/* ============================================================
   STYLE.CSS — Nexus PDV — Sistema de Controle de Vendas
   Design System Completo | Tema Claro/Escuro
   ============================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background 0.25s, color 0.25s;
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }

/* ============================================================
   VARIÁVEIS — TEMA CLARO
   ============================================================ */
:root, [data-theme="light"] {
  --primary:         #6366f1;
  --primary-dark:    #4f46e5;
  --primary-light:   #ede9fe;
  --secondary:       #10b981;
  --secondary-dark:  #059669;
  --danger:          #ef4444;
  --warning:         #f59e0b;
  --info:            #3b82f6;
  --purple:          #8b5cf6;
  --pink:            #ec4899;

  --bg-app:          #f1f5f9;
  --bg-card:         #ffffff;
  --bg-sidebar:      #0f172a;
  --bg-table-alt:    #f8fafc;

  --text-primary:    #0f172a;
  --text-secondary:  #334155;
  --text-muted:      #64748b;
  --border:          #e2e8f0;
  --border-focus:    #6366f1;

  --shadow-sm:       0 1px 3px rgba(0,0,0,0.08);
  --shadow:          0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:       0 10px 40px rgba(0,0,0,0.12);
  --radius:          12px;
  --radius-sm:       8px;
  --radius-lg:       16px;

  --sidebar-w:       240px;
  --topbar-h:        62px;
  --transition:      0.18s ease;
}

/* ============================================================
   VARIÁVEIS — TEMA ESCURO
   ============================================================ */
[data-theme="dark"] {
  --primary:         #818cf8;
  --primary-dark:    #6366f1;
  --primary-light:   #1e1b4b;
  --secondary:       #34d399;
  --secondary-dark:  #10b981;
  --danger:          #f87171;
  --warning:         #fbbf24;
  --info:            #60a5fa;
  --purple:          #a78bfa;
  --pink:            #f472b6;

  --bg-app:          #0f172a;
  --bg-card:         #1e293b;
  --bg-sidebar:      #0a1120;
  --bg-table-alt:    #162032;

  --text-primary:    #f1f5f9;
  --text-secondary:  #cbd5e1;
  --text-muted:      #64748b;
  --border:          #334155;
  --border-focus:    #818cf8;

  --shadow-sm:       0 1px 3px rgba(0,0,0,0.3);
  --shadow:          0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg:       0 10px 40px rgba(0,0,0,0.5);
}

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
#login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  z-index: 1000;
}
#login-screen.hidden { display: none; }

#app-container {
  display: flex;
  min-height: 100vh;
}
#app-container.hidden { display: none; }

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  position: fixed; left: 0; top: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
  transition: width var(--transition);
  box-shadow: 2px 0 20px rgba(0,0,0,0.3);
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
}
.brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 17px; flex-shrink: 0;
}
.brand-text h2 {
  font-size: 16px; font-weight: 800; color: #f1f5f9;
  letter-spacing: -0.3px;
}
.brand-text span {
  font-size: 11px; color: #64748b; font-weight: 500;
}

