:root {
  --bg: #fbfbfc;
  --surface: #ffffff;
  --border: #e9e9ec;
  --border-subtle: #f1f1f3;
  --text: #16181d;
  --muted: #6f737c;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --warn: #b45309;
  --ok: #15803d;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 0.15rem; }
h2 { font-size: 1.02rem; font-weight: 640; letter-spacing: -0.01em; margin: 1.6rem 0 0.6rem; }
h3 { font-size: 0.9rem; font-weight: 600; margin: 0; }
p { margin: 0.4rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.center { text-align: center; }
.r { text-align: right; }
.danger { color: var(--danger); }
.warn { color: var(--warn); }

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

.sidebar {
  width: 244px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 0.95rem; color: var(--text);
  padding: 4px 6px; margin-bottom: 14px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.8rem;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section {
  font-size: 0.65rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.07em;
  color: #9a9ea8; padding: 14px 10px 4px;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--muted); font-weight: 500; font-size: 0.875rem;
}
.sidebar nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar nav a:hover { background: #f5f5f7; color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); }

.side-user {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 12px 6px 2px; border-top: 1px solid var(--border);
}
.side-user .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #eceef1; color: var(--muted);
  display: grid; place-items: center; font-weight: 600; font-size: 0.8rem; flex-shrink: 0;
}
.side-user .avatar:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.side-user-info { display: flex; flex-direction: column; line-height: 1.3; flex: 1; min-width: 0; color: var(--text); }
.side-user-info:hover { text-decoration: none; }
.side-user-info:hover strong { color: var(--accent); }
table.narrow { max-width: 420px; }
table.narrow th { width: 30%; background: #fcfcfd; }
.side-user-info strong { font-size: 0.8rem; font-weight: 600; }
.side-user-info small { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.side-user button.link { padding: 4px; color: var(--muted); }
.side-user button.link svg { width: 17px; height: 17px; display: block; }

.content { flex: 1; min-width: 0; padding: 30px 40px 64px; max-width: 1140px; }

/* ── Bits ───────────────────────────────────────── */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

.flash { padding: 0.6rem 0.9rem; border-radius: 10px; margin-bottom: 1rem; font-size: 0.85rem; border: 1px solid transparent; }
.flash-success { background: #f0fdf4; border-color: #bbf7d0; color: var(--ok); }
.flash-error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }

button, .btn {
  font: inherit; font-size: 0.82rem; font-weight: 550; cursor: pointer;
  background: var(--text); color: #fff; border: 1px solid var(--text);
  padding: 0.5rem 0.85rem; border-radius: 8px; line-height: 1.2;
}
button:hover, .btn:hover { background: #000; text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #f5f5f7; }
button.link, .link {
  background: none; border: 0; color: var(--accent); padding: 0.2rem 0.35rem; font-weight: 500;
}
button.link:hover, .link:hover { background: none; text-decoration: underline; }
button.link.danger, .link.danger { color: var(--danger); }

.filters { display: flex; gap: 0.55rem; align-items: center; margin-bottom: 1.1rem; flex-wrap: wrap; }
.filters .clear { color: var(--muted); font-size: 0.85rem; }
label.inline { display: inline-flex; flex-direction: row; align-items: center; gap: 0.4rem; font-weight: 500; }

/* forms */
form.stack { display: flex; flex-direction: column; gap: 0.9rem; max-width: 540px; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 550; font-size: 0.8rem; }
.row { display: flex; gap: 0.9rem; }
.row label { flex: 1; }
.grow { flex: 1; }
input, select, textarea {
  font: inherit; font-size: 0.87rem; padding: 0.5rem 0.6rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input[disabled] { background: #f6f6f7; color: var(--muted); }
small.err { color: var(--danger); font-weight: 500; font-size: 0.75rem; }
small.muted { font-weight: 400; }

/* ── Tables ─────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  font-size: 0.845rem; overflow: hidden;
}
th, td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
th {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); font-weight: 600; background: #fcfcfd;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafb; }
tfoot td { background: #fcfcfd; font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; }
td.actions { white-space: nowrap; }
td.actions form { display: inline; }
td.actions > * { vertical-align: middle; }
.inline-form { display: inline-flex; }
.inline-form select { padding: 0.28rem 0.4rem; font-size: 0.8rem; width: auto; }

table.sheet { min-width: 940px; }
table.sheet td.photo { width: 60px; }
table.sheet td.photo img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; display: block; }
table.sheet .noimg { color: var(--muted); }

/* ── Badges ─────────────────────────────────────── */
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.02em; }
.badge-high, .badge-pending, .badge-processing, .badge-draft { background: #fef3c7; color: #92400e; }
.badge-med, .badge-submitted, .badge-shipped, .badge-ordered { background: #e0e7ff; color: #3730a3; }
.badge-low, .badge-received, .badge-delivered { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #f1f1f3; color: #6b7280; }
.badge-out { background: #fee2e2; color: #991b1b; }

/* ── Cards / dashboard ──────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 0.85rem; margin: 1rem 0 1.75rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem 1rem; }
.card .n { display: block; font-size: 1.4rem; font-weight: 680; letter-spacing: -0.02em; line-height: 1.25; }
.card label, .card > span + span { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 500; margin-top: 0.15rem; }
.card small { display: block; color: var(--muted); font-weight: 500; font-size: 0.72rem; margin-top: 0.1rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.75rem; }
section > h2:first-child { margin-top: 0; }

/* getting-started guide */
.guide { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.4rem 1.5rem; margin: 0.5rem 0 1.75rem; }
.guide h2 { margin: 0 0 0.15rem; }
.guide > p { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.5rem; }
.steps { margin-top: 0.75rem; }
.step { display: flex; gap: 0.9rem; padding: 0.85rem 0; border-top: 1px solid var(--border-subtle); }
.step:first-child { border-top: 0; padding-top: 0; }
.step-num {
  width: 25px; height: 25px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--accent); color: var(--accent);
  display: grid; place-items: center; font-weight: 650; font-size: 0.78rem;
}
.step-body h3 { margin-bottom: 0.1rem; }
.step-body p { margin: 0; color: var(--muted); font-size: 0.83rem; }
.step-body a { font-size: 0.82rem; font-weight: 500; }

.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1.1rem; color: var(--muted); font-size: 0.83rem; }
.spaced { margin-top: 0.85rem; }
.w-xs { width: 4.5rem; }
.w-sm { width: 6.5rem; }

.plan-meta { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.2rem; margin-bottom: 1.1rem; }
.inline-row { display: flex; gap: 0.9rem; align-items: flex-end; flex-wrap: wrap; }
.inline-row.wrap { flex-wrap: wrap; }
.plan-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.9rem; flex-wrap: wrap; }
.add-item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.2rem; margin-top: 1.1rem; }
.add-item h2 { margin-top: 0; }

/* ── Auth ───────────────────────────────────────── */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 356px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2rem; box-shadow: var(--shadow); }
.auth-card .brand-mark { width: 34px; height: 34px; font-size: 1rem; margin-bottom: 0.75rem; }
.auth-card h1 { margin-bottom: 0; }
.auth-card > .muted { margin-top: 0.1rem; }
.auth-card form { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 1.25rem; }
.auth-card button { width: 100%; padding: 0.6rem; font-size: 0.9rem; }

.empty { text-align: center; padding: 4rem 1rem; }
.empty h1 { font-size: 3rem; color: var(--muted); font-weight: 700; }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: auto; height: auto; position: static;
    flex-direction: row; align-items: center; gap: 4px;
    padding: 10px 12px; overflow-x: auto;
  }
  .brand { margin-bottom: 0; margin-right: 6px; white-space: nowrap; }
  .sidebar nav { flex-direction: row; gap: 2px; align-items: center; }
  .sidebar nav a span { display: none; }
  .sidebar nav a { padding: 8px; }
  /* Section headings collapse to a thin divider on the horizontal bar. */
  .nav-section {
    padding: 0; margin: 0 4px; width: 1px; height: 20px;
    background: var(--border); overflow: hidden; text-indent: -999px;
  }
  .side-user { margin: 0 0 0 auto; padding: 0; border: 0; }
  .side-user-info { display: none; }
  .content { padding: 22px 18px 48px; }
  .grid-2 { grid-template-columns: 1fr; gap: 1.25rem; }
  .row { flex-direction: column; }
}
