/* ==========================================================================
   CRM Dashboard Clone — design tokens + components
   No build step, no framework. Plain CSS.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-subtle: #f9fafb;
  --card: #ffffff;
  --fg: #111827;
  --fg-muted: #6b7280;
  --fg-faint: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --primary: #111827;
  --primary-fg: #ffffff;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --ring: rgba(37, 99, 235, 0.35);
  --grid-line: #80808012;

  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --violet: #6d28d9;
  --violet-soft: #ede9fe;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, 0.18);

  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;

  --sidebar-w: 256px;
  --topbar-h: 60px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  /* categorical chart palette */
  --c1: #2563eb;
  --c2: #0d9488;
  --c3: #d97706;
  --c4: #7c3aed;
  --c5: #db2777;
  --c6: #64748b;
}

html[data-theme="dark"] {
  --bg: #0b0f19;
  --bg-subtle: #0f1524;
  --card: #141b2b;
  --fg: #e8ecf4;
  --fg-muted: #9aa5b8;
  --fg-faint: #6b7688;
  --border: #232c40;
  --border-strong: #2f3a52;
  --primary: #e8ecf4;
  --primary-fg: #0b0f19;
  --accent: #60a5fa;
  --accent-soft: #16233c;
  --ring: rgba(96, 165, 250, 0.4);
  --grid-line: #ffffff0a;

  --ok: #4ade80;
  --ok-soft: #14301f;
  --warn: #fbbf24;
  --warn-soft: #33260a;
  --danger: #f87171;
  --danger-soft: #3a1717;
  --info: #93c5fd;
  --info-soft: #16233c;
  --violet: #c4b5fd;
  --violet-soft: #241a3d;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.6);

  --c1: #60a5fa;
  --c2: #2dd4bf;
  --c3: #fbbf24;
  --c4: #a78bfa;
  --c5: #f472b6;
  --c6: #94a3b8;
}

/* ---------- reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
  padding: 0;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img,
svg {
  display: block;
  max-width: 100%;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  background: none;
  border: none;
  cursor: pointer;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: 700;
}
table {
  border-collapse: collapse;
  width: 100%;
}
[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- shared bits ---------- */
.grid-bg {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.brand__tile {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-sm);
}
.brand--sm .brand__tile {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 12px;
}
.brand__tile:nth-child(1) { background: #e11d48; }
.brand__tile:nth-child(2) { background: #f59e0b; }
.brand__tile:nth-child(3) { background: #10b981; }
.brand__tile:nth-child(4) { background: #3b82f6; }
.brand__tile:nth-child(5) { background: #8b5cf6; }
.brand__tile:nth-child(6) { background: #ec4899; }

.muted {
  color: var(--fg-muted);
}
.faint {
  color: var(--fg-faint);
}
.mono {
  font-family: var(--font-mono);
}
.nowrap {
  white-space: nowrap;
}
.num {
  font-variant-numeric: tabular-nums;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    opacity 0.15s ease, transform 0.05s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn:hover {
  text-decoration: none;
}
.btn--primary {
  background: var(--primary);
  color: var(--primary-fg);
}
.btn--primary:hover {
  opacity: 0.9;
}
.btn--accent {
  background: var(--accent);
  color: #fff;
}
html[data-theme="dark"] .btn--accent {
  color: #0b0f19;
}
.btn--accent:hover {
  opacity: 0.9;
}
.btn--ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--border);
}
.btn--ghost:hover {
  background: var(--bg-subtle);
}
.btn--danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}
.btn--danger:hover {
  opacity: 0.85;
}
.btn--block {
  width: 100%;
}
.btn--sm {
  padding: 5px 10px;
  font-size: 13px;
}
.btn--icon {
  padding: 7px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
}
.btn--icon:hover {
  background: var(--bg-subtle);
  color: var(--fg);
}
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- form fields ---------- */
.field {
  display: block;
}
.field + .field {
  margin-top: 16px;
}
.field__label {
  display: inline-block;
  margin-bottom: 6px;
  padding-left: 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}
.field__req {
  color: #ef4444;
}
.field__wrap {
  position: relative;
}
.field__icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-faint);
  pointer-events: none;
}
.field__toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-faint);
  padding: 2px;
  line-height: 0;
}
.field__toggle:hover {
  color: var(--fg);
}
.field__hint {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--fg-muted);
}
.field__error {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--danger);
}

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input--icon {
  padding-left: 38px;
}
.input--pw {
  padding-right: 38px;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--fg-faint);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--ring);
}
.input[aria-invalid="true"] {
  border-color: var(--danger);
}
.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.textarea {
  min-height: 84px;
  resize: vertical;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 6px;
  font-family: var(--font-mono);
}
.radio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.radio input,
.check input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

