/* Lilam admin — one stylesheet. Tokens first; every colour is a token.
   Shared design with the SevenLavan admin; brand = Lilam black. */

:root {
  --brand: #111111;
  --brand-strong: #000000;
  --brand-soft: #ececee;
  --on-brand: #ffffff;
  --logo: #000000;            /* Lilam wordmark: black on light */
  --accent: #c8a46b;

  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --text: #16202a;
  --text-2: #4b5966;
  --muted: #7b8894;
  --line: #e2e7ec;
  --input-bg: #ffffff;

  --success: #14804a;  --success-soft: #e3f5ea;
  --danger: #c93a3a;   --danger-soft: #fbe9e9;
  --warning: #9a6200;  --warning-soft: #fff4dc;
  --info: #1f6fb2;     --info-soft: #e5f1fb;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 1px 3px rgba(16, 24, 32, .05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 32, .16);
  --sidebar-w: 248px;
  --gutter: 24px;
  color-scheme: light;
}

/* Dark theme. The top-bar switch sets <html data-theme="light|dark"> (saved per
   browser); with no choice saved, the panel follows the system setting. */
:root[data-theme="dark"] {
  --brand: #f2f2f2;
  --brand-strong: #ffffff;
  --brand-soft: #2a2d31;
  --on-brand: #111111;
  --logo: #ffffff;          /* … white on dark */
  --bg: #0f1418;
  --surface: #171e24;
  --surface-2: #1c242b;
  --text: #e8edf1;
  --text-2: #b3bec8;
  --muted: #84919c;
  --line: #2a343d;
  --input-bg: #11171c;
  --success: #4cc38a;  --success-soft: #16301f;
  --danger: #f07171;   --danger-soft: #3a1c1c;
  --warning: #f0b44a;  --warning-soft: #3a2c12;
  --info: #6cb4f0;     --info-soft: #16293a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #f2f2f2;
    --brand-strong: #ffffff;
    --brand-soft: #2a2d31;
    --on-brand: #111111;
    --logo: #ffffff;          /* … white on dark */
    --bg: #0f1418;
    --surface: #171e24;
    --surface-2: #1c242b;
    --text: #e8edf1;
    --text-2: #b3bec8;
    --muted: #84919c;
    --line: #2a343d;
    --input-bg: #11171c;
    --success: #4cc38a;  --success-soft: #16301f;
    --danger: #f07171;   --danger-soft: #3a1c1c;
    --warning: #f0b44a;  --warning-soft: #3a2c12;
    --info: #6cb4f0;     --info-soft: #16293a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
img { max-width: 100%; }
.icon { flex: none; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 16px; }

/* ---------- App shell ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-center { justify-content: center; padding-bottom: 8px; }
/* The wordmark is a mask, so it takes the --logo colour of the active theme. */
.brand-logo {
  display: block; width: 54px; aspect-ratio: 1000 / 518; flex: none;
  background: var(--logo);
  -webkit-mask: url("../img/logo.png") center / contain no-repeat;
          mask: url("../img/logo.png") center / contain no-repeat;
}
.brand-tag {
  padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.brand-center { flex-direction: column; gap: 8px; }
.brand-center .brand-logo { width: 100px; }
.nav { flex: 1; overflow-y: auto; }
.nav-section { margin: 14px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
/* Count bubble: new orders / businesses / payouts since this admin last opened the page. */
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
}
.nav-badge[hidden] { display: none; }
.stat-icon { position: relative; }
.stat-badge { position: absolute; top: -7px; right: -9px; margin: 0; box-shadow: 0 0 0 2px var(--surface); }
.nav-toggle { position: relative; }
.nav-toggle-dot {
  position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 2px var(--surface);
}
.nav-toggle-dot[hidden] { display: none; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 12px; }
.sidebar-foot .btn { width: 100%; justify-content: flex-start; }
.sidebar-overlay { display: none; }

.shell { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 60px;
  display: flex; align-items: center; gap: 12px; padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .nav-toggle { display: none; }
/* Light / dark switch: shows the moon in light mode, the sun in dark mode. */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px;
  background: none; border: 1px solid transparent; border-radius: 999px; color: inherit; cursor: pointer; font: inherit;
}
.user-chip:hover { border-color: var(--line); }
.user-chip-text { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.user-chip-text small { color: var(--muted); font-size: 11.5px; }
.avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand); font-weight: 700;
}

.main { flex: 1; padding: 24px var(--gutter) 48px; width: 100%; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.page-subtitle { color: var(--muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.flashes:empty { display: none; }
.flashes { display: grid; gap: 8px; margin-bottom: 16px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-title { font-size: 15px; font-weight: 650; }
.card-subtitle { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

/* list + form on one screen */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.split-form { position: sticky; top: 76px; }
.split-form .card-body { max-height: calc(100vh - 170px); overflow-y: auto; }
.card-header .collapse-toggle { display: none; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.form-section { margin: 18px 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.form-section:first-child { margin-top: 0; }

/* ---------- Form controls ---------- */
.field { margin-bottom: 14px; min-width: 0; }
.field-label { display: block; margin-bottom: 6px; font-weight: 550; font-size: 13px; color: var(--text-2); }
.req { color: var(--danger); }
.field-help { margin-top: 5px; font-size: 12px; color: var(--muted); }
.field-error { margin-top: 5px; font-size: 12px; color: var(--danger); font-weight: 500; }
.input {
  display: block; width: 100%; min-height: 40px; padding: 8px 12px;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted); }
.input:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--muted)); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.input[readonly], .input:disabled { background: var(--surface-2); color: var(--muted); }
/* products.php: the computed profit per unit — readable, red when selling below cost. */
.input[data-profit-out] { color: var(--success); font-weight: 600; }
.input[data-profit-out].is-loss { color: var(--danger); }
textarea.input { resize: vertical; min-height: 80px; }
.has-error .input { border-color: var(--danger); }
.select-wrap { position: relative; }
.select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select-search { margin-bottom: 6px; min-height: 34px; padding: 6px 10px; font-size: 13px; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 34px; }
.input-password { position: relative; }
.input-password .input { padding-right: 42px; }
.input-password-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 34px; height: 32px;
  background: none; border: 0; border-radius: 6px; color: var(--muted); cursor: pointer;
}
.input-password-toggle:hover, .input-password-toggle[aria-pressed="true"] { color: var(--brand); }

.choice { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.choice input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio-group.inline { flex-direction: row; flex-wrap: wrap; gap: 8px 18px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--line); transition: background .15s; flex: none; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brand); outline-offset: 2px; }

.image-upload-drop {
  display: grid; place-items: center; width: 100%; max-width: 280px; aspect-ratio: var(--ratio, 1 / 1);
  border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface-2);
  overflow: hidden; cursor: pointer; transition: border-color .15s;
}
.image-upload-drop:hover { border-color: var(--brand); }
.image-upload-drop img { width: 100%; height: 100%; object-fit: contain; }
.image-upload-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); text-align: center; padding: 12px; }
.image-upload-empty span { font-weight: 600; color: var(--text-2); }
.image-upload-empty small { font-size: 11.5px; }
.image-upload-path { margin: 6px 0; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.image-upload .field { margin: 4px 0 0; }

.image-upload-drop.multi { max-width: none; aspect-ratio: auto; min-height: 96px; }

/* checkbox list (ui_checkbox_group) */
.check-grid { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 8px 16px;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }

/* repeatable blocks (ui_repeater) */
.repeater-rows { display: grid; gap: 12px; margin-bottom: 12px; }
.repeater-rows:not(:empty) + .repeater-empty { display: none; }
.repeater-empty { margin-bottom: 12px; }
.repeater-row { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 2px; background: var(--surface-2); }
.repeater-row:has(.repeater-remove input:checked) { opacity: .55; border-style: dashed; }
.repeater-row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; min-height: 32px; }
.repeater-row-title { font-weight: 650; font-size: 13px; color: var(--text-2); }
.repeater-remove { font-size: 12.5px; color: var(--danger); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
.repeater-row .image-upload-drop { max-width: 120px; }
.repeater-row .image-upload-path { max-width: 120px; }

/* full-width edit page: main column + side column */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.form-layout > div { display: grid; gap: 20px; min-width: 0; }
.form-sticky-actions { position: sticky; bottom: 0; z-index: 20; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  margin-top: 20px; padding: 12px 16px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); }

