:root {
  --bg: #f3f5f8;
  --ink: #1c2430;
  --muted: #667085;
  --line: #e6e9ef;
  --card: #ffffff;
  --sidebar: #121826;
  --sidebar-text: #d5dbe6;
  --accent: #0f766e;
  --accent-ink: #115e59;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 10px 28px rgba(16, 24, 40, 0.05);
  --radius: 16px;
  --sidebar-w: 252px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.sidebar-brand { padding: 20px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar-brand a { display: flex; gap: 12px; align-items: center; color: #fff; text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 18px; flex: none;
}
.brand-name, .brand-sub { display: block; }
.brand-name { font-weight: 700; letter-spacing: -.02em; }
.brand-sub { color: #9aa3b5; font-size: 12px; margin-top: 1px; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-nav { padding: 12px; overflow: auto; flex: 1; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--sidebar-text); text-decoration: none;
  padding: 9px 12px; border-radius: 10px; margin-bottom: 2px; font-weight: 600;
}
.side-nav a i { font-size: 17px; width: 20px; }
.side-nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.side-nav a.active { background: rgba(15, 118, 110, .28); color: #ccfbf1; }
.nav-count {
  margin-left: auto; background: #b45309; color: #fff;
  border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center; font-size: 12px;
}

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.user-chip { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.user-chip strong, .user-chip small { display: block; }
.user-chip strong { color: #fff; font-size: 14px; }
.user-chip small { color: #9aa3b5; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #1f2937; color: #fff;
  display: grid; place-items: center; font-weight: 700;
}

.content { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  height: 64px; display: flex; align-items: center; gap: 12px;
  padding: 0 24px; position: sticky; top: 0; z-index: 20;
  background: rgba(243, 245, 248, .92); backdrop-filter: blur(10px);
}
.topbar-title { font-weight: 700; letter-spacing: -.02em; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.menu-btn { display: none; }
.page { padding: 4px 24px 48px; }

.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin: 8px 0 18px; }
.page-head h1 { font-size: 30px; letter-spacing: -.035em; margin: 0; font-weight: 750; }
.page-sub { color: var(--muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel {
  background: var(--card); border: 1px solid #eef0f3; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.panel h2, .panel h3 { font-size: 16px; margin: 0 0 12px; letter-spacing: -.02em; }
.panel + .panel, .stack > * + * { margin-top: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: #fff; border: 1px solid #eef0f3; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; text-decoration: none; color: inherit; display: block; min-height: 112px;
}
.stat-card:hover { border-color: #d7dce4; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 650; }
.stat-value { font-size: 24px; font-weight: 750; letter-spacing: -.03em; margin-top: 8px; }
.stat-hint { color: #98a2b3; font-size: 12px; margin-top: 4px; }
.stat-card.alert-card { background: #fffaf3; }

.dash-grid { display: grid; grid-template-columns: 1.4fr .8fr; gap: 16px; margin-top: 16px; }
.dash-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }

.table-app { margin-bottom: 0; }
.table-app thead th {
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: #667085; font-weight: 750; white-space: nowrap;
}
.table-app td { vertical-align: middle; }
.table-app a.row-link { font-weight: 700; color: var(--ink); text-decoration: none; }
.table-app a.row-link:hover { color: var(--accent-ink); }

.badge-stock { font-weight: 700; border-radius: 999px; padding: .35em .6em; }
.badge-ok { background: #e7f8ef; color: #067647; }
.badge-low { background: #fff4e5; color: #b54708; }
.badge-out { background: #fdecec; color: #b42318; }
.money-pos { color: #067647; font-weight: 750; }
.money-neg { color: #b42318; font-weight: 750; }
.money-zero { color: var(--ink); font-weight: 650; }

.thumb, .thumb-ph {
  width: 42px; height: 42px; border-radius: 10px; object-fit: cover; background: #eef2f6;
  display: inline-grid; place-items: center; color: #98a2b3;
}
.product-cell { display: flex; gap: 10px; align-items: center; }
.product-cell small, .muted { color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters .form-control, .filters .form-select { width: auto; min-width: 140px; }

.period-links { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.period-links a {
  text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-weight: 650; font-size: 13px;
}
.period-links a.active { background: var(--sidebar); color: #fff; border-color: var(--sidebar); }

.line-row { padding: 12px 0; border-top: 1px solid var(--line); }
.line-row:first-child { border-top: 0; padding-top: 0; }
.line-grid { display: grid; grid-template-columns: minmax(220px, 1.6fr) 90px 130px 120px 48px; gap: 10px; align-items: end; }
.line-total { background: #f8fafc; }

.recon { width: 100%; }
.recon td { padding: 7px 0; border-bottom: 1px solid #f0f2f5; }
.recon tr:last-child td { border-bottom: 0; font-weight: 750; }
.recon td:last-child { text-align: right; }

.empty-state { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty-state i { font-size: 28px; color: #98a2b3; }
.empty-state h2 { font-size: 18px; color: var(--ink); margin: 8px 0 4px; }

.help { color: var(--muted); font-size: 13px; }
.scan-row { display: flex; gap: 8px; }
.scan-row .form-control { flex: 1; }

#scanVideo { width: 100%; border-radius: 12px; background: #111; min-height: 180px; }

.invoice { max-width: 860px; margin: 0 auto; }
.invoice-top { display: flex; justify-content: space-between; gap: 20px; }
.invoice h1 { font-size: 28px; margin: 0; }
.totals-table { width: 280px; margin-left: auto; }
.totals-table td { padding: 4px 0; }
.totals-table td:last-child { text-align: right; }

.guest-body { min-height: 100vh; background: linear-gradient(160deg, #121826 0%, #1b3a36 48%, #f3f5f8 48%); }
.guest-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(920px, 100%); display: grid; grid-template-columns: 1fr 1fr; background: #fff; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); }
.login-copy { background: #121826; color: #fff; padding: 40px 32px; }
.login-copy h1 { font-size: 34px; letter-spacing: -.04em; margin: 16px 0 8px; }
.login-copy p { color: #c5cedd; }
.login-form { padding: 40px 32px; }
.install-wrap { width: min(760px, 100%); }
.install-card { background: #fff; border-radius: 24px; padding: 28px; box-shadow: var(--shadow); }
.check-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0f2f5; }
.check-ok { color: #067647; font-weight: 700; }
.check-bad { color: #b42318; font-weight: 700; }

.sidebar-backdrop { display: none; }

@media (max-width: 1100px) {
  .dash-grid, .dash-split, .login-card { grid-template-columns: 1fr; }
  .login-copy { display: none; }
}

@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .content { margin-left: 0; }
  .sidebar { transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 30; }
  .page, .topbar { padding-left: 16px; padding-right: 16px; }
  .line-grid { grid-template-columns: 1fr 1fr; }
  .page-head { flex-direction: column; }
  .topbar-title { display: none; }
}

@media print {
  .sidebar, .topbar, .page-actions, .no-print, .sidebar-backdrop, .btn, .alert { display: none !important; }
  .content { margin: 0 !important; }
  .page { padding: 0 !important; }
  .panel { box-shadow: none; }
  body { background: #fff; }
}