/* ==========================================================================
   AUTH PAGES
   ========================================================================== */
.auth {
  position: relative;
  min-height: 100vh;
  background: var(--bg);
  overflow: hidden;
}
.auth__inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.auth__pitch {
  display: none;
  flex: 1;
  padding: 48px;
}
.auth__panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 24px 16px;
}
.auth__title {
  font-size: 30px;
  font-weight: 700;
  margin: 18px 0 12px;
  max-width: 17ch;
}
.auth__lede {
  color: var(--fg-muted);
  max-width: 54ch;
}
.auth__features {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 22px;
  padding-left: 16px;
}
.auth__feature {
  display: flex;
  align-items: center;
  gap: 16px;
}
.auth__feature-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--fg);
}
.auth__feature h3 {
  font-size: 15px;
  font-weight: 600;
}
.auth__feature p {
  font-size: 14px;
  color: var(--fg-muted);
}

.auth-card {
  width: 100%;
  max-width: 28rem;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 80%, transparent);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-md);
}
.auth-card__title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}
.auth-card__sub {
  font-size: 14px;
  font-weight: 400;
  text-align: center;
  color: var(--fg-muted);
  margin-bottom: 22px;
}
.auth-card form > * + * {
  margin-top: 18px;
}
.auth-card__foot {
  margin-top: 18px;
  text-align: center;
  font-size: 14px;
}
.auth-card__foot p + p {
  margin-top: 10px;
}
.group-label {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.auth__theme {
  position: absolute;
  top: 16px;
  right: 18px;
  z-index: 2;
}
.demo-note {
  margin-top: 18px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 12.5px;
  color: var(--fg-muted);
}
.demo-note b {
  color: var(--fg);
}

@media (min-width: 900px) {
  .auth__inner {
    flex-direction: row;
    justify-content: space-between;
  }
  .auth__pitch {
    display: block;
  }
  .auth__panel {
    padding: 48px;
  }
}

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app {
  display: flex;
  min-height: 100vh;
  background: var(--bg-subtle);
}

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed;
  z-index: 60;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.22s ease;
}
.sidebar.is-open {
  transform: translateX(0);
}
.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: var(--topbar-h);
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 20px;
}
.sidebar__section {
  margin: 16px 0 6px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.sidebar__section:first-child {
  margin-top: 4px;
}
.navlink {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-size: 14px;
  font-weight: 500;
}
.navlink:hover {
  background: var(--bg-subtle);
  color: var(--fg);
  text-decoration: none;
}
.navlink + .navlink {
  margin-top: 2px;
}
.navlink.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.navlink svg {
  flex: none;
}
.navlink__badge {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sidebar__foot {
  flex: none;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.plan-card {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}
.plan-card h4 {
  font-size: 13px;
}
.plan-card p {
  margin: 3px 0 9px;
  font-size: 12px;
  color: var(--fg-muted);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(1px);
}

/* ---------- main column ---------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 14px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar__search {
  position: relative;
  flex: 1;
  max-width: 420px;
}
.topbar__search .input {
  background: var(--bg-subtle);
  box-shadow: none;
}
.topbar__spacer {
  flex: 1;
}
.kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--card);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-faint);
}
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
}
html[data-theme="dark"] .avatar {
  color: #0b0f19;
}
.avatar--lg {
  width: 40px;
  height: 40px;
  font-size: 15px;
}
.userbtn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 4px 4px;
  border-radius: 999px;
}
.userbtn:hover {
  background: var(--bg-subtle);
}
.userbtn__meta {
  display: none;
  text-align: left;
  line-height: 1.25;
}
.userbtn__meta strong {
  display: block;
  font-size: 13px;
}
.userbtn__meta span {
  font-size: 11.5px;
  color: var(--fg-muted);
}
@media (min-width: 640px) {
  .userbtn__meta {
    display: block;
  }
}

.dropdown {
  position: relative;
}
.dropdown__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 50;
  min-width: 210px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--fg);
  text-align: left;
}
.dropdown__item:hover {
  background: var(--bg-subtle);
  text-decoration: none;
}
.dropdown__sep {
  height: 1px;
  margin: 6px 0;
  background: var(--border);
}
.dropdown__head {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.dropdown__head strong {
  display: block;
  font-size: 13.5px;
}
.dropdown__head span {
  font-size: 12px;
  color: var(--fg-muted);
}

.bell {
  position: relative;
}
.bell__dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #ef4444;
  border: 2px solid var(--card);
}

/* ---------- page content ---------- */
.content {
  flex: 1;
  padding: 22px 16px 48px;
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.page-head h1 {
  font-size: 22px;
  letter-spacing: -0.015em;
}
.page-head p {
  margin-top: 3px;
  font-size: 14px;
  color: var(--fg-muted);
}
.page-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card__head h2 {
  font-size: 15px;
  font-weight: 600;
}
.card__head p {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--fg-muted);
}
.card__body {
  padding: 16px;
}
.card__foot {
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 16px;
}
.grid--kpi {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.grid--2 {
  grid-template-columns: 1fr;
}
.grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
@media (min-width: 1000px) {
  .grid--2 {
    grid-template-columns: 1.6fr 1fr;
  }
  .grid--2.grid--even {
    grid-template-columns: 1fr 1fr;
  }
}
.stack {
  display: grid;
  gap: 16px;
}

/* ---------- KPI ---------- */
.kpi {
  padding: 16px;
}
.kpi__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.kpi__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
}
.kpi__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  flex: none;
}
.kpi__value {
  margin-top: 10px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi__delta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  font-size: 12.5px;
  font-weight: 600;
}
.kpi__delta--up {
  color: var(--ok);
}
.kpi__delta--down {
  color: var(--danger);
}
.kpi__delta span {
  color: var(--fg-muted);
  font-weight: 400;
}

/* ---------- badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--violet { background: var(--violet-soft); color: var(--violet); }
.badge--neutral { background: var(--bg-subtle); color: var(--fg-muted); }
.dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  flex: none;
}

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
}
.table {
  font-size: 14px;
  min-width: 640px;
}
.table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table tbody tr:hover td {
  background: var(--bg-subtle);
}
.table .t-right {
  text-align: right;
}
.table .t-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cell-main {
  font-weight: 600;
}
.cell-sub {
  font-size: 12.5px;
  color: var(--fg-muted);
}
.cell-person {
  display: flex;
  align-items: center;
  gap: 10px;
}
.linkish {
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.linkish:hover {
  text-decoration: underline;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.toolbar .field__wrap {
  flex: 1;
  min-width: 190px;
}
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.pagination__pages {
  display: flex;
  gap: 4px;
}
.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-muted);
}
.page-btn:hover:not([disabled]) {
  background: var(--bg-subtle);
  color: var(--fg);
}
.page-btn.is-active {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}
.page-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.empty {
  padding: 46px 20px;
  text-align: center;
}
.empty svg {
  margin: 0 auto 12px;
  color: var(--fg-faint);
}
.empty h3 {
  font-size: 15px;
  margin-bottom: 4px;
}
.empty p {
  font-size: 13.5px;
  color: var(--fg-muted);
}

/* ---------- lists ---------- */
.list {
  display: flex;
  flex-direction: column;
}
.list__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.list__item:last-child {
  border-bottom: none;
}
.list__item:hover {
  background: var(--bg-subtle);
}
.list__body {
  min-width: 0;
  flex: 1;
}
.list__body strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}
.list__body span {
  font-size: 12.5px;
  color: var(--fg-muted);
}
.icon-tile {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
}

.meter {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.meter__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

/* ---------- timeline ---------- */
.timeline {
  position: relative;
  padding-left: 26px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}
.timeline__item {
  position: relative;
  padding-bottom: 18px;
}
.timeline__item:last-child {
  padding-bottom: 0;
}
.timeline__item::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--card);
  border: 2px solid var(--accent);
}
.timeline__item p {
  font-size: 14px;
}
.timeline__item time {
  font-size: 12px;
  color: var(--fg-faint);
}

