:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #1e293b;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #0d9488;
  --accent-weak: #ccfbf1;
  --success: #16a34a;
  --success-weak: #dcfce7;
  --warn: #d97706;
  --track: #e5e9ee;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --panel: #121a2b;
    --sidebar: #0a0f1c;
    --sidebar-text: #94a3b8;
    --sidebar-active: #17223a;
    --text: #e6edf6;
    --muted: #8b98ac;
    --border: #223049;
    --accent: #2dd4bf;
    --accent-weak: #123b38;
    --success: #34d399;
    --success-weak: #10362a;
    --track: #1e2a41;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 22px; }
.brand-logo { font-size: 26px; }
.brand-name { font-weight: 700; color: #fff; font-size: 17px; line-height: 1.1; display: flex; flex-direction: column; }
.brand-name small { font-weight: 500; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--sidebar-text); }

nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: 10px;
  color: var(--sidebar-text); text-decoration: none;
  font-size: 14.5px; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--sidebar-active); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-ico { font-size: 16px; width: 18px; text-align: center; }

.logout { margin-top: auto; }
.logout button {
  width: 100%; padding: 10px; border: 1px solid rgba(255,255,255,.12);
  background: transparent; color: var(--sidebar-text);
  border-radius: 10px; cursor: pointer; font-size: 13.5px;
}
.logout button:hover { background: var(--sidebar-active); color: #fff; }

.content { flex: 1; padding: 30px 34px 60px; max-width: 1100px; }

/* ---------- Page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 26px; gap: 16px; flex-wrap: wrap; }
h1 { font-size: 24px; margin: 0; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.live { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); padding: 7px 12px; border-radius: 999px; box-shadow: var(--shadow); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.live-dot.ok { background: var(--success); box-shadow: 0 0 0 4px var(--success-weak); }
.live-dot.stale { background: var(--warn); }
.live-dot.err { background: #dc2626; }

/* ---------- Sections & cards ---------- */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 30px 0 12px; display: flex; align-items: center; gap: 10px; }
.goal-chip { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 12px; color: var(--accent); background: var(--accent-weak); padding: 3px 9px; border-radius: 999px; }
.muted { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.card-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.stat { font-size: 34px; font-weight: 750; letter-spacing: -.02em; line-height: 1; }
.stat-sub { font-size: 17px; color: var(--muted); font-weight: 600; }
.card-foot { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.card.met .stat { color: var(--success); }

/* progress bar with goal marker */
.bar { position: relative; height: 9px; background: var(--track); border-radius: 999px; margin-top: 14px; overflow: hidden; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); border-radius: 999px; transition: width .5s ease; }
.card.met .bar-fill { background: var(--success); }
.bar-goal { position: absolute; right: 0; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .25; }

/* ---------- Sales table ---------- */
.table-card { padding: 0; overflow: hidden; }
.sales { width: 100%; border-collapse: collapse; font-size: 14px; }
.sales th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 13px 20px; border-bottom: 1px solid var(--border); font-weight: 600; }
.sales td { padding: 13px 20px; border-bottom: 1px solid var(--border); }
.sales tr:last-child td { border-bottom: none; }
.sales tbody tr:hover { background: var(--bg); }
.sales .right, th.right { text-align: right; }
.sales .amount { font-weight: 650; font-variant-numeric: tabular-nums; }
.sales .ordno { color: var(--accent); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* ---------- Placeholder (SOPs) ---------- */
.placeholder { text-align: center; padding: 54px 20px; }
.placeholder-ico { font-size: 42px; }
.placeholder h3 { margin: 12px 0 6px; }
.placeholder p { color: var(--muted); margin: 0; }

/* ---------- Login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; background: var(--bg); }
.login-split {
  display: grid; grid-template-columns: 1.05fr 1fr;
  width: 100%; max-width: 840px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(15,23,42,.16);
}

/* Left: branded panel — mirrors the dashboard sidebar */
.login-brand {
  background: var(--sidebar); color: var(--sidebar-text);
  padding: 40px 36px; display: flex; flex-direction: column; gap: 26px;
}
.login-brand .brand { padding: 0; }
.login-brand-copy h2 { color: #fff; font-size: 22px; margin: 0 0 8px; letter-spacing: -.01em; }
.login-brand-copy p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--sidebar-text); }
.login-points { list-style: none; margin: auto 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.login-points li { display: flex; align-items: center; gap: 11px; font-size: 13.5px; color: #e2e8f0; }
.login-points li span {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px;
  display: grid; place-items: center; font-size: 15px;
  background: rgba(45,212,191,.14);
}

/* Right: form */
.login-form-panel { padding: 46px 40px; display: flex; flex-direction: column; justify-content: center; }
.login-form-panel h1 { font-size: 23px; margin: 0 0 4px; }
.login-sub { color: var(--muted); margin: 0 0 26px; font-size: 14px; }
.login-form-panel label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.login-form-panel input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px; background: var(--bg); color: var(--text);
}
.login-form-panel input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.login-form-panel button {
  width: 100%; margin-top: 18px; padding: 12px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: filter .12s;
}
.login-form-panel button:hover { filter: brightness(1.06); }
.login-error { color: #dc2626; font-size: 13px; margin: 16px 0 0; }

@media (max-width: 680px) {
  .login-split { grid-template-columns: 1fr; max-width: 420px; }
  .login-brand { padding: 30px 28px; gap: 20px; }
  .login-points { display: none; }
  .login-form-panel { padding: 32px 28px 36px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px; }
  .sidebar nav { flex-direction: row; }
  .brand { padding: 0 12px 0 6px; }
  .brand-name small { display: none; }
  .logout { margin: 0 0 0 auto; }
  .logout button { width: auto; padding: 9px 14px; }
  .content { padding: 20px 16px 40px; }
  .grid-2 { grid-template-columns: 1fr; }
  .sales th:nth-child(3), .sales td:nth-child(3),
  .sales th:nth-child(4), .sales td:nth-child(4) { display: none; }
}