/* saved photos of a product */
.photo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-bottom: 12px; }
.photo-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; background: var(--surface-2); }
.photo-item img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; border-radius: 6px; background: #fff; }
.photo-item .choice { font-size: 12px; margin-top: 4px; }
.photo-item:has(input[name^="photo_remove"]:checked) img { opacity: .35; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer;
  white-space: nowrap; text-decoration: none !important; transition: background .15s, border-color .15s, color .15s;
}
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 36px; min-height: 36px; }
.btn-sm.btn-icon { width: 32px; min-height: 32px; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.inline-form { display: inline; margin: 0; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 200px;
  display: none; padding: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.dropdown.align-left .dropdown-menu { left: 0; right: auto; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown.drop-up .dropdown-menu { top: auto; bottom: calc(100% + 6px); }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px;
  background: none; border: 0; border-radius: 6px; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item.danger { color: var(--danger); }
.dropdown-menu .inline-form { display: block; }

/* ---------- Badges, alerts, empty ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }

.alert { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 500; }
.alert > span { flex: 1; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-close { background: none; border: 0; color: inherit; cursor: pointer; padding: 2px; opacity: .7; }
.alert-close:hover { opacity: 1; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 16px; color: var(--muted); text-align: center; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filter-bar .field { margin: 0; flex: 1 1 160px; min-width: 140px; }
.filter-bar .field.grow { flex: 2 1 220px; }
.filter-bar .field-label { font-size: 12px; margin-bottom: 4px; }
.filter-bar .input { min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
.filter-actions { display: flex; gap: 6px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 10px 14px; text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.is-selected { background: var(--brand-soft); }
.table tr.is-inactive td { opacity: .72; }
.table .actions { text-align: right; width: 1%; white-space: nowrap; }
/* sortable column headers (ui_table 'sort') */
.th-sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
.th-sort:hover { color: var(--text); text-decoration: none; }
.th-sort .sort-arrows { display: inline-flex; flex-direction: column; line-height: 0; opacity: .35; }
.th-sort .sort-arrows svg { display: block; }
.th-sort.is-sorted { color: var(--text); }
.th-sort.is-sorted .sort-arrows { opacity: 1; }
.th-sort.is-sorted.asc .sort-down, .th-sort.is-sorted.desc .sort-up { opacity: .25; }
/* phones: sort picker above the cards (headers are hidden there) */
.sort-bar { display: none; }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12.5px; }
.cell-flex { display: flex; align-items: center; gap: 12px; min-width: 0; }
.thumb { width: 42px; height: 42px; flex: none; border-radius: 8px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); }
.thumb-lg { width: 110px; height: 110px; border-radius: 10px; }   /* a quick order's list photos (orders.php) */
.thumb.wide { width: 84px; height: 42px; }
.thumb-empty { display: grid; place-items: center; color: var(--muted); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.pagination-info { color: var(--muted); font-size: 13px; }
.pagination-info b { color: var(--text); font-weight: 600; }
.pagination-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.page {
  display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text-2); background: var(--surface); font-weight: 500;
}
a.page:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.page.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.page.disabled { opacity: .45; }
.page.gap { border: 0; background: none; min-width: 20px; }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  display: flex; align-items: center; gap: 14px; padding: 18px; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
a.stat:hover { border-color: var(--brand); text-decoration: none; }
.stat-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); flex: none; }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-hint { color: var(--muted); font-size: 12px; }
.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Lilam module pages ---------- */
.scope-strip { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 16px;
  background: var(--brand-soft); border: 1px solid var(--line); border-radius: var(--radius); }
