:root {
  --brand: #7c3aed;
  --brand-dark: #5b21b6;
  --brand-light: #ede9fe;
  --accent: #f59e0b;
  --sidebar-bg: #171425;
  --sidebar-bg-2: #201c33;
  --sidebar-text: #b7b2cf;
  --sidebar-text-active: #ffffff;
  --bg: #f5f6fb;
  --card-bg: #ffffff;
  --border: #e7e7f1;
  --text: #1f2130;
  --text-muted: #6b7085;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
}

a { text-decoration: none; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff;
  letter-spacing: .2px;
}
.brand-icon { font-size: 1.4rem; }

.sidebar-nav { flex: 1; padding: 6px 12px; }

.nav-section {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #756f95;
  font-weight: 700;
  margin: 18px 12px 8px;
}
.nav-section:first-child { margin-top: 4px; }

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: .9rem;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.sidebar .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124,58,237,.45);
}
.sidebar-footer { padding: 14px 12px 20px; border-top: 1px solid rgba(255,255,255,.08); }

/* Main area */
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 66px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.page-title { font-size: 1.15rem; font-weight: 700; margin: 0; flex: 1; }
.btn-icon {
  border: none; background: transparent; font-size: 1.3rem; color: var(--text);
  width: 38px; height: 38px; border-radius: 10px;
}
.btn-icon:hover { background: var(--bg); }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip .dropdown-toggle {
  display: flex; align-items: center; gap: 10px; border: none; background: var(--bg);
  padding: 6px 12px 6px 6px; border-radius: 999px; cursor: pointer;
}
.user-chip .dropdown-toggle::after { display: none; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
.user-name { font-weight: 600; font-size: .87rem; }

.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* Cards */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(20,20,50,.03);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  padding: 16px 20px;
}
.card-body { padding: 20px; }

.stat-card {
  border-radius: var(--radius);
  padding: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff; flex-shrink: 0;
}
.stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: .8rem; font-weight: 600; }

/* Buttons */
.btn { border-radius: 10px; font-weight: 600; font-size: .88rem; padding: 8px 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }
.btn-sm { padding: 5px 10px; font-size: .8rem; border-radius: 8px; }

/* Tables */
.table-wrap { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { margin-bottom: 0; }
.table thead th {
  background: #faf9fd;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
  padding: 12px 16px;
  white-space: nowrap;
}
.table td { padding: 12px 16px; vertical-align: middle; border-bottom: 1px solid var(--border); font-size: .89rem; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fbfaff; }

.badge-status { padding: 5px 10px; border-radius: 999px; font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; }
.badge-pendente { background: #fef3c7; color: #92400e; }
.badge-recebido { background: #dcfce7; color: #166534; }
.badge-cancelado { background: #fee2e2; color: #991b1b; }
.badge-concluida { background: #dcfce7; color: #166534; }
.badge-baixo { background: #fee2e2; color: #991b1b; }
.badge-ok { background: #dcfce7; color: #166534; }

.form-label { font-weight: 600; font-size: .85rem; margin-bottom: 5px; }
.form-control, .form-select {
  border-radius: 10px; border: 1px solid var(--border); padding: 9px 12px; font-size: .9rem;
}
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124,58,237,.12); }

.filter-bar { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 18px; }

/* Login page */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #2a1f4d, #14101f 60%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-logo { text-align: center; font-size: 2.2rem; margin-bottom: 6px; }
.login-title { text-align: center; font-weight: 800; font-size: 1.3rem; margin-bottom: 2px; }
.login-sub { text-align: center; color: var(--text-muted); font-size: .85rem; margin-bottom: 24px; }

/* PDV */
.pdv-grid { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
@media (max-width: 992px) { .pdv-grid { grid-template-columns: 1fr; } }
.pdv-search { position: relative; }
.pdv-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 30px rgba(20,20,50,.12);
  max-height: 340px; overflow-y: auto; z-index: 50; display: none;
}
.pdv-result-item { padding: 10px 14px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--border); }
.pdv-result-item:last-child { border-bottom: none; }
.pdv-result-item:hover { background: var(--brand-light); }
.pdv-result-item .nome { font-weight: 600; }
.pdv-result-item .meta { font-size: .78rem; color: var(--text-muted); }
.pdv-cart-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.pdv-cart-item:last-child { border-bottom: none; }
.pdv-cart-item .nome { font-weight: 600; font-size: .87rem; }
.pdv-cart-item .sub { font-size: .77rem; color: var(--text-muted); }
.pdv-qty-input { width: 62px; text-align: center; }
.pdv-total-box { background: var(--sidebar-bg); color: #fff; border-radius: var(--radius); padding: 20px; }
.pdv-total-box .valor { font-size: 2rem; font-weight: 800; }
.pay-method-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; }
  .content { padding: 16px; }
}

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 10px; display: block; color: #cfcbe6; }

.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv-list .row-item { display: flex; justify-content: space-between; font-size: .88rem; }
.kv-list .row-item .k { color: var(--text-muted); }

.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--brand-light); color: var(--brand-dark); font-weight: 600; font-size: .76rem; }