.sidebar-nav {
  flex: 1; overflow-y: auto; padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.nav-section-title {
  padding: 14px 18px 5px;
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: #475569;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  color: #94a3b8; font-size: 13.5px; font-weight: 500;
  cursor: pointer; border-radius: 0;
  transition: all var(--transition);
  position: relative; margin: 1px 8px; border-radius: 8px;
}
.nav-item i { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #f1f5f9; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(99,102,241,0.25), rgba(99,102,241,0.1));
  color: #a5b4fc;
  border-left: 3px solid var(--primary);
  font-weight: 700;
}
.nav-item.active i { color: var(--primary); }
.nav-badge {
  margin-left: auto;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px; border-radius: 10px; cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user:hover { background: rgba(255,255,255,0.06); }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 800; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 700; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: #64748b; }
.user-logout { color: #475569; font-size: 14px; flex-shrink: 0; transition: color var(--transition); }
.sidebar-user:hover .user-logout { color: var(--danger); }

/* ============================================================
   MAIN AREA
   ============================================================ */
#main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* TOPBAR */
#topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-title {
  font-size: 17px; font-weight: 800; color: var(--text-primary);
  white-space: nowrap;
}
.topbar-subtitle {
  font-size: 12px; color: var(--text-muted); margin-top: 1px;
  white-space: nowrap;
}
.topbar-search {
  flex: 1; max-width: 360px; margin: 0 auto;
  position: relative;
}
.topbar-search i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 13px;
}
.topbar-search input {
  width: 100%; padding: 9px 14px 9px 36px;
  background: var(--bg-app); border: 1.5px solid var(--border);
  border-radius: 25px; font-size: 13px; color: var(--text-primary);
  transition: all var(--transition); outline: none;
}
.topbar-search input:focus {
  border-color: var(--primary); background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-btn {
  width: 36px; height: 36px; border-radius: 9px;
  background: none; border: 1.5px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all var(--transition);
  position: relative;
}
.topbar-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.topbar-badge {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; background: var(--danger); border-radius: 50%;
  border: 2px solid var(--bg-card);
}

/* PAGES */
.page { display: none; padding: 24px; }
.page.active { display: block; animation: fadeInPage 0.22s ease; }

@keyframes fadeInPage {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes animate-fade {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fade { animation: animate-fade 0.3s ease forwards; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 14px; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
.card-title i { color: var(--primary); }
.card-body { padding: 18px; }

/* ============================================================
   GRIDS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .grid-3 { grid-template-columns: 1fr; }
}

/* ============================================================
   METRICS / KPI CARDS
   ============================================================ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: default;
}
.metric-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.metric-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.metric-icon.purple { background: #ede9fe; color: #7c3aed; }
.metric-icon.green  { background: #d1fae5; color: #059669; }
.metric-icon.blue   { background: #dbeafe; color: #2563eb; }
.metric-icon.amber  { background: #fef3c7; color: #d97706; }
.metric-icon.pink   { background: #fce7f3; color: #be185d; }
.metric-icon.red    { background: #fee2e2; color: #dc2626; }
[data-theme="dark"] .metric-icon.purple { background: rgba(139,92,246,0.2); color: #a78bfa; }
[data-theme="dark"] .metric-icon.green  { background: rgba(16,185,129,0.2); color: #34d399; }
[data-theme="dark"] .metric-icon.blue   { background: rgba(59,130,246,0.2); color: #60a5fa; }
[data-theme="dark"] .metric-icon.amber  { background: rgba(245,158,11,0.2); color: #fbbf24; }
[data-theme="dark"] .metric-icon.pink   { background: rgba(236,72,153,0.2); color: #f472b6; }
[data-theme="dark"] .metric-icon.red    { background: rgba(239,68,68,0.2); color: #f87171; }
.metric-data .value {
  font-size: 22px; font-weight: 900; color: var(--text-primary);
  line-height: 1.1;
}
.metric-data .label {
  font-size: 12.5px; color: var(--text-muted); margin-top: 3px;
}
.metric-data .change {
  font-size: 11.5px; font-weight: 600; margin-top: 5px;
  display: flex; align-items: center; gap: 4px;
}
.change.up   { color: var(--secondary); }
.change.down { color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg-app); }
th {
  padding: 11px 14px;
  text-align: left; font-size: 11.5px;
  font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  font-size: 13.5px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-app); }
.amount-positive { color: var(--secondary) !important; font-weight: 700; }
.text-bold { font-weight: 700; }

/* ============================================================
   FORMULÁRIOS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12.5px; font-weight: 700;
  color: var(--text-secondary); margin-bottom: 6px;
  letter-spacing: 0.2px;
}
.form-label .required { color: var(--danger); }
.form-control {
  width: 100%; padding: 10px 13px;
  background: var(--bg-app); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13.5px;
  color: var(--text-primary); outline: none;
  transition: all var(--transition);
  -webkit-appearance: none;
}
.form-control:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control[readonly], .form-control[disabled] {
  opacity: 0.7; cursor: default;
}
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 36px;
  cursor: pointer;
}
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; display: block; }
.form-row { display: grid; gap: 14px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* Switch */
.form-switch {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none;
}
.switch-track {
  width: 40px; height: 22px; border-radius: 12px;
  background: var(--border); position: relative;
  transition: background 0.2s; flex-shrink: 0;
}
.switch-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 9px 18px;
  font-size: 13.5px; font-weight: 600;
  border-radius: var(--radius-sm); cursor: pointer;
  border: 1.5px solid transparent; transition: all var(--transition);
  white-space: nowrap; line-height: 1.4;
  text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; gap: 5px; }
.btn-lg { padding: 13px 24px; font-size: 15px; border-radius: 10px; }
.btn-icon { width: 32px; height: 32px; padding: 0; gap: 0; }

.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark); border-color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.btn-secondary {
  background: var(--secondary); color: #fff; border-color: var(--secondary);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--secondary-dark); border-color: var(--secondary-dark);
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}
.btn-danger {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { opacity: 0.88; box-shadow: 0 4px 12px rgba(239,68,68,0.3); }
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-outline {
  background: transparent; color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover:not(:disabled) { background: var(--primary); color: #fff; }
.w-full { width: 100%; }

/* Payment buttons */
.payment-btn.btn-primary {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  border-color: var(--primary) !important;
  font-weight: 700;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 25px;
  font-size: 11.5px; font-weight: 700;
  white-space: nowrap;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: var(--bg-app); color: var(--text-muted); border: 1px solid var(--border); }
.badge-purple  { background: #ede9fe; color: #5b21b6; }
.badge-primary { background: var(--primary-light); color: var(--primary); }
[data-theme="dark"] .badge-success { background: rgba(16,185,129,0.2); color: #34d399; }
[data-theme="dark"] .badge-danger  { background: rgba(239,68,68,0.2);  color: #f87171; }
[data-theme="dark"] .badge-warning { background: rgba(245,158,11,0.2); color: #fbbf24; }
[data-theme="dark"] .badge-info    { background: rgba(59,130,246,0.2); color: #60a5fa; }
[data-theme="dark"] .badge-gray    { background: rgba(255,255,255,0.06); color: #64748b; }
[data-theme="dark"] .badge-purple  { background: rgba(139,92,246,0.2); color: #a78bfa; }

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex; gap: 4px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  overflow-x: auto;
}
.tab-btn {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all var(--transition); white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn:hover { color: var(--text-primary); background: var(--bg-card); }
.tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-header-left h1 {
  font-size: 22px; font-weight: 900; color: var(--text-primary);
  display: flex; align-items: center; gap: 8px;
}
.page-header-left p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.page-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px; align-items: center;
}
.search-input-wrap {
  position: relative;
}
.search-input-wrap i {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 13px;
  pointer-events: none;
}
.search-input-wrap input {
  width: 100%; padding: 10px 14px 10px 36px;
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13.5px;
  color: var(--text-primary); outline: none;
  transition: all var(--transition);
}
.search-input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.search-input-wrap input::placeholder { color: var(--text-muted); }
.filter-select {
  padding: 9px 34px 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px;
  color: var(--text-primary); background: var(--bg-card);
  outline: none; cursor: pointer; transition: border-color var(--transition);
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 11px;
}
.filter-select:focus { border-color: var(--primary); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-top: 1px solid var(--border);
  flex-wrap: wrap; gap: 10px;
}
.pagination-info { font-size: 12.5px; color: var(--text-muted); }
.pagination-controls { display: flex; gap: 4px; }
.page-btn {
  min-width: 32px; height: 32px; padding: 0 6px;
  border: 1.5px solid var(--border); border-radius: 7px;
  background: var(--bg-card); color: var(--text-secondary);
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover:not(.disabled):not(.active) {
  border-color: var(--primary); color: var(--primary); background: var(--primary-light);
}
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn.disabled { opacity: 0.4; cursor: default; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 52px; margin-bottom: 14px; opacity: 0.35; display: block; }
.empty-state h3 { font-size: 17px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 13.5px; line-height: 1.6; margin-bottom: 18px; }

/* ============================================================
   CHARTS
   ============================================================ */
.chart-container { position: relative; }

/* ============================================================
   MODAIS
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; animation: fadeInModal 0.2s ease; }

@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  animation: slideInModal 0.22s ease;
}
.modal.modal-lg { max-width: 780px; }
.modal.modal-xl { max-width: 1000px; }

@keyframes slideInModal {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-card); z-index: 2;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-title {
  font-size: 16px; font-weight: 800; color: var(--text-primary);
}
.modal-close {
  width: 30px; height: 30px;
  background: var(--bg-app); border: none; border-radius: 7px;
  color: var(--text-muted); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--danger); color: #fff; }
.modal-body { padding: 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-app);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  flex-wrap: wrap;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 300; display: flex; flex-direction: column; gap: 10px;
  max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateX(110%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  min-width: 280px; max-width: 360px;
}
.toast.show { transform: translateX(0); }
.toast-left {
  width: 4px; flex-shrink: 0; align-self: stretch;
}
.toast-icon {
  padding: 14px 12px 14px 10px;
  display: flex; align-items: center; font-size: 15px;
  flex-shrink: 0;
}
.toast-content { flex: 1; padding: 12px 6px; }
.toast-title { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }
.toast-msg { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.5; }

.toast-success .toast-left { background: var(--secondary); }
.toast-success .toast-icon { color: var(--secondary); }
.toast-error .toast-left { background: var(--danger); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-left { background: var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-left { background: var(--info); }
.toast-info .toast-icon { color: var(--info); }

/* ============================================================
   CONFIRM MODAL
   ============================================================ */
#confirm-modal .modal { max-width: 420px; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 40px;
  width: 100%; max-width: 420px;
  backdrop-filter: blur(20px);
  box-shadow: 0 25px 60px rgba(0,0,0,0.4);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 18px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff;
  box-shadow: 0 8px 24px rgba(99,102,241,0.4);
}
.login-logo h1 { font-size: 26px; font-weight: 900; color: #f1f5f9; }
.login-logo p  { font-size: 13px; color: #64748b; margin-top: 5px; }
.login-form .form-group { margin-bottom: 18px; }
.login-form .form-group label { display: block; font-size: 13px; font-weight: 600; color: #94a3b8; margin-bottom: 8px; }
.login-form input {
  width: 100%; padding: 12px 16px;
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 10px; color: #f1f5f9;
  font-size: 14px; outline: none;
  transition: all var(--transition);
}
.login-form input:focus {
  border-color: #6366f1;
  background: rgba(255,255,255,0.1);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
}
.login-form input::placeholder { color: #475569; }
.btn-login {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 6px;
}
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(99,102,241,0.4); }
.login-error {
  display: none; background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 10px; padding: 11px 14px;
  color: #fca5a5; font-size: 13px;
  margin-bottom: 16px;
}
.login-error.show { display: flex; align-items: center; gap: 8px; }
.login-hint {
  text-align: center; margin-top: 20px;
  padding-top: 18px; border-top: 1px solid rgba(255,255,255,0.07);
}
.login-hint p { font-size: 12px; color: #475569; line-height: 1.9; }
.login-hint strong { color: #94a3b8; }

/* ============================================================
   PDV — PONTO DE VENDA
   ============================================================ */
.pdv-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 18px;
  height: calc(100vh - var(--topbar-h) - 130px);
  min-height: 520px;
}
.pdv-products-panel {
  display: flex; flex-direction: column; gap: 12px;
  overflow: hidden;
}
.pdv-cart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.pdv-cart-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-app);
}
.pdv-cart-title {
  font-size: 15px; font-weight: 800;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-primary);
}
.pdv-cart-items {
  flex: 1; overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.pdv-cart-items::-webkit-scrollbar { width: 4px; }
.pdv-cart-items::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.cart-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px;
  border-radius: 9px; margin-bottom: 5px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.cart-item:hover { border-color: var(--primary); }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name {
  font-size: 12.5px; font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cart-item-price { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.cart-item-qty {
  display: flex; align-items: center; gap: 5px; flex-shrink: 0;
}
.qty-btn {
  width: 24px; height: 24px;
  border-radius: 6px; background: var(--bg-card);
  border: 1.5px solid var(--border); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--text-secondary);
  transition: all var(--transition); user-select: none;
}
.qty-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.qty-val {
  min-width: 26px; text-align: center;
  font-size: 14px; font-weight: 800; color: var(--text-primary);
}
.cart-item-total {
  font-size: 13px; font-weight: 800; color: var(--primary);
  min-width: 65px; text-align: right; flex-shrink: 0;
}
.cart-item-remove {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  border-radius: 5px; cursor: pointer; color: var(--text-muted);
  transition: all var(--transition); font-size: 12px;
  flex-shrink: 0;
}
.cart-item-remove:hover { background: var(--danger); color: #fff; }

.pdv-totals {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-app);
}
.total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; font-size: 13.5px;
}
.total-row .label { color: var(--text-muted); font-weight: 500; }
.total-row .val { font-weight: 700; color: var(--text-primary); }
.total-row.grand {
  font-size: 16px; font-weight: 900;
  padding: 8px 0; margin-top: 4px;
  border-top: 2px solid var(--border);
}
.total-row.grand .val { color: var(--primary); font-size: 20px; }

.discount-input-row {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 0;
}
.discount-input-row select {
  padding: 8px 10px; border: 1.5px solid var(--border);
  border-radius: 7px; background: var(--bg-card); font-size: 13px;
  color: var(--text-primary); outline: none; cursor: pointer; width: 64px;
}
.discount-input-row input {
  flex: 1; padding: 8px 10px; border: 1.5px solid var(--border);
  border-radius: 7px; background: var(--bg-card); font-size: 13px;
  color: var(--text-primary); outline: none;
  transition: border-color var(--transition);
}
.discount-input-row input:focus { border-color: var(--primary); }

.pdv-actions {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.pdv-actions .btn-lg {
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  border-color: transparent;
}
.pdv-actions .btn-lg:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(16,185,129,0.35);
  transform: translateY(-1px);
}

/* ============================================================
   PRODUCT GRID / CARDS
   ============================================================ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 12px;
}
.product-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; cursor: pointer;
  transition: all var(--transition);
}
.product-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.prod-img {
  height: 110px; background: var(--bg-app);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.prod-img i { font-size: 32px; color: var(--border); }
.prod-info { padding: 10px 12px; }
.prod-name {
  font-size: 13px; font-weight: 700; color: var(--text-primary);
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  line-height: 1.4; min-height: 36px;
}
.prod-sku { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.prod-price { font-size: 15px; font-weight: 800; color: var(--primary); }
.prod-stock { font-size: 11px; color: var(--text-muted); }

/* Product image preview */
.product-img-preview {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px;
  color: var(--text-muted); font-size: 13px; overflow: hidden;
}
.product-img-preview img { width: 100%; height: 100%; object-fit: cover; }
.product-img-preview i { font-size: 28px; color: var(--border); }

/* ============================================================
   STOCK ALERTS
   ============================================================ */
.stock-alert-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.stock-alert-item:last-child { border-bottom: none; }
.stock-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.stock-dot.zero    { background: var(--danger); }
.stock-dot.critical { background: var(--warning); }
.stock-alert-info { flex: 1; min-width: 0; }
.stock-alert-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stock-alert-detail { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar {
  height: 7px; background: var(--bg-app);
  border-radius: 4px; overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ============================================================
   KBD TAG
   ============================================================ */
kbd.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 7px; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 5px; font-size: 11.5px; font-weight: 700;
  color: var(--text-muted); font-family: 'Courier New', monospace;
}

/* ============================================================
   RECEIPT (COMPROVANTE)
   ============================================================ */
#receipt-body .divider {
  border-top: 1px dashed var(--border); margin: 10px 0;
}
#receipt-body .center { text-align: center; }
#receipt-body .bold { font-weight: 700; }
#receipt-body .big { font-size: 16px; }
#receipt-body .row {
  display: flex; justify-content: space-between; margin: 4px 0;
  font-size: 13px;
}

/* ============================================================
   UTILITY
   ============================================================ */
.hidden   { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

/* Tooltip */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: #0f172a; color: #f1f5f9;
  padding: 5px 10px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap; pointer-events: none;
  z-index: 400; box-shadow: var(--shadow);
}

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
  .pdv-layout { grid-template-columns: 1fr 340px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  #sidebar {
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  #sidebar.open { transform: translateX(0); }

  #main-area { margin-left: 0; }

  .pdv-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .pdv-cart-panel {
    height: auto;
    min-height: 400px;
  }

  .page { padding: 16px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .topbar-search { display: none; }

  .form-row.cols-2,
  .form-row.cols-3 { grid-template-columns: 1fr; }

  .page-header { flex-direction: column; align-items: flex-start; }
  .search-bar { flex-direction: column; }
  .search-bar .search-input-wrap { width: 100%; }
  .filter-select { width: 100%; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }

  #topbar { padding: 0 14px; }
  .topbar-title { font-size: 15px; }
}

@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .modal { border-radius: 12px 12px 0 0; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .login-card { padding: 28px 22px; border-radius: 16px 16px 0 0; }
  #login-screen { align-items: flex-end; }
}

/* ============================================================
   SCROLLBAR GLOBAL
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   ANIMAÇÕES EXTRAS
   ============================================================ */
@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
.nav-badge { animation: pulse-badge 2s ease-in-out infinite; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-app) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}

/* ============================================================
   MELHORIAS DE ACESSIBILIDADE
   ============================================================ */
:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  #sidebar, #topbar, #toast-container, .modal-overlay:not(#receipt-modal) { display: none !important; }
  #main-area { margin-left: 0; }
  .page { padding: 0; }
  #receipt-body {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    max-width: 300px;
    margin: 0 auto;
  }
}

/* ============================================================
   TRANSIÇÕES SUAVES GLOBAIS
   ============================================================ */
.card, .metric-card, .product-card, .nav-item,
.btn, .badge, .tab-btn, .page-btn {
  transition: all 0.18s ease;
}

/* ============================================================
   INDICADOR DE CARREGAMENTO (spinner inline)
   ============================================================ */
.loading-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