/* ---------- charts ---------- */
.chart {
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart text {
  font-family: var(--font);
  font-size: 11px;
  fill: var(--fg-muted);
}
.chart .axis-line {
  stroke: var(--border);
  stroke-width: 1;
}
.chart .grid-line {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}
.chart .bar {
  transition: opacity 0.15s ease;
}
.chart .bar:hover {
  opacity: 0.78;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--fg-muted);
}
.legend__key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.donut-center {
  font-size: 20px;
  font-weight: 700;
  fill: var(--fg);
}
.donut-sub {
  font-size: 11px;
  fill: var(--fg-muted);
}

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  overflow-y: auto;
}
.modal__box {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop 0.16s ease-out;
}
.modal__box--wide {
  max-width: 720px;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.modal__head h2 {
  font-size: 16px;
}
.modal__head p {
  margin-top: 2px;
  font-size: 13px;
  color: var(--fg-muted);
}
.modal__body {
  padding: 16px;
  max-height: 65vh;
  overflow-y: auto;
}
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}
@media (min-width: 560px) {
  .form-grid--2 {
    grid-template-columns: 1fr 1fr;
  }
  .form-grid .span-2 {
    grid-column: span 2;
  }
}
.form-grid .field + .field {
  margin-top: 0;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.detail-row:last-child {
  border-bottom: none;
}
.detail-row dt {
  color: var(--fg-muted);
}
.detail-row dd {
  font-weight: 600;
  text-align: right;
}

/* ---------- toast ---------- */
.toasts {
  position: fixed;
  z-index: 99;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 360px;
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: slide-in 0.2s ease-out;
}
.toast--ok { border-left: 3px solid var(--ok); }
.toast--err { border-left: 3px solid var(--danger); }
.toast--info { border-left: 3px solid var(--accent); }
@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}