.scope-text { display: flex; flex-direction: column; flex: 1; min-width: 140px; line-height: 1.3; }
.scope-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.stars { color: #e0a100; letter-spacing: 1px; white-space: nowrap; }
.stars .muted { color: var(--line); }
.hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
.hub .stat { padding: 14px; }
.hub .stat-value { font-size: 20px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 26px; color: var(--muted); }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.timeline li::after { content: ""; position: absolute; left: 10px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.done { color: var(--text); }
.timeline li.done::before { background: var(--success); }
.timeline li.now::before { background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.timeline li.stop { color: var(--danger); }
.timeline li.stop::before { background: var(--danger); }
.timeline small { display: block; color: var(--muted); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.gallery a { display: block; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.gallery img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.doc-list { display: grid; gap: 8px; }
.doc-list a, .doc-list .doc-missing { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.doc-missing { color: var(--muted); }
.amount-credit { color: var(--success); font-weight: 600; white-space: nowrap; }
.amount-debit { color: var(--danger); font-weight: 600; white-space: nowrap; }
.bill { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 0; }
.bill dt { color: var(--muted); }
.bill dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.bill .total { font-weight: 700; color: var(--text); border-top: 1px solid var(--line); padding-top: 6px; }
.row-actions { display: inline-flex; gap: 4px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }

/* tabs (categories.php) */
.tabs { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; margin-bottom: 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text-2); font-weight: 550; white-space: nowrap; }
.tab:hover { text-decoration: none; border-color: var(--brand); color: var(--text); }
.tab.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.tab-count { font-size: 11.5px; opacity: .75; }

/* banner preview (banners.php) — mirrors the app's Home promo slide */
.promo { position: relative; aspect-ratio: 16 / 10; border-radius: 14px; overflow: hidden; background: #111 center / cover no-repeat; color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 16px; }
.promo::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,.65)); }
.promo > * { position: relative; }
.promo-kicker { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.promo-title { font-size: 20px; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.promo-badge { position: absolute; top: 12px; left: 12px; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.4); font-size: 11px; font-weight: 700; }
.thumb.banner-thumb { width: 112px; height: 70px; }

/* ---------- Activity log diff ---------- */
.diff-table td { vertical-align: top; }
.diff-from { color: var(--danger); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 45%, transparent); overflow-wrap: anywhere; }
.diff-to { color: var(--success); overflow-wrap: anywhere; }
.secret-status { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

/* ---------- Dialog ---------- */
.dialog {
  width: min(420px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(10, 16, 22, .5); }
.dialog form { padding: 22px; }
.dialog-title { font-size: 17px; font-weight: 700; }
.dialog-body { margin-top: 8px; color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- Auth pages ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--brand-soft), transparent 60%), var(--bg); }
.auth-card { width: min(400px, 100%); padding: 32px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); }
.auth-theme { position: fixed; top: 12px; right: 12px; }
.auth-title { font-size: 20px; font-weight: 700; text-align: center; margin-top: 4px; }
.auth-subtitle { text-align: center; color: var(--muted); margin: 4px 0 20px; }
.auth-card .flashes { margin-top: 12px; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split-form { position: static; order: -1; }
  .split-form .card-body { max-height: none; }
  .split-form.collapsed .card-body { display: none; }
  .split-form.collapsed .card-header { border-bottom: 0; }
  .card-header .collapse-toggle { display: inline-flex; }
  .split-form:not(.collapsed) .collapse-toggle .icon { transform: rotate(45deg); }
  .form-layout { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  :root { --gutter: 16px; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(10, 16, 22, .45); }
  body.nav-open { overflow: hidden; }
  .shell { margin-left: 0; }
  .topbar .nav-toggle { display: inline-flex; }
  .main { padding-top: 18px; }
  .page-title { font-size: 19px; }
}

@media (max-width: 640px) {
  .user-chip-text { display: none; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .check-grid { grid-template-columns: minmax(0, 1fr); }
  .card-header, .card-body { padding-left: 16px; padding-right: 16px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }

  /* table rows become cards */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 16px; border-bottom: 1px solid var(--line); position: relative; }
  .table td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; }
  .table td.cell-primary { display: block; text-align: left; padding: 0 44px 6px 0; }
  .table td.cell-primary::before { display: none; }
  .table td.actions { position: absolute; top: 10px; right: 10px; width: auto; padding: 0; }
  .table td.actions::before { display: none; }
  .filter-bar .field { flex-basis: 100%; }
  .sort-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
  .sort-bar a { color: var(--text-2); }
  .sort-bar a.is-sorted { color: var(--text); font-weight: 600; }
  .filter-actions { width: 100%; }
  .filter-actions .btn { flex: 1; }
}