/* ---------- print-ish preview (labels/invoices) ---------- */
.paper {
  background: #fff;
  color: #111827;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.paper h3 {
  font-size: 17px;
}
.paper .table {
  min-width: 0;
}
.paper .table th {
  background: #f9fafb;
  color: #6b7280;
  border-color: #e5e7eb;
}
.paper .table td {
  border-color: #e5e7eb;
}
.paper .table tbody tr:hover td {
  background: transparent;
}
.label-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
}
.label-tag {
  border: 1px dashed #9ca3af;
  border-radius: 6px;
  padding: 9px;
  background: #fff;
  color: #111827;
  font-size: 11px;
  line-height: 1.35;
}
.label-tag strong {
  font-size: 12.5px;
}
.barcode {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 30px;
  margin: 6px 0 4px;
}
.barcode i {
  display: block;
  background: #111827;
  height: 100%;
}

/* ---------- settings tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover {
  color: var(--fg);
}
.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex: none;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.18s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  transition: transform 0.18s ease;
}
.switch.is-on {
  background: var(--accent);
}
.switch.is-on::after {
  transform: translateX(18px);
}

/* ---------- responsive shell ---------- */
@media (min-width: 1024px) {
  .sidebar {
    position: sticky;
    height: 100vh;
    transform: none;
    flex: none;
  }
  .sidebar__close,
  .topbar__burger {
    display: none;
  }
  .scrim {
    display: none;
  }
  .content {
    padding: 24px 24px 56px;
  }
  .topbar {
    padding: 0 24px;
  }
}

@media print {
  .sidebar,
  .topbar,
  .page-head__actions,
  .toasts {
    display: none !important;
  }
  .app,
  .content {
    background: #fff;
    padding: 0;
  }
  .card {
    border: none;
    box-shadow: none;
  }
}
