@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&family=Tajawal:wght@400;500;700&display=swap');

/* =========================================================================
   Design tokens
   Field-service software for electrical/security-systems maintenance —
   technicians reading this outdoors on a phone as often as office staff
   at a desk. Two themes, both calm and technical rather than a bright
   consumer look: three tonal surface layers instead of one flat panel
   color, a restrained teal accent, and shadows tinted toward the
   background instead of a neutral grey card-kit look.

   Theme resolution (see the inline script in index.html's <head>):
   - No stored preference → follows the OS/browser's prefers-color-scheme,
     and keeps following it live if the OS setting changes.
   - Manually toggled once (moon/sun control in the sidebar / mobile top
     bar) → pinned to that choice via data-theme="dark"|"light" on <html>,
     stored in localStorage, and no longer follows the OS.
   Dark is the fallback if the browser supports neither, since it's
   easier on the eyes/battery for outdoor field use.
   ========================================================================= */
:root, :root[data-theme="dark"] {
  /* Surfaces — layered, not flat: bg < panel < panel-alt < panel-2, each a
     step up in elevation. panel-2 is for things that float above panels
     (dropdowns, the date picker) — panel and panel-2 read as distinct
     without a border. */
  --bg: #0b121c;
  --panel: #131e2c;
  --panel-alt: #1a2636;
  --panel-2: #1c2c3f;
  --border: #263750;
  --border-strong: #34495f;

  /* Brand accent — teal reads as "circuitry / verified system", fitting
     for electrical and security-systems maintenance without leaning on
     an alarm-style red or a generic SaaS blue. */
  --accent: #3fb0a6;
  --accent-hover: #4dc0b5;
  --accent-soft: rgba(63,176,166,0.14);
  --accent-ink: #062420;
  --accent-border: rgba(63,176,166,0.3);

  /* Status */
  --amber: #dda44a;
  --amber-soft: rgba(221,164,74,0.14);
  --danger: #d1715f;
  --danger-soft: rgba(209,113,95,0.14);
  --danger-ink: #200a06;
  --danger-border: rgba(209,113,95,0.4);

  /* Text */
  --text: #eaeff5;
  --text-muted: #8fa0b6;
  --text-dim: #5f7189;

  /* Elevation — tinted toward the background color, not neutral grey */
  --shadow-sm: 0 1px 2px rgba(3,7,13,0.5);
  --shadow-md: 0 10px 28px rgba(3,7,13,0.45), 0 2px 6px rgba(3,7,13,0.35);
  --shadow-lg: 0 20px 56px rgba(3,7,13,0.55), 0 4px 12px rgba(3,7,13,0.4);

  /* Fine surface texture — the background grid and the sidebar's top
     sheen. Faint white on this dark theme. */
  --grid-line: rgba(255,255,255,0.022);
  --panel-sheen: rgba(255,255,255,0.015);
  --scrim: rgba(4,7,12,0.7);

  /* House standard (v1.22.0): grey tier grades, and the ink used by the
     selected tab and chip. Colour stays reserved for indicators. */
  --tier-platinum: #46556c; --tier-platinum-edge: #5b6c86;
  --tier-gold: #3a4658; --tier-gold-edge: #4d5e76;
  --tier-silver: #2f3a4b; --tier-silver-edge: #424f66;
  --tier-ink: #eaeff5;
  --ink: #eaeff5; --ink-text: #0b121c;

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  /* Only takes effect with no data-theme attribute at all, i.e. no
     manual choice has ever been stored — see the resolution note above.
     A manual choice (data-theme="light" or "dark") is handled by its own
     unconditional block below and always wins regardless of this. */
  :root:not([data-theme]) {
    --bg: #f3f5f8;
    --panel: #ffffff;
    --panel-alt: #edf0f4;
    --panel-2: #ffffff;
    --border: #dbe1e8;
    --border-strong: #c1cad4;

    --accent: #1f8f84;
    --accent-hover: #197a71;
    --accent-soft: rgba(31,143,132,0.12);
    --accent-ink: #ffffff;
    --accent-border: rgba(31,143,132,0.35);

    --amber: #a8701d;
    --amber-soft: rgba(168,112,29,0.12);
    --danger: #b8503d;
    --danger-soft: rgba(184,80,61,0.12);
    --danger-ink: #ffffff;
    --danger-border: rgba(184,80,61,0.4);

    --text: #1a2431;
    --text-muted: #5b6b7f;
    --text-dim: #8896a8;

    --shadow-sm: 0 1px 2px rgba(20,30,45,0.08);
    --shadow-md: 0 10px 28px rgba(20,30,45,0.10), 0 2px 6px rgba(20,30,45,0.06);
    --shadow-lg: 0 20px 56px rgba(20,30,45,0.14), 0 4px 12px rgba(20,30,45,0.08);

    --grid-line: rgba(20,30,45,0.035);
    --panel-sheen: rgba(20,30,45,0.02);
    --scrim: rgba(15,20,28,0.55);

    --tier-platinum: #c2c8d1; --tier-platinum-edge: #a2aab6;
    --tier-gold: #d5dae1; --tier-gold-edge: #b3bac4;
    --tier-silver: #e6e9ee; --tier-silver-edge: #c6ccd4;
    --tier-ink: #22262c;
    --ink: #1a2431; --ink-text: #ffffff;

    color-scheme: light;
  }
}
:root[data-theme="light"] {
  /* Explicit override — identical values to the media-query block above,
     duplicated so a manual "light" choice applies even when the OS itself
     is set to dark. */
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-alt: #edf0f4;
  --panel-2: #ffffff;
  --border: #dbe1e8;
  --border-strong: #c1cad4;

  --accent: #1f8f84;
  --accent-hover: #197a71;
  --accent-soft: rgba(31,143,132,0.12);
  --accent-ink: #ffffff;
  --accent-border: rgba(31,143,132,0.35);

  --amber: #a8701d;
  --amber-soft: rgba(168,112,29,0.12);
  --danger: #b8503d;
  --danger-soft: rgba(184,80,61,0.12);
  --danger-ink: #ffffff;
  --danger-border: rgba(184,80,61,0.4);

  --text: #1a2431;
  --text-muted: #5b6b7f;
  --text-dim: #8896a8;

  --shadow-sm: 0 1px 2px rgba(20,30,45,0.08);
  --shadow-md: 0 10px 28px rgba(20,30,45,0.10), 0 2px 6px rgba(20,30,45,0.06);
  --shadow-lg: 0 20px 56px rgba(20,30,45,0.14), 0 4px 12px rgba(20,30,45,0.08);

  --grid-line: rgba(20,30,45,0.035);
  --panel-sheen: rgba(20,30,45,0.02);
  --scrim: rgba(15,20,28,0.55);

  --tier-platinum: #c2c8d1; --tier-platinum-edge: #a2aab6;
  --tier-gold: #d5dae1; --tier-gold-edge: #b3bac4;
  --tier-silver: #e6e9ee; --tier-silver-edge: #c6ccd4;
  --tier-ink: #22262c;
  --ink: #1a2431; --ink-text: #ffffff;

  color-scheme: light;
}
:root {
  /* Radius — a deliberate small scale, not one value reused everywhere */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 16px;

  /* Motion — one easing curve, one short duration, used only where a state
     genuinely changes (hover, focus, open/close) — never as decoration */
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --dur: 140ms;

  --focus-ring: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Theme-switch polish: surfaces/text fade instead of flashing when the
   toggle is used or the OS setting changes underneath the app. */
*, *::before, *::after {
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: 'Space Grotesk', sans-serif; margin: 0; letter-spacing: -0.012em; font-weight: 600; }
h1 { font-size: 22px; }
.mono { font-family: 'IBM Plex Mono', monospace; }
button { font-family: 'Inter', sans-serif; cursor: pointer; touch-action: manipulation; }
a, .navitem, .list-row, .alertrow, .list-row, .btn, .iconbtn, .logout-link { touch-action: manipulation; }
a { color: var(--accent); }

/* Visible keyboard focus everywhere — the one accessibility rule that
   covers the most ground for the least code. :focus-visible (not :focus)
   so a mouse click doesn't leave a ring behind, only real keyboard/AT
   navigation does. */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible, [role="button"]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--r-sm);
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
  padding: 10px 14px; border-radius: var(--r-sm); font-size: 13px;
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---------- Login ---------- */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-box {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 36px 32px; width: 360px; max-width: 100%;
  box-shadow: var(--shadow-lg);
  animation: rise-in 360ms var(--ease) both;
}
.login-brand { margin-bottom: 24px; }
.login-brand-title { font-family: 'Space Grotesk', sans-serif; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.login-brand-sub { color: var(--text-dim); font-size: 11px; margin-top: 4px; font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.06em; }
.login-error { color: var(--danger); font-size: 12.5px; margin-top: 10px; min-height: 16px; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- App shell ---------- */
#app-screen { display: none; min-height: 100vh; }
#app-screen.visible { display: flex; animation: app-reveal 300ms var(--ease) both; }
/* One deliberate entrance moment — the app appearing after login — not a
   transition repeated on every navigation click afterward, which would
   slow down a tool people open dozens of times a day. */
@keyframes app-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}

.mobile-topbar { display: none; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 480px; }

.sidebar {
  width: 216px; flex-shrink: 0; border-right: 1px solid var(--border);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 22px;
}
.brand { padding: 0 8px; }
.brand-title { font-family: 'Space Grotesk', sans-serif; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { color: var(--text-dim); font-size: 11px; margin-top: 3px; font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.06em; }
.navlist { display: flex; flex-direction: column; gap: 2px; }
.navitem {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm);
  cursor: pointer; color: var(--text-muted); border: 1px solid transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.navitem:hover { background: var(--panel-alt); color: var(--text); }
.navitem.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border); font-weight: 500; }
.navitem svg { flex-shrink: 0; }
.nav-alert-dot {
  margin-left: auto; background: var(--danger); color: var(--danger-ink); font-size: 10px; font-weight: 600;
  min-width: 17px; height: 17px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
}
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding-top: 14px; }
.session-user { font-size: 12.5px; font-weight: 500; }
.session-role { color: var(--text-dim); font-size: 11px; font-family: 'IBM Plex Mono', monospace; text-transform: uppercase; letter-spacing: 0.05em; }
.logout-link { color: var(--text-dim); font-size: 12px; cursor: pointer; margin-top: 8px; margin-right: 12px; display: inline-block; transition: color var(--dur) var(--ease); }
.logout-link:hover { color: var(--text); }
.theme-toggle {
  background: transparent; border: none; padding: 0; margin-top: 10px; cursor: pointer;
  display: flex; align-items: center; gap: 7px; color: var(--text-dim); font-size: 12px;
  font-family: inherit; transition: color var(--dur) var(--ease);
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { flex-shrink: 0; }
.theme-toggle-mobile {
  background: transparent; border: none; padding: 2px; cursor: pointer; color: var(--text-dim);
  display: flex; align-items: center; transition: color var(--dur) var(--ease);
}
.theme-toggle-mobile:hover { color: var(--text); }

.main { flex: 1; padding: 28px 34px 60px; overflow-x: hidden; max-width: 1180px; }
.topbar { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 10px; }
.topbar .date { color: var(--text-dim); font-family: 'IBM Plex Mono', monospace; font-size: 12px; }

.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-label { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 30px; font-weight: 600; margin-top: 6px; letter-spacing: -0.015em; }
.stat.warn .stat-value { color: var(--amber); }
.stat.bad .stat-value { color: var(--danger); }

.section {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md); padding: 18px 20px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.section-head h2 { font-size: 13.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.alertrow {
  display: grid; grid-template-columns: 20px 1.4fr 1fr 110px 90px; gap: 12px; align-items: center;
  padding: 11px 6px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease);
}
.alertrow:last-child { border-bottom: none; }
.alertrow:hover { background: var(--panel-alt); }
.alertrow .due { color: var(--text-dim); font-family: 'IBM Plex Mono', monospace; font-size: 12px; }
.alertrow .cust { font-weight: 500; }
.sys-with-icon { color: var(--text-muted); display: flex; align-items: center; gap: 6px; }

.badge { font-family: 'IBM Plex Mono', monospace; font-size: 11px; padding: 3px 8px; border-radius: var(--r-sm); white-space: nowrap; display: inline-block; font-weight: 500; }
.badge-overdue { background: var(--danger-soft); color: var(--danger); }
.badge-due-soon { background: var(--amber-soft); color: var(--amber); }
.badge-ok { background: var(--accent-soft); color: var(--accent); }
.badge-ended { background: var(--panel-alt); color: var(--text-dim); border: 1px solid var(--border); }

.empty { color: var(--text-dim); padding: 32px 0; text-align: center; font-size: 13px; }

.btn {
  font-size: 13px; font-weight: 500; background: var(--accent); color: var(--accent-ink); border: none;
  border-radius: var(--r-sm); padding: 9px 14px; display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--dur) var(--ease), filter var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.secondary { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn.secondary:hover { color: var(--text); border-color: var(--border-strong); background: var(--panel-alt); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger-border); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; color: var(--accent); padding: 6px 8px; }
.btn.ghost:hover { background: var(--accent-soft); }
.iconbtn { background: transparent; border: none; color: var(--text-dim); padding: 4px; border-radius: var(--r-sm); transition: color var(--dur) var(--ease), background var(--dur) var(--ease); }
.iconbtn:hover { color: var(--text); background: var(--panel-alt); }

.searchbar { display: flex; align-items: center; gap: 8px; background: var(--panel-alt); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 10px; width: 220px; transition: border-color var(--dur) var(--ease); }
.searchbar:focus-within { border-color: var(--accent); }
.searchbar input { background: transparent; border: none; outline: none; color: var(--text); font-size: 13px; width: 100%; }

.list-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 6px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: var(--r-sm); transition: background var(--dur) var(--ease); }
.list-row:hover { background: var(--panel-alt); }
.list-row:last-child { border-bottom: none; }
.list-row .name { font-weight: 500; }
.list-row .meta { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--panel-alt); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 8px 10px; color: var(--text); font-family: 'Inter', sans-serif; font-size: 13px; outline: none;
  transition: border-color var(--dur) var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input:disabled, .field select:disabled { color: var(--text-dim); cursor: not-allowed; opacity: 0.75; }
.fieldrow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

table.systable { width: 100%; border-collapse: collapse; }
table.systable th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.systable td { padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
table.systable tr:last-child td { border-bottom: none; }
.sysname { display: flex; align-items: center; gap: 8px; }

.back { display: flex; align-items: center; gap: 6px; color: var(--text-muted); cursor: pointer; font-size: 13px; margin-bottom: 16px; transition: color var(--dur) var(--ease); }
.back:hover { color: var(--text); }

.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.bar-chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart .bar { width: 100%; max-width: 26px; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; transition: opacity var(--dur) var(--ease); }
.bar-chart .bar.over { background: var(--danger); }
.bar-chart .bar-label { color: var(--text-dim); font-size: 10px; margin-top: 6px; font-family: 'IBM Plex Mono', monospace; white-space: nowrap; }
.bar-chart .bar-count { color: var(--text-dim); font-size: 10px; margin-bottom: 4px; font-family: 'IBM Plex Mono', monospace; }

/* ---------- Searchable customer combo (Log a visit / Reports) ---------- */
.combo { position: relative; }
.combo-input-wrap {
  display: flex; align-items: center; gap: 8px; background: var(--panel-alt);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px;
  transition: border-color var(--dur) var(--ease);
}
.combo-input-wrap:focus-within { border-color: var(--accent); }
.combo-input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-family: 'Inter', sans-serif; font-size: 13px; }
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  max-height: 240px; overflow-y: auto; box-shadow: var(--shadow-md);
}
.combo-item { padding: 9px 12px; font-size: 13px; cursor: pointer; transition: background var(--dur) var(--ease); }
.combo-item:hover { background: var(--panel-alt); }
.combo-item.selected { color: var(--accent); }
.combo-empty { padding: 12px; color: var(--text-dim); font-size: 12.5px; }

/* ---------- Donut chart ---------- */
.donut-wrap { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.donut-svg svg { display: block; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 160px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.legend-label { color: var(--text-muted); flex: 1; }
.legend-value { color: var(--text); }

/* ---------- Horizontal bar chart (technician workload, cities) ---------- */
.hbar-chart { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 120px 1fr 34px; gap: 10px; align-items: center; }
.hbar-label { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { background: var(--panel-alt); border-radius: 2px; height: 10px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.hbar-value { font-size: 11.5px; color: var(--text-dim); text-align: right; }

/* ---------- Year-over-year comparison chart (two bars per row) ---------- */
.compare-legend { display: flex; gap: 18px; margin-bottom: 12px; }
.compare-chart { display: flex; flex-direction: column; gap: 12px; }
.compare-row { display: grid; grid-template-columns: 120px 1fr 60px; gap: 10px; align-items: center; }
.compare-label { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compare-bars { display: flex; flex-direction: column; gap: 3px; }
.compare-track { background: var(--panel-alt); border-radius: 2px; height: 7px; overflow: hidden; }
.compare-fill { height: 100%; border-radius: 2px; }
.compare-fill-current { background: var(--accent); }
.compare-fill-previous { background: var(--text-dim); }
.compare-values { font-size: 11px; color: var(--text); text-align: right; }

/* Tab bar: see the house-standard rules at the end of this file. */

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--panel-alt); }

/* ---------- Filter bar (Reports > Overview > Maintenance schedule) ---------- */
.filterbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-input {
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 8px 10px; color: var(--text); font-family: 'Inter', sans-serif; font-size: 13px;
  width: 180px; max-width: 100%; transition: border-color var(--dur) var(--ease);
}
.filter-input:focus { outline: none; border-color: var(--accent); }
/* The customer-name combo box wasn't originally built for this flex row
   (it's normally full-width inside a block-level .field) — give it the
   same width as its .filter-input siblings so it doesn't render oddly
   narrow next to them. */
.filterbar .combo { width: 180px; max-width: 100%; }
.filterbar .combo-input-wrap { padding: 7px 8px; }
.filterbar .combo-input { font-size: 13px; }
.filter-date-group { display: flex; align-items: center; gap: 6px; }
.filter-date {
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 7px 8px; color: var(--text); font-family: 'IBM Plex Mono', monospace; font-size: 12.5px;
}
.filter-date-sep { color: var(--text-dim); font-size: 12px; }

/* ---------- Custom date picker (replaces native <input type="date">) ---------- */
.datepicker { position: relative; }
.datepicker-display {
  width: 100%; display: flex; align-items: center; gap: 7px;
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 8px 10px; color: var(--text); font-family: 'IBM Plex Mono', monospace; font-size: 12.5px;
  cursor: pointer; text-align: left; transition: border-color var(--dur) var(--ease);
}
.datepicker-display:hover { border-color: var(--border-strong); }
.datepicker-display:disabled { color: var(--text-dim); cursor: not-allowed; opacity: 0.75; }
.datepicker-display.datepicker-placeholder { color: var(--text-dim); }
/* Compact variant for filter bars — sits next to .filter-input/.filter-date siblings */
.filter-date-group .datepicker-display { padding: 7px 8px; font-size: 12.5px; width: auto; min-width: 122px; }

.dp-panel {
  /* top/left are set inline by JS (renderDatePickerPanel), positioned
     against the trigger button's actual on-screen location — fixed, not
     absolute, so it's anchored to the viewport rather than any scrolling
     ancestor (the modals these fields live in scroll internally). */
  position: fixed; z-index: 60;
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: 10px; width: 250px; box-shadow: var(--shadow-lg);
  animation: dp-in 120ms var(--ease) both;
}
@keyframes dp-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.dp-header { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.dp-nav {
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 4px 7px; cursor: pointer; color: var(--text); display: flex; align-items: center;
  transition: border-color var(--dur) var(--ease);
}
.dp-nav:hover { border-color: var(--accent); }
.dp-month-label { font-size: 12.5px; font-weight: 500; flex: 1; text-align: center; }
.dp-year-select {
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 4px 5px; font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; color: var(--text);
}
.dp-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.dp-wd { text-align: center; font-size: 9.5px; color: var(--text-dim); text-transform: uppercase; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-cell { text-align: center; padding: 6px 0; font-size: 12px; border-radius: var(--r-sm); cursor: pointer; transition: background var(--dur) var(--ease); }
.dp-cell:hover { background: var(--panel-alt); }
.dp-cell.dp-empty { cursor: default; }
.dp-cell.dp-empty:hover { background: transparent; }
.dp-cell.dp-selected { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.dp-cell.dp-today:not(.dp-selected) { border: 1px solid var(--accent); }
.dp-footer { margin-top: 8px; display: flex; justify-content: space-between; }
.dp-footer .logout-link { margin: 0; }

.location-inline { display: inline-flex; align-items: center; gap: 3px; }
.location-inline svg { position: relative; top: 1px; }

.roleselect {
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 4px 6px; color: var(--text); font-family: 'IBM Plex Mono', monospace; font-size: 11.5px;
}

/* ---------- Per-user permission checklist (Edit user modal) ---------- */
.permlist {
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 9px;
}
.permlist-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-muted); cursor: pointer; }
.permlist-row input[type="checkbox"] { flex-shrink: 0; width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.modal-overlay {
  position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; z-index: 50;
  animation: overlay-in 160ms var(--ease) both;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  padding: 20px 22px; width: 420px; max-width: 90vw; max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in 180ms var(--ease) both;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { font-size: 15.5px; }

.banner-error { color: var(--danger); font-size: 12.5px; margin-bottom: 12px; }

/* =====================================================================
   Mobile — makes the app behave like a native phone app: a fixed top
   bar, a bottom tab bar instead of a side rail, full-width bottom-sheet
   modals, larger tap targets, and no accidental iOS zoom on inputs.
   ===================================================================== */
@media (max-width: 860px) {

  /* Top bar: brand + current user + logout, replaces the sidebar's brand/footer */
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: fixed; top: 0; left: 0; right: 0; z-index: 45;
    height: 52px; padding: 0 16px; padding-top: env(safe-area-inset-top);
    background: var(--panel); border-bottom: 1px solid var(--border);
  }
  .mobile-topbar-brand { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px; }
  .mobile-topbar-user { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-dim); }
  .mobile-topbar-user .logout-link { margin-top: 0; }

  /* Sidebar becomes a fixed bottom tab bar; its brand/footer are replaced by the top bar above */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    width: 100%; height: auto; flex-direction: row;
    border-right: none; border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    gap: 0; background: var(--panel);
  }
  .sidebar .brand, .sidebar .sidebar-footer { display: none; }
  .navlist { flex-direction: row; width: 100%; gap: 2px; }
  .navitem {
    flex: 1; flex-direction: column; gap: 3px; padding: 7px 2px 6px;
    border-radius: var(--r-md); font-size: 10px; text-align: center;
    min-height: 44px; justify-content: center;
  }
  .navitem span { white-space: nowrap; }
  .navitem svg { width: 19px; height: 19px; }
  .nav-alert-dot { position: absolute; margin-left: 0; top: 2px; right: 18%; }
  .navitem { position: relative; }

  /* Main content: clear the fixed top/bottom bars, tighter side padding */
  .main {
    padding: calc(52px + env(safe-area-inset-top) + 18px) 16px calc(64px + env(safe-area-inset-bottom) + 20px);
    max-width: 100%;
  }
  .topbar h1 { font-size: 20px; }

  .statgrid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 22px; }

  .section { padding: 14px; }

  .fieldrow { grid-template-columns: 1fr; gap: 0; }
  /* 16px prevents iOS Safari from auto-zooming the page on focus */
  .field input, .field select, .field textarea { font-size: 16px; padding: 10px 12px; }
  .field { margin-bottom: 14px; }

  .searchbar { width: 100%; }

  /* Alerts: drop the redundant date column and let the row wrap instead of clipping */
  .alertrow {
    display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px;
    padding: 12px 6px;
  }
  .alertrow .due { display: none; }
  .alertrow .cust { flex: 1 1 100%; order: 1; }
  .alertrow .sys-with-icon { order: 2; font-size: 12px; }
  .alertrow .badge { order: 3; margin-left: auto; }

  /* Buttons: comfortable tap targets */
  .btn, .btn.secondary, .btn.danger { min-height: 44px; }
  .btn.ghost { min-height: 36px; }
  .iconbtn { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }

  /* Bar charts: scroll horizontally instead of squeezing bars unreadably thin */
  .bar-chart { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .bar-chart .bar-col { min-width: 32px; }

  /* Modals become a full-width bottom sheet */
  .modal-overlay { align-items: flex-end; }
  .modal-box {
    width: 100%; max-width: 100%; max-height: 88vh;
    border-radius: 18px 18px 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    animation: sheet-in 220ms var(--ease) both;
  }
  @keyframes sheet-in {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .list-row { padding: 14px 6px; min-height: 44px; }

  /* Donut + horizontal-bar charts: stack instead of squeezing side by side */
  .donut-wrap { flex-direction: column; align-items: flex-start; gap: 16px; }
  .hbar-row { grid-template-columns: 90px 1fr 30px; gap: 8px; }
  .compare-row { grid-template-columns: 90px 1fr 50px; gap: 8px; }
  .compare-legend { flex-wrap: wrap; gap: 10px 18px; }
  .tabbar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { padding: 10px 4px; }
  .filterbar { flex-direction: column; align-items: stretch; }
  .filter-input { width: 100%; font-size: 16px; padding: 10px 12px; }
  .filterbar .combo { width: 100%; }
  .filterbar .combo-input-wrap { padding: 10px 12px; }
  .filterbar .combo-input { font-size: 16px; }
  .filter-date-group { width: 100%; }
  .filter-date { flex: 1; font-size: 16px; padding: 9px 8px; }
  .filter-date-group .datepicker-display { flex: 1; width: auto; font-size: 15px; padding: 9px 8px; }
  .dp-panel { width: min(280px, calc(100vw - 40px)); }
  .dp-cell { padding: 9px 0; font-size: 13px; }
}

/* =====================================================================
   House standard (v1.22.0): grey tiers with a bevel, uniform tabs, the
   report centre, the phone layout. Colour is reserved for indicators.
   ===================================================================== */

/* Signature line — shown on the login screen and in the sidebar footer */
.sig { color: var(--text-dim); font-size: 10.5px; margin-top: 8px; font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.03em; line-height: 1.5; }
.sig a { color: inherit; }
.login-box .sig { text-align: center; margin-top: 18px; }

/* Tabs: one width each, and the selected tab fills with ink so its text inverts */
.tabbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; border-bottom: none; }
.tab {
  width: 190px; max-width: 100%; box-sizing: border-box; margin-right: 0; padding: 9px 10px;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 13px; font-weight: 500; color: var(--text); background: var(--panel-alt);
  border: 1px solid var(--border); border-radius: var(--r-sm);
}
.tab:hover { color: var(--text); border-color: var(--border-strong); }
.tab.active { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }

/* Tier grades: flat fills. The depth comes from the bevel, not a gradient. */
.tile.tier-platinum, .tier-chip.tier-platinum { background: var(--tier-platinum); border-color: var(--tier-platinum-edge); }
.tile.tier-gold, .tier-chip.tier-gold { background: var(--tier-gold); border-color: var(--tier-gold-edge); }
.tile.tier-silver, .tier-chip.tier-silver { background: var(--tier-silver); border-color: var(--tier-silver-edge); }
.tier-section.tier-section-platinum { border-top-color: var(--tier-platinum-edge); }
.tier-section.tier-section-gold { border-top-color: var(--tier-gold-edge); }
.tier-section.tier-section-silver { border-top-color: var(--tier-silver-edge); }

.tier-board { display: flex; flex-direction: column; gap: 16px; margin-bottom: 22px; }
.tier-section {
  border: 1px solid var(--border); border-top: 3px solid; border-radius: var(--r-md);
  padding: 14px 16px 16px; background: var(--panel); box-shadow: var(--shadow-sm);
}
.tier-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.tier-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 50px;
  font-weight: 600; font-size: 13px; color: var(--tier-ink); border: 1px solid;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), inset 0 -1px 0 rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.12);
}
.tier-note { color: var(--text-dim); font-size: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tile {
  position: relative; display: block; box-sizing: border-box; min-height: 92px; padding: 14px 16px 16px;
  border-radius: 12px; border: 1px solid; color: var(--tier-ink); text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), inset 0 -2px 0 rgba(0,0,0,0.11), 0 2px 4px rgba(0,0,0,0.16), 0 6px 12px rgba(0,0,0,0.07);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.tile[role="button"] { cursor: pointer; }
.tile[role="button"]:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), inset 0 -2px 0 rgba(0,0,0,0.11), 0 5px 9px rgba(0,0,0,0.18), 0 12px 20px rgba(0,0,0,0.09);
}
/* Pressed: the bevel inverts, so the tile reads as pushed in */
.tile[role="button"]:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.20), inset 0 -1px 0 rgba(255,255,255,0.5), 0 1px 2px rgba(0,0,0,0.12);
}
/* A tile whose figure should be zero keeps its grey face: only the edge and number go red */
.tile.is-warn { border-color: var(--danger); }
.tile.is-warn .tile-num { color: var(--danger); }
.tile.is-active { outline: 2px solid var(--ink); outline-offset: 2px; }
.tile-label { display: block; font-size: 13px; font-weight: 600; opacity: 0.75; padding-right: 30px; }
.tile > svg { position: absolute; top: 13px; right: 14px; opacity: 0.45; }
.tile-num { display: block; font-family: 'Space Grotesk', sans-serif; font-size: 30px; font-weight: 700; line-height: 1.15; margin-top: 4px; }
.tile-num.is-amber { color: var(--amber); }
.tile-sub { display: block; font-size: 12px; opacity: 0.7; margin-top: 4px; }

/* Dashboard: two small lists side by side on a desk, stacked below 1100px */
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-cols .section { margin-bottom: 0; }
@media (max-width: 1100px) { .dash-cols { grid-template-columns: 1fr; } }

/* Report table: column picker, sortable headers, figures right-aligned */
.colpick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 12px; }
.colpick-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-right: 4px; }
.colchip {
  font-size: 12px; padding: 5px 11px; border-radius: 50px; border: 1px solid var(--border);
  background: var(--panel-alt); color: var(--text-muted); cursor: pointer; user-select: none;
}
.colchip:hover { color: var(--text); border-color: var(--border-strong); }
.colchip.on { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.colpick .logout-link { margin: 0 6px 0 8px; }
.sortable { cursor: pointer; white-space: nowrap; }
.sortable:hover { color: var(--text); }
table.systable th.num, table.systable td.num { text-align: right; }
table.systable td.num { font-family: 'IBM Plex Mono', monospace; }
.result-count { color: var(--text-dim); font-size: 11.5px; margin-top: 10px; }
.num-danger { color: var(--danger); font-weight: 600; }
.tile-num.is-amber, .tile.is-warn .tile-num { font-variant-numeric: tabular-nums; }

/* Phone: the work and nothing else. Desk-only sections never render here,
   and this is the second line of defence if they ever do. */
.phone-cta { width: 100%; min-height: 56px; justify-content: center; font-size: 16px; font-weight: 600; }
.phone-visit {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 4px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.phone-visit:last-child { border-bottom: none; }
.phone-visit .info { flex: 1 1 55%; min-width: 0; }
.phone-visit .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-visit .sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.phone-visit .btn { min-height: 44px; }

@media (max-width: 640px) {
  .desktop-only { display: none !important; }
  .tabbar { overflow: visible; }
  .tab { flex: 1 1 calc(50% - 6px); width: auto; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tier-section { padding: 12px 12px 14px; }
  .tile { min-height: 84px; padding: 12px 13px 14px; }
  .tile-num { font-size: 26px; }
  .colchip { font-size: 13px; }
}

/* ---- Company header (dashboard), sidebar and login logos, company profile form ---- */
.co-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.co-id { display: flex; gap: 16px; align-items: center; min-width: 0; }
.co-logo { width: 68px; height: 68px; object-fit: contain; border-radius: 8px; background: var(--panel-alt); border: 1px solid var(--border); flex: 0 0 auto; }
.co-logo-empty { display: flex; align-items: center; justify-content: center; font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 22px; color: var(--text-muted); }
.co-kicker { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.co-name { margin: 2px 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.co-meta { display: flex; flex-wrap: wrap; gap: 2px 16px; color: var(--text-muted); font-size: 12.5px; line-height: 1.5; }
.co-hint { margin-top: 6px; color: var(--amber); font-size: 12px; }
.co-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.co-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.co-footer { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 11.5px; font-family: 'IBM Plex Mono', monospace; line-height: 1.6; }
.co-footer a { color: var(--text-muted); }
.brand-logo { display: block; width: 36px; height: 36px; object-fit: contain; border-radius: 6px; margin-bottom: 8px; }
.brand-logo[hidden] { display: none; }
.login-brand .brand-logo { width: 52px; height: 52px; margin-bottom: 10px; }
.co-logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.co-logo-preview { width: 96px; height: 64px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border-strong); border-radius: 8px; color: var(--text-dim); font-size: 12px; background: var(--panel-alt); }
.co-logo-preview img { max-width: 88px; max-height: 56px; object-fit: contain; }
.co-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 720px) {
  .co-fields { grid-template-columns: 1fr; }
  .co-side { align-items: flex-start; }
  .co-actions { justify-content: flex-start; }
}

/* ---- Getting-ready card (desktop dashboard) ---- */
.setup-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.setup-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.setup-head h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.setup-count { color: var(--text-dim); font-size: 12px; font-family: 'IBM Plex Mono', monospace; }
.setup-bar { height: 6px; background: var(--panel-alt); border-radius: 3px; margin: 12px 0 4px; overflow: hidden; }
.setup-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.setup-step { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.setup-mark { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; background: var(--panel-alt); border: 1px solid var(--border-strong); color: var(--text-muted); font-size: 12px; font-weight: 600; }
.setup-step.is-done .setup-mark { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.setup-text { flex: 1; min-width: 0; }
.setup-title { font-weight: 600; font-size: 14px; }
.setup-desc { color: var(--text-dim); font-size: 12.5px; line-height: 1.5; margin-top: 2px; }
.setup-count-line { color: var(--text-muted); font-size: 12px; margin-top: 4px; font-family: 'IBM Plex Mono', monospace; }
.setup-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 720px) {
  .setup-step { flex-wrap: wrap; }
  .setup-actions { width: 100%; justify-content: flex-start; }
}

/* ---- Setup lists in Settings ---- */
.setup-hint { color: var(--text-muted); font-size: 12.5px; line-height: 1.6; margin: 0 0 12px; }
.setup-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.setup-row input { flex: 1 1 180px; min-width: 0; }
.setup-row select { flex: 0 0 auto; }
.setup-months { min-width: 56px; color: var(--text-dim); font-size: 12px; }

/* ---- Dashboard v1.26: KPI strip, attention list, two-column grids ---- */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { display: flex; flex-direction: column; gap: 4px; text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; cursor: pointer; font: inherit; color: var(--text); box-shadow: var(--shadow-sm); transition: border-color var(--dur) var(--ease); }
.kpi:hover { border-color: var(--border-strong); }
.kpi-label { color: var(--text-muted); font-size: 12px; font-weight: 500; }
.kpi-num { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-family: 'Space Grotesk', sans-serif; }
.kpi-sub { color: var(--text-dim); font-size: 11.5px; min-height: 1em; }
.kpi.is-warn { border-color: var(--danger-border); }
.kpi.is-warn .kpi-num { color: var(--danger); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.dash-grid > .section, .dash-grid-3 > .section { margin-bottom: 0; }
.dash-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.att-row, .plan-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.att-row:first-of-type, .plan-row:first-of-type { border-top: 0; }
.att-row.is-action, .plan-row.is-link { cursor: pointer; }
.att-row.is-action:hover, .plan-row.is-link:hover { background: var(--panel-alt); }
.att-kind { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); width: 78px; flex: 0 0 auto; }
.att-main { flex: 1; min-width: 0; }
.att-customer { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-detail { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-due { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.att-btn { padding: 4px 9px; font-size: 12px; white-space: nowrap; }
.att-more { color: var(--text-dim); font-size: 12px; padding-top: 10px; border-top: 1px solid var(--border); margin-top: 4px; }
.plan-date { width: 96px; flex: 0 0 auto; font-size: 12px; color: var(--text-muted); }
@media (max-width: 1100px) {
  .dash-grid, .dash-grid-3 { grid-template-columns: 1fr; }
}

/* ---- Arabic (right-to-left) — v1.26.0 ----
   The page flips with direction: rtl on <html>, so flex rows, text flow and
   table order reverse on their own. These rules cover the physical left/right
   properties that do not flip by themselves, and use one Arabic-capable face. */
html[dir="rtl"] *, html[dir="rtl"] *::before, html[dir="rtl"] *::after {
  font-family: 'IBM Plex Sans Arabic', 'Tajawal', 'IBM Plex Sans', 'Segoe UI', Tahoma, sans-serif !important;
  letter-spacing: 0 !important;
}
html[dir="rtl"] .sidebar { border-right: 0; border-left: 1px solid var(--border); }
html[dir="rtl"] .logout-link { margin-right: 0; margin-left: 12px; }
html[dir="rtl"] .kpi { text-align: right; }
html[dir="rtl"] .tile-label { padding-right: 0; padding-left: 30px; }
html[dir="rtl"] .tile > svg { right: auto; left: 14px; }
html[dir="rtl"] table.systable th, html[dir="rtl"] table.systable td { text-align: right; }
html[dir="rtl"] table.systable th.num, html[dir="rtl"] table.systable td.num { text-align: left; }
html[dir="rtl"] .bar-chart .bar-count, html[dir="rtl"] .bar-chart .bar-label { direction: ltr; }
html[dir="rtl"] input[type="email"], html[dir="rtl"] input[type="tel"], html[dir="rtl"] input[type="url"],
html[dir="rtl"] input[type="password"], html[dir="rtl"] .mono { direction: ltr; text-align: left; }
html[dir="rtl"] .theme-toggle, html[dir="rtl"] .theme-toggle-mobile { margin-left: 0; }
@media (max-width: 860px) {
  html[dir="rtl"] .navitem { font-size: 10px; line-height: 1.2; }
  html[dir="rtl"] .navitem span { white-space: normal; text-align: center; }
}

/* =========================================================================
   v1.28.0: NEP-ERP look. theme.js writes the colours as CSS variables on
   <html>. These rules place them: the menu is the colour rail, the top bar
   is the topbar colour, and the type is IBM Plex Sans. Flat surfaces only,
   no gradients. Dashboard tiles keep the flat grey house grades.
   ========================================================================= */
body, h1, h2, h3, button, input, select, textarea {
  font-family: 'IBM Plex Sans', 'IBM Plex Sans Arabic', 'Tajawal', system-ui, sans-serif;
}
.brand-title { font-family: 'IBM Plex Sans', 'IBM Plex Sans Arabic', 'Tajawal', system-ui, sans-serif; }

.sidebar {
  background: var(--rail-bg);
  color: var(--rail-text);
  border-right: 1px solid var(--rail-line);
  --text: var(--rail-text); --text-muted: var(--rail-muted); --text-dim: var(--rail-muted);
  --border: var(--rail-line); --border-strong: var(--rail-line);
}
.sidebar .navitem:hover { background: var(--rail-hover); color: var(--rail-text); }
.sidebar .navitem.active { background: var(--rail-hover); color: var(--rail-text); box-shadow: inset 3px 0 0 var(--rail-accent); }

.mobile-topbar {
  background: var(--topbar-bg);
  color: var(--on-topbar);
  border-bottom: 1px solid var(--topbar-line);
  --text: var(--on-topbar); --text-muted: var(--on-topbar-muted); --text-dim: var(--on-topbar-muted);
  --border: var(--topbar-line);
}

/* Appearance settings (admin) */
.ap-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 4px 0 16px; }
.ap-preset {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px;
  background: var(--panel-alt); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r); font: inherit; font-size: 12.5px; cursor: pointer; text-align: start;
}
.ap-preset:hover { border-color: var(--border-strong); }
.ap-preset.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ap-swatches { display: flex; width: 100%; height: 26px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); }
.ap-swatches i { flex: 1; display: block; }
.field input[type="color"] { width: 64px; height: 34px; padding: 2px; }

/* v1.28.3: logo splash and mobile install sheet */
.app-splash {
  position: fixed; inset: 0; z-index: 999; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  transition: opacity .35s ease;
}
.app-splash.hide { opacity: 0; pointer-events: none; }
.app-splash img { max-width: 180px; max-height: 120px; object-fit: contain; }
.app-splash-name { font-size: 15px; color: var(--text-muted); letter-spacing: .02em; }

.install-sheet {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 900;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 14px; display: flex; gap: 12px; align-items: flex-start;
}
.install-sheet img, .install-sheet-mark {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: var(--r); object-fit: contain;
}
.install-sheet-mark { background: var(--ink); color: var(--ink-text); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 18px; }
.install-sheet-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.install-sheet-body strong { font-size: 14px; }
.install-sheet-body > span { font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }
.install-sheet-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* =========================================================================
   v1.29.0 — Design refresh
   A framed workspace: the menu colour wraps the page, and the working area
   sits inside it as one rounded canvas with its own header. The language
   switch, search (Ctrl/Cmd + K) and the account menu live in that header,
   top right. Flat fills only — depth comes from hairlines, bevels and
   shadow, never a gradient. Colour stays reserved for indicators.
   ========================================================================= */
:root[data-theme="dark"] {
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.28);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.32), 0 2px 6px rgba(0,0,0,0.22);
  --shadow-lg: 0 24px 64px rgba(0,0,0,0.48), 0 6px 16px rgba(0,0,0,0.26);
  --bevel: inset 0 1px 0 rgba(255,255,255,0.05);
  --bevel-strong: inset 0 1px 0 rgba(255,255,255,0.10), inset 0 -1px 0 rgba(0,0,0,0.25);
}
:root[data-theme="light"] {
  --shadow-sm: 0 1px 2px rgba(16,24,40,0.05);
  --shadow-md: 0 8px 24px rgba(16,24,40,0.08), 0 2px 6px rgba(16,24,40,0.05);
  --shadow-lg: 0 24px 64px rgba(16,24,40,0.16), 0 6px 16px rgba(16,24,40,0.08);
  --bevel: inset 0 1px 0 rgba(255,255,255,0.9);
  --bevel-strong: inset 0 1px 0 rgba(255,255,255,0.9), inset 0 -1px 0 rgba(16,24,40,0.08);
}
:root {
  --frame-gap: 10px;
  --rail-w: 252px;
  --rail-w-collapsed: 76px;
  --header-h: 62px;
  --dur: 160ms;
  /* Fallbacks until theme.js has written the derived colours */
  --rail-solid: var(--rail-bg, #131E2C);
  --rail-active: rgba(255,255,255,0.09);
  --accent-text: var(--accent);
  --panel-hover: var(--panel-alt);
  --input-bg: var(--panel-alt);
}

body { font-size: 14px; letter-spacing: -0.003em; background: var(--bg); }
.mono, .tile-num, .kpi-num, .stat-value { font-variant-numeric: tabular-nums; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* Quiet scrollbars that match the surface */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Shared marks ---------- */
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--rail-active); color: var(--rail-text);
  font-weight: 700; font-size: 15px; letter-spacing: 0.02em;
  box-shadow: var(--bevel-strong);
}
.brand-mark[hidden] { display: none; }
.version-pill {
  display: inline-flex; align-items: center; font-size: 10.5px; padding: 2px 8px;
  border: 1px solid currentColor; border-radius: 999px; opacity: 0.75; letter-spacing: 0.02em;
}

/* ---------- Language switch (top right everywhere) ---------- */
.lang-switch {
  --ls-fg: var(--text-muted); --ls-line: var(--border-strong); --ls-on-bg: var(--ink); --ls-on-fg: var(--ink-text);
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  border: 1px solid var(--ls-line); border-radius: 999px;
}
.lang-switch button {
  height: 28px; min-width: 42px; padding: 0 11px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ls-fg); font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.lang-switch button[data-lang="ar"] { font-family: 'IBM Plex Sans Arabic', 'Tajawal', sans-serif !important; letter-spacing: 0 !important; font-size: 12.5px; }
.lang-switch button:hover { color: var(--ls-on-bg); }
.lang-switch button.on { background: var(--ls-on-bg); color: var(--ls-on-fg); box-shadow: var(--shadow-sm); }

/* =========================== Login =========================== */
#login-screen { min-height: 100vh; padding: 0; align-items: stretch; justify-content: stretch; background: var(--bg); }
.login-aside {
  flex: 0 0 44%; max-width: 580px; position: relative; overflow: hidden;
  background: var(--rail-solid); color: var(--rail-text); padding: 40px 48px;
}
.login-pattern { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--rail-text); opacity: 0.07; pointer-events: none; }
.login-aside-inner { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.login-aside-brand { display: flex; align-items: center; gap: 12px; }
.login-aside-brand .brand-logo { width: 44px; height: 44px; margin: 0; border-radius: var(--r-md); background: rgba(255,255,255,0.92); padding: 4px; }
.login-aside-name { font-weight: 600; font-size: 15px; }
.login-aside-kicker { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.14em; color: var(--rail-muted); margin-bottom: 14px; }
.login-aside-title { font-size: 31px; line-height: 1.22; font-weight: 600; letter-spacing: -0.022em; max-width: 440px; }
.login-points { list-style: none; padding: 0; margin: 30px 0 0; display: flex; flex-direction: column; gap: 14px; }
.login-points li { display: flex; align-items: center; gap: 12px; color: var(--rail-muted); font-size: 14px; }
.login-point-ico {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center;
  background: var(--rail-active); color: var(--rail-text); box-shadow: var(--bevel-strong);
}
.login-aside .sig { color: var(--rail-muted); margin: 0; }
.login-main { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 88px 24px 40px; }
.login-topright { position: absolute; top: 22px; inset-inline-end: 24px; }
.login-box {
  width: 420px; max-width: 100%; padding: 36px 36px 28px; border-radius: var(--r-xl);
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-lg), var(--bevel);
}
.login-box .login-brand { display: none; }
.login-welcome { font-size: 26px; font-weight: 600; letter-spacing: -0.022em; margin: 0; }
.login-lede { margin: 6px 0 26px; color: var(--text-muted); font-size: 14px; }
.field-labelrow { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.field-labelrow label { margin-bottom: 0 !important; }
.login-forgot { font-size: 12.5px; font-weight: 500; }
.login-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 12px; }
.login-foot a { color: var(--text-muted); }
.login-foot .version-pill { color: var(--text-dim); }
.login-sig-mobile { display: none; }
.login-error:empty { min-height: 0; margin: 0; }

/* =========================== App frame =========================== */
#app-screen.visible { display: flex; min-height: 100vh; background: var(--rail-solid); }

.sidebar {
  position: sticky; top: 0; height: 100vh; width: var(--rail-w); flex: 0 0 auto;
  padding: 18px 12px 14px; gap: 6px; border: 0 !important; overflow: hidden;
  transition: width 220ms var(--ease);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px; min-width: 0; }
.brand .brand-logo { width: 38px; height: 38px; margin: 0; flex: 0 0 auto; border-radius: var(--r-md); background: rgba(255,255,255,0.92); padding: 3px; object-fit: contain; }
.brand-text { min-width: 0; }
.brand-title { font-size: 14.5px; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--rail-text); }
.brand-sub { font-size: 10px; letter-spacing: 0.14em; color: var(--rail-muted); margin-top: 3px; }

.navlist { gap: 2px; overflow-y: auto; overflow-x: hidden; flex: 1; margin: 0 -4px; padding: 0 4px; }
.nav-group {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--rail-muted); opacity: 0.8; padding: 16px 12px 6px; white-space: nowrap;
}
.nav-group:first-child { padding-top: 6px; }
.navitem {
  position: relative; height: 40px; padding: 0 12px; gap: 12px; border: 0 !important;
  border-radius: var(--r-md); color: var(--rail-muted); font-weight: 500; font-size: 13.5px; white-space: nowrap;
}
.nav-ico { display: inline-flex; flex: 0 0 auto; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar .navitem:hover { background: var(--rail-hover); color: var(--rail-text); }
.sidebar .navitem.active { background: var(--rail-active); color: var(--rail-text); font-weight: 600; box-shadow: var(--bevel-strong); }
.sidebar .navitem.active .nav-ico { color: var(--rail-accent); }
.sidebar .navitem.active::before {
  content: ""; position: absolute; inset-inline-start: -12px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 3px; background: var(--rail-accent);
}
.nav-alert-dot {
  margin-inline-start: auto; margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  font-size: 10.5px; font-family: 'IBM Plex Mono', monospace; background: var(--danger); color: #fff;
  box-shadow: 0 0 0 2px var(--rail-solid);
}
html[dir="rtl"] .nav-alert-dot { margin-left: 0; margin-right: auto; }

.sidebar-footer { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--rail-line); display: flex; flex-direction: column; gap: 10px; }
.rail-toggle {
  display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 12px; border-radius: var(--r-md);
  background: transparent; border: 0; color: var(--rail-muted); font: inherit; font-size: 12.5px; white-space: nowrap; width: 100%;
}
.rail-toggle:hover { background: var(--rail-hover); color: var(--rail-text); }
.rail-toggle svg { flex: 0 0 auto; transition: transform 220ms var(--ease); }
html[dir="rtl"] .rail-toggle svg { transform: scaleX(-1); }
.rail-meta { padding: 0 12px 2px; color: var(--rail-muted); }
.rail-meta .sig { margin-top: 6px; color: var(--rail-muted); }

/* Collapsed rail (desktop only) */
@media (min-width: 861px) {
  html.rail-collapsed .sidebar { width: var(--rail-w-collapsed); }
  html.rail-collapsed .brand { justify-content: center; padding-inline: 0; }
  html.rail-collapsed .brand-text,
  html.rail-collapsed .nav-label,
  html.rail-collapsed .rail-toggle span,
  html.rail-collapsed .rail-meta { display: none; }
  html.rail-collapsed .nav-group { font-size: 0; padding: 10px 0; margin: 6px 12px; height: 1px; background: var(--rail-line); opacity: 1; }
  html.rail-collapsed .nav-group:first-child { display: none; }
  html.rail-collapsed .navitem, html.rail-collapsed .rail-toggle { justify-content: center; padding: 0; }
  html.rail-collapsed .nav-alert-dot { position: absolute; top: 3px; right: 7px; min-width: 16px; height: 16px; font-size: 9.5px; padding: 0 4px; margin: 0; }
  html.rail-collapsed .rail-toggle svg { transform: scaleX(-1); }
  html.rail-collapsed[dir="rtl"] .rail-toggle svg { transform: none; }
}

/* The working canvas */
.shell {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  height: calc(100vh - var(--frame-gap) * 2); margin-block: var(--frame-gap); margin-inline-end: var(--frame-gap);
  background: var(--bg); border-radius: var(--r-xl); overflow: hidden;
  border: 1px solid var(--rail-line); box-shadow: var(--shadow-md);
}
.app-header {
  flex: 0 0 auto; height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px; background: var(--topbar-bg); color: var(--on-topbar); border-bottom: 1px solid var(--topbar-line);
  position: relative; z-index: 40;
}
.hdr-left, .hdr-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hdr-mark, .hdr-brand { display: none; }
.hdr-right .lang-switch { --ls-fg: var(--on-topbar-muted); --ls-line: var(--topbar-line); --ls-on-bg: var(--on-topbar); --ls-on-fg: var(--topbar); }

.cmdk-trigger {
  display: flex; align-items: center; gap: 10px; width: 360px; max-width: 42vw; height: 38px; padding: 0 8px 0 12px;
  border-radius: var(--r-md); border: 1px solid var(--topbar-line); color: var(--on-topbar-muted); font: inherit; font-size: 13px;
  background: color-mix(in srgb, var(--on-topbar) 5%, transparent); text-align: start;
}
.cmdk-trigger:hover { border-color: color-mix(in srgb, var(--on-topbar) 28%, transparent); color: var(--on-topbar); }
.cmdk-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-kbd {
  font-family: 'IBM Plex Mono', monospace !important; font-size: 10.5px; padding: 3px 7px; border-radius: 6px;
  border: 1px solid currentColor; opacity: 0.7; white-space: nowrap; direction: ltr;
}

.usermenu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 10px 0 5px; border-radius: 999px;
  background: transparent; border: 1px solid transparent; color: var(--on-topbar); font: inherit;
}
html[dir="rtl"] .user-chip { padding: 0 5px 0 10px; }
.user-chip:hover, .user-chip[aria-expanded="true"] { border-color: var(--topbar-line); background: color-mix(in srgb, var(--on-topbar) 6%, transparent); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
  background: var(--ink); color: var(--ink-text); box-shadow: var(--bevel-strong);
}
.user-chip .avatar { background: var(--on-topbar); color: var(--topbar); }
.avatar-lg { width: 42px; height: 42px; font-size: 14px; }
.user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; min-width: 0; }
.user-meta .session-user { font-size: 13px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta .session-role { font-size: 11px; color: var(--on-topbar-muted); font-family: inherit; text-transform: none; letter-spacing: 0; }
.user-caret { color: var(--on-topbar-muted); }

.usermenu-panel {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; width: 250px; z-index: 70;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 6px; animation: dp-in 140ms var(--ease) both;
}
.usermenu-panel[hidden] { display: none; }
.usermenu-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.usermenu-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-role { color: var(--text-dim); font-size: 12px; }
.usermenu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 10px; border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--text); font: inherit; font-size: 13px; text-align: start;
}
.usermenu-item svg { color: var(--text-muted); }
.usermenu-item:hover { background: var(--panel-alt); }
.usermenu-item.is-danger, .usermenu-item.is-danger svg { color: var(--danger); }
.usermenu-sep { height: 1px; background: var(--border); margin: 4px 6px; }

.main {
  flex: 1; overflow-y: auto; overflow-x: hidden; max-width: none;
  padding: 28px max(32px, calc((100% - 1240px) / 2)) 56px;
  scroll-behavior: smooth;
}

/* =========================== Page content =========================== */
.topbar { align-items: center; margin-bottom: 22px; gap: 12px; }
.topbar h1, h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.022em; }
.topbar .date {
  font-size: 11.5px; color: var(--text-muted); padding: 5px 11px; border: 1px solid var(--border-strong);
  border-radius: 999px; background: var(--panel);
}

.section, .setup-card, .tier-section {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px 22px; box-shadow: var(--shadow-sm), var(--bevel);
}
.section { margin-bottom: 18px; }
.section-head { margin-bottom: 14px; }
.section-head h2 { font-size: 15px; font-weight: 600; color: var(--text); text-transform: none; letter-spacing: -0.01em; }
.section-head .logout-link, .att-more .logout-link {
  margin: 0; font-size: 12.5px; font-weight: 500; color: var(--accent-text);
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
}
.section-head .logout-link:hover { background: var(--panel-alt); border-color: var(--border-strong); }
.logout-link { color: var(--accent-text); }
.logout-link:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.section-head .logout-link:hover { text-decoration: none; }

.empty {
  color: var(--text-dim); padding: 30px 16px; font-size: 13px; text-align: center;
  border: 1px dashed var(--border-strong); border-radius: var(--r-md); background: transparent;
}
.banner-error { background: var(--danger-soft); border: 1px solid var(--danger-border); padding: 10px 12px; border-radius: var(--r-md); }
.banner-error:empty { display: none; }

/* Dashboard hero */
.co-head {
  position: relative; overflow: hidden; padding: 22px 26px; border-radius: var(--r-xl);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm), var(--bevel); margin-bottom: 18px;
}
.co-head::after {
  content: ""; position: absolute; inset-block: 0; inset-inline-end: 0; width: 460px; max-width: 70%;
  background: var(--text); opacity: 0.05; pointer-events: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='460' height='180' viewBox='0 0 460 180'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M0 46h120l24 24h110l26-26h190'/%3E%3Cpath d='M0 112h70l34 34h150l34-34h182'/%3E%3Cpath d='M200 -10v40l22 22'/%3E%3Cpath d='M380 190v-60l-20-20'/%3E%3C/g%3E%3Cg fill='%23000'%3E%3Ccircle cx='254' cy='70' r='4'/%3E%3Ccircle cx='104' cy='146' r='3.5'/%3E%3Ccircle cx='222' cy='52' r='3'/%3E%3Ccircle cx='288' cy='112' r='4'/%3E%3Ccircle cx='360' cy='110' r='3'/%3E%3C/g%3E%3C/svg%3E") right center / 460px auto no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='460' height='180' viewBox='0 0 460 180'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M0 46h120l24 24h110l26-26h190'/%3E%3Cpath d='M0 112h70l34 34h150l34-34h182'/%3E%3Cpath d='M200 -10v40l22 22'/%3E%3Cpath d='M380 190v-60l-20-20'/%3E%3C/g%3E%3Cg fill='%23000'%3E%3Ccircle cx='254' cy='70' r='4'/%3E%3Ccircle cx='104' cy='146' r='3.5'/%3E%3Ccircle cx='222' cy='52' r='3'/%3E%3Ccircle cx='288' cy='112' r='4'/%3E%3Ccircle cx='360' cy='110' r='3'/%3E%3C/g%3E%3C/svg%3E") right center / 460px auto no-repeat;
}
html[dir="rtl"] .co-head::after { -webkit-mask-position: left center; mask-position: left center; transform: scaleX(-1); }
.co-head > * { position: relative; z-index: 1; }
.co-logo { width: 64px; height: 64px; border-radius: var(--r-lg); background: #fff; padding: 6px; box-shadow: var(--bevel-strong); }
.co-logo-empty { background: var(--ink); color: var(--ink-text); padding: 0; font-size: 22px; }
.co-kicker { color: var(--text-dim); letter-spacing: 0.14em; font-size: 10.5px; }
.co-name { font-size: 25px; letter-spacing: -0.024em; }
.co-meta { gap: 2px 18px; }
.co-side .date { font-size: 11.5px; color: var(--text-muted); padding: 5px 11px; border: 1px solid var(--border-strong); border-radius: 999px; }
.co-footer { border-top: 1px solid var(--border); margin-top: 28px; text-align: center; }

/* KPI strip */
.kpi-strip { gap: 14px; margin-bottom: 18px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi {
  position: relative; overflow: hidden; gap: 6px; padding: 16px 18px 15px; border-radius: var(--r-lg);
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-sm), var(--bevel);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.kpi:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md), var(--bevel); }
.kpi:active { transform: translateY(0); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.kpi-ico {
  width: 32px; height: 32px; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  background: var(--panel-alt); color: var(--text-muted); border: 1px solid var(--border); box-shadow: var(--bevel);
}
.kpi-num { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; margin-top: 2px; }
.kpi-sub { font-size: 12px; }
.kpi.is-warn { border-color: var(--danger-border); }
.kpi.is-warn::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; background: var(--danger); }
.kpi.is-warn .kpi-ico { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }

/* Lists inside dashboard cards */
.att-row, .plan-row { padding: 11px 10px; margin: 0 -10px; border-radius: var(--r-md); border-top-color: var(--border); }
.att-row.is-action:hover, .plan-row.is-link:hover { background: var(--panel-hover); }
.att-kind {
  width: auto; min-width: 86px; font-size: 10px; padding: 3px 8px; border-radius: 999px; text-align: center;
  background: var(--panel-alt); border: 1px solid var(--border); color: var(--text-muted);
}
.plan-date { font-size: 11.5px; color: var(--text-muted); }
.att-btn { height: 30px; min-height: 30px !important; padding: 0 10px !important; border-radius: 999px !important; }

/* Badges: pills with a status dot */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px;
  font-family: inherit; font-size: 11.5px; font-weight: 600; letter-spacing: 0;
  background: var(--panel-alt); color: var(--text-muted); border: 1px solid var(--border);
}
html[dir="rtl"] .badge { padding: 3px 8px 3px 10px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.badge-overdue { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.badge-due-soon { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.badge-ok { background: var(--ok-soft, var(--accent-soft)); color: var(--ok, var(--accent)); border-color: color-mix(in srgb, var(--ok, var(--accent)) 30%, transparent); }
.badge-ended { background: var(--panel-alt); color: var(--text-dim); }

/* Buttons */
.btn {
  height: 38px; padding: 0 16px; border-radius: var(--r-md); font-size: 13.5px; font-weight: 600; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), inset 0 -1px 0 rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.18);
  justify-content: center; white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); box-shadow: inset 0 1px 2px rgba(0,0,0,0.22); }
.btn.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm), var(--bevel); }
.btn.secondary:hover { background: var(--panel-hover); color: var(--text); }
.btn.danger { background: var(--panel); color: var(--danger); border: 1px solid var(--danger-border); box-shadow: var(--shadow-sm); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; color: var(--accent-text); box-shadow: none; height: 32px; padding: 0 10px; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn-block { width: 100%; }
.btn-lg { height: 46px; font-size: 14.5px; border-radius: var(--r-md); }
.iconbtn { border-radius: var(--r-md); padding: 6px; }
.iconbtn:hover { background: var(--panel-alt); }

/* Form controls */
.field { margin-bottom: 14px; }
.field label {
  font-size: 12.5px; color: var(--text-muted); text-transform: none; letter-spacing: 0; font-weight: 500; margin-bottom: 6px;
}
.field input, .field select, .field textarea,
.filter-input, .filter-date, .roleselect, .dp-year-select, .setup-row input, .setup-row select {
  background: var(--input-bg); border: 1px solid var(--border-strong); border-radius: var(--r-md); color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field input, .field select { height: 40px; padding: 0 12px; font-size: 13.5px; }
.field textarea { padding: 10px 12px; font-size: 13.5px; line-height: 1.5; }
.field input[type="checkbox"], .field input[type="radio"] { height: auto; width: auto; }
.field input[type="color"] { height: 36px; padding: 3px; }
.field input:focus, .field select:focus, .field textarea:focus, .filter-input:focus,
.setup-row input:focus, .setup-row select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring, var(--accent-soft)); outline: none;
}
.filter-input { height: 38px; padding: 0 12px; }
.searchbar, .combo-input-wrap, .datepicker-display {
  background: var(--input-bg); border: 1px solid var(--border-strong); border-radius: var(--r-md);
}
.searchbar { height: 38px; padding: 0 12px; width: 260px; }
.searchbar:focus-within, .combo-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring, var(--accent-soft)); }
.combo-input-wrap { min-height: 40px; padding: 0 12px; }
.datepicker-display { min-height: 40px; padding: 0 12px; }
.combo-list, .dp-panel { border-radius: var(--r-lg); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.combo-item { border-radius: var(--r-sm); margin: 2px 4px; }
.combo-list { padding: 4px 0; }
.dp-cell.dp-selected { box-shadow: var(--bevel-strong); }
.permlist { background: var(--panel-alt); border-radius: var(--r-lg); padding: 12px 14px; }

/* Tabs — house standard kept: uniform width, the selected tab fills with ink and its text inverts */
.tabbar {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; max-width: 100%;
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.tab {
  width: 176px; height: 34px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-md); color: var(--text-muted); cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--panel); border-color: var(--border); }
.tab.active { background: var(--ink); color: var(--ink-text); border-color: var(--ink); box-shadow: var(--shadow-sm), var(--bevel-strong); }
.colchip { padding: 5px 12px; }
.colchip.on { box-shadow: var(--bevel-strong); }

/* Tables */
table.systable { border-collapse: separate; border-spacing: 0; }
table.systable th {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; color: var(--text-dim);
  background: var(--panel-alt); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.systable th:first-child { border-start-start-radius: var(--r-md); border-end-start-radius: var(--r-md); }
table.systable th:last-child { border-start-end-radius: var(--r-md); border-end-end-radius: var(--r-md); }
table.systable th { border-bottom: 0; }
table.systable td { padding: 12px; border-bottom: 1px solid var(--border); }
table.systable tbody tr:hover td, .clickable-row:hover td { background: var(--panel-hover); }
.clickable-row:hover { background: transparent; }
.result-count { font-size: 12px; }

/* Rows */
.list-row, .alertrow { padding: 13px 12px; margin: 0 -12px; border-radius: var(--r-md); border-bottom-color: var(--border); }
.list-row:hover, .alertrow:hover { background: var(--panel-hover); }
.list-row .name { font-weight: 600; }
.back { display: inline-flex; padding: 6px 12px 6px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); }
.back:hover { border-color: var(--border-strong); }
html[dir="rtl"] .back svg { transform: scaleX(-1); }

/* Charts: flat bars; the current month carries the full accent */
.bar-chart .bar { border-radius: 6px 6px 2px 2px; max-width: 28px; background: var(--accent); opacity: 0.45; }
.bar-chart .bar-col.is-current .bar { opacity: 1; }
.bar-chart .bar-col.is-current .bar-label { color: var(--text); font-weight: 600; }
.bar-chart .bar-col:hover .bar { opacity: 0.8; }
.hbar-track, .compare-track { height: 8px; border-radius: 999px; background: var(--panel-alt); }
.hbar-fill, .compare-fill { border-radius: 999px; }

/* Setup card */
.setup-bar { height: 6px; border-radius: 999px; }
.setup-bar span { border-radius: 999px; }
.setup-mark { box-shadow: var(--bevel); }

/* Modals: bottom sheet on phones, a centred card on a desk */
.modal-overlay { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal-box { border-radius: var(--r-xl); padding: 22px 24px; width: 460px; box-shadow: var(--shadow-lg), var(--bevel); }
.modal-head { padding-bottom: 14px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; letter-spacing: -0.015em; }

/* Command palette */
.palette-overlay {
  position: fixed; inset: 0; z-index: 80; background: var(--scrim); display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh 16px 16px; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: overlay-in 140ms var(--ease) both;
}
.palette {
  width: 640px; max-width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg), var(--bevel); overflow: hidden; animation: modal-in 160ms var(--ease) both;
}
.palette-input-row { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 58px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.palette-input { flex: 1; height: 100%; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; font-size: 16px; }
.palette-input-row .cmdk-kbd { color: var(--text-dim); }
.palette-list { max-height: min(52vh, 440px); overflow-y: auto; padding: 6px; }
.palette-group { font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); padding: 10px 10px 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--r-md); cursor: pointer; color: var(--text); }
.palette-item.on { background: var(--panel-alt); box-shadow: inset 3px 0 0 var(--accent); }
html[dir="rtl"] .palette-item.on { box-shadow: inset -3px 0 0 var(--accent); }
.palette-ico {
  width: 32px; height: 32px; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  background: var(--panel-alt); border: 1px solid var(--border); color: var(--text-muted);
}
.palette-item.on .palette-ico { color: var(--text); background: var(--panel); }
.palette-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.palette-label { font-weight: 500; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-sub { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-go { color: var(--text-dim); opacity: 0; display: inline-flex; }
.palette-item.on .palette-go { opacity: 1; }
html[dir="rtl"] .palette-go svg { transform: scaleX(-1); }
.palette-empty { padding: 28px; text-align: center; color: var(--text-dim); }
.palette-foot { padding: 10px 16px; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 11.5px; }

/* Splash */
.app-splash { background: var(--rail-solid); gap: 18px; }
.app-splash-name { color: var(--rail-text, var(--text)); font-weight: 600; font-size: 16px; }
.app-splash-bar { width: 140px; height: 3px; border-radius: 999px; overflow: hidden; background: var(--rail-line, var(--border)); }
.app-splash-bar span { display: block; width: 40%; height: 100%; border-radius: 999px; background: var(--accent); animation: splash-run 900ms var(--ease) infinite; }
@keyframes splash-run { from { transform: translateX(-110%); } to { transform: translateX(260%); } }

/* Appearance presets */
.ap-preset { border-radius: var(--r-lg); padding: 10px; }
.ap-swatches { height: 30px; border-radius: var(--r-md); }

/* Install sheet */
.install-sheet { border-radius: var(--r-xl); box-shadow: var(--shadow-lg), var(--bevel); }

/* =========================== Tablet and phone =========================== */
@media (max-width: 1100px) {
  .cmdk-trigger { width: 280px; }
  .user-meta { display: none; }
}

@media (max-width: 860px) {
  #app-screen.visible { display: block; background: var(--bg); }

  /* Login: the brand panel folds away, the card fills the screen */
  #login-screen { flex-direction: column; }
  .login-aside { display: none; }
  .login-main { padding: 76px 16px 28px; justify-content: flex-start; }
  .login-topright { top: calc(16px + env(safe-area-inset-top)); inset-inline-end: 16px; }
  .login-box { padding: 28px 22px 22px; border-radius: var(--r-xl); }
  .login-box .login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
  .login-box .login-brand .brand-logo { margin: 0; width: 44px; height: 44px; }
  .login-sig-mobile { display: block; text-align: center; margin-top: 18px; }

  /* The canvas becomes the page; the header is fixed at the top */
  .shell { display: block; height: auto; margin: 0; border: 0; border-radius: 0; box-shadow: none; overflow: visible; background: var(--bg); }
  .app-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 45;
    height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
  }
  .hdr-left, .hdr-right { gap: 8px; }
  .hdr-mark { display: inline-flex; width: 34px; height: 34px; font-size: 13px; background: color-mix(in srgb, var(--on-topbar) 10%, transparent); color: var(--on-topbar); }
  .hdr-mark.has-logo { background: #fff; padding: 3px; }
  .hdr-mark img { width: 100%; height: 100%; object-fit: contain; }
  .hdr-brand { display: block; font-weight: 600; font-size: 15px; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cmdk-trigger { width: 38px; height: 38px; padding: 0; justify-content: center; border-radius: 999px; flex: 0 0 auto; }
  .cmdk-text, .cmdk-trigger .cmdk-kbd { display: none; }
  .lang-switch button { min-width: 36px; padding: 0 8px; height: 28px; }
  .user-chip { padding: 0 2px !important; height: 40px; }
  .user-caret { display: none; }

  .main {
    overflow: visible;
    padding: calc(56px + env(safe-area-inset-top) + 18px) 16px calc(92px + env(safe-area-inset-bottom));
  }

  /* The menu is a floating dock at the bottom */
  .sidebar {
    position: fixed; top: auto; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    width: auto; height: auto; padding: 6px; border-radius: 22px; z-index: 45; overflow: visible;
    background: var(--rail-solid); border: 1px solid var(--rail-line) !important; box-shadow: var(--shadow-lg);
  }
  .sidebar .brand, .sidebar .sidebar-footer, .nav-group { display: none; }
  .navlist { flex-direction: row; overflow-x: auto; overflow-y: hidden; margin: 0; padding: 0; gap: 2px; scrollbar-width: none; }
  .navlist::-webkit-scrollbar { display: none; }
  .navitem {
    flex: 1 0 auto; min-width: 58px; height: 54px; min-height: 54px; flex-direction: column; justify-content: center;
    gap: 4px; padding: 6px 6px 5px; border-radius: 16px; font-size: 10px; font-weight: 500;
  }
  .nav-label { max-width: 76px; }
  .navitem svg { width: 20px; height: 20px; }
  .sidebar .navitem.active::before { display: none; }
  .nav-alert-dot { position: absolute; top: 3px; right: calc(50% - 22px); margin: 0 !important; min-width: 17px; height: 17px; font-size: 9.5px; padding: 0 4px; }
  html[dir="rtl"] .nav-alert-dot { right: auto; left: calc(50% - 22px); }

  .topbar h1, h1 { font-size: 21px; }
  .section, .setup-card, .tier-section { padding: 16px; border-radius: var(--r-lg); }
  .co-head { padding: 18px; }
  .co-head::after { display: none; }
  .modal-box { border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .field input, .field select { height: 46px; font-size: 16px; }
  .field textarea { font-size: 16px; }
  .btn { height: 44px; }
  .btn.ghost { height: 36px; }
  .searchbar { width: 100%; height: 44px; }
  .searchbar input { font-size: 16px; }
  .tabbar { display: flex; }
  .att-row, .plan-row, .list-row, .alertrow { margin: 0 -8px; padding-inline: 8px; }
  .palette-overlay { padding-top: calc(10px + env(safe-area-inset-top)); }
  .palette-input { font-size: 16px; }
  .install-sheet { bottom: calc(90px + env(safe-area-inset-bottom)); }
}

@media (max-width: 640px) {
  .tab { width: auto; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) {
  .hdr-brand { display: none; }
}

/* v1.29.0 refinements */
.palette-input:focus, .palette-input:focus-visible { box-shadow: none !important; outline: none; }
.sidebar .navitem.active::before { inset-inline-start: 0; top: 11px; bottom: 11px; }
@media (min-width: 861px) {
  html.rail-collapsed .nav-group { padding: 0; height: 1px; margin: 10px 14px; }
}
/* The header keeps the same physical layout in Arabic, so the language switch
   and the account menu stay in the top-right corner in both languages. */
html[dir="rtl"] .app-header, html[dir="rtl"] .hdr-right { flex-direction: row-reverse; }
html[dir="rtl"] .usermenu-panel { inset-inline-end: auto; left: auto; right: 0; }
html[dir="rtl"] .login-topright { inset-inline-end: auto; left: auto; right: 24px; }
@media (max-width: 860px) {
  html[dir="rtl"] .login-topright { right: 16px; }
  html[dir="rtl"] .hdr-left { flex-direction: row-reverse; }
}
.field .combo-input, .combo-input-wrap input {
  height: 38px; border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; border-radius: 0;
}
.combo-input:focus-visible { box-shadow: none !important; }
.filter-input { width: 220px; }

/* =========================================================================
   v1.29.1 — Tab colours (Appearance → Tabs), report centre, report cards,
   Service calls. Tabs keep the house rule: one width each, and the selected
   tab fills with one colour while its text takes the contrasting colour.
   ========================================================================= */
:root {
  --tab-on-bg: var(--ink); --tab-on-fg: var(--ink-text); --tab-on-line: var(--ink);
  --tab-bar-bg: var(--panel-alt); --tab-bar-line: var(--border);
  --tab-fg: var(--text-muted); --tab-fg-hover: var(--text); --tab-hover-bg: var(--panel);
}
.tabbar { background: var(--tab-bar-bg); border-color: var(--tab-bar-line); }
.tab { color: var(--tab-fg); }
.tab:hover { color: var(--tab-fg-hover); background: var(--tab-hover-bg); border-color: var(--tab-bar-line); }
.tab.active, .tab.active:hover { background: var(--tab-on-bg); color: var(--tab-on-fg); border-color: var(--tab-on-line); }
.colchip.on, .colchip.on:hover { background: var(--tab-on-bg); color: var(--tab-on-fg); border-color: var(--tab-on-line); }
button.tab { font: inherit; font-size: 13px; font-weight: 500; }

/* Tab with a count (Service calls scope) */
.tabbar-counts .tab { gap: 8px; width: 168px; }
.tab-count {
  min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; font-family: 'IBM Plex Mono', monospace;
  background: color-mix(in srgb, currentColor 14%, transparent);
}
.tab-count.is-alert { background: var(--danger); color: #fff; }

/* Page titles with a line underneath */
.topbar-titles { min-width: 0; }
.page-sub { margin: 4px 0 0; color: var(--text-muted); font-size: 13.5px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Report centre ---------- */
.report-hub { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.hub-col {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px; box-shadow: var(--shadow-sm), var(--bevel); display: flex; flex-direction: column; gap: 12px;
}
.hub-head { display: flex; align-items: center; justify-content: space-between; }
.hub-head .tier-chip { font-size: 12px; padding: 5px 12px; }
.hub-list { display: flex; flex-direction: column; gap: 8px; }
.hub-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: start;
  border: 1px solid; border-radius: var(--r-md); color: var(--tier-ink); font: inherit; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.10), inset 0 -1px 0 rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.10);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.hub-item:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), inset 0 -1px 0 rgba(0,0,0,0.12), var(--shadow-md); }
.hub-item:active { transform: translateY(1px); box-shadow: inset 0 2px 3px rgba(0,0,0,0.18); }
.hub-item.tier-platinum { background: var(--tier-platinum); border-color: var(--tier-platinum-edge); }
.hub-item.tier-gold { background: var(--tier-gold); border-color: var(--tier-gold-edge); }
.hub-item.tier-silver { background: var(--tier-silver); border-color: var(--tier-silver-edge); }
.hub-item.is-active { background: var(--tab-on-bg); border-color: var(--tab-on-line); color: var(--tab-on-fg); }
.hub-item.is-active .hub-ico { background: color-mix(in srgb, var(--tab-on-fg) 14%, transparent); color: var(--tab-on-fg); border-color: transparent; }
.hub-item.is-active .hub-desc { opacity: 0.8; }
.hub-ico {
  width: 36px; height: 36px; flex: 0 0 auto; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--panel) 55%, transparent); border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
}
.hub-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hub-title { font-weight: 600; font-size: 13.5px; }
.hub-desc { font-size: 12px; opacity: 0.7; line-height: 1.35; }
.hub-num { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* Grey tier grades, re-toned (v1.29.1) to sit with the cards of every theme:
   flat steps of the card colour toward the text colour. */
:root[data-theme] {
  --tier-silver: color-mix(in srgb, var(--panel) 93%, var(--text));
  --tier-silver-edge: color-mix(in srgb, var(--panel) 85%, var(--text));
  --tier-gold: color-mix(in srgb, var(--panel) 88%, var(--text));
  --tier-gold-edge: color-mix(in srgb, var(--panel) 80%, var(--text));
  --tier-platinum: color-mix(in srgb, var(--panel) 82%, var(--text));
  --tier-platinum-edge: color-mix(in srgb, var(--panel) 74%, var(--text));
  --tier-ink: var(--text);
}
.tier-chip { box-shadow: var(--bevel-strong); }

/* ---------- Report card ---------- */
.report-card { padding: 0; overflow: hidden; }
.report-card > * { margin-inline: 22px; }
.report-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin: 0 !important; padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.report-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.report-title h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.012em; }
.report-title p { margin: 2px 0 0; color: var(--text-muted); font-size: 12.5px; }
.report-ico {
  width: 38px; height: 38px; border-radius: var(--r-md); flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-alt); border: 1px solid var(--border); color: var(--text-muted); box-shadow: var(--bevel);
}
.export-group { display: flex; gap: 8px; flex-wrap: wrap; }
.export-group .btn { height: 34px; padding: 0 12px; font-size: 13px; }

.report-filters {
  margin-top: 16px !important; margin-bottom: 0; padding: 10px; gap: 10px;
  background: var(--panel-alt); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.report-filters .tabbar { background: var(--tab-bar-bg); padding: 3px; }
.report-filters .filter-input, .report-filters .combo-input-wrap, .report-filters .datepicker-display { background: var(--input-bg); }
.filter-search {
  padding-inline-start: 36px !important; min-width: 240px; flex: 1 1 240px;
  background-repeat: no-repeat; background-position: 12px center; background-size: 16px 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238896A8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E");
}
html[dir="rtl"] .filter-search { background-position: calc(100% - 12px) center; }
.btn-reset { height: 36px; margin-inline-start: auto; }
.report-filters > .logout-link { margin-inline-start: auto; font-size: 12.5px; }

.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; margin-bottom: 10px; }
.table-count { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.table-count .result-count { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--text); }
.table-footnote { color: var(--text-dim); font-size: 12px; }
.btn-sm { height: 32px !important; padding: 0 10px !important; font-size: 12.5px !important; gap: 6px !important; }
.btn.is-on { border-color: var(--tab-on-line); }
.btn-count { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text-dim); }
.colpick {
  margin-bottom: 12px; padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--r-lg);
  background: var(--panel-alt); animation: dp-in 140ms var(--ease) both;
}
.colpick-links { display: inline-flex; gap: 14px; margin-inline-start: auto; font-size: 12.5px; }
.colpick .logout-link { margin: 0; }
.table-frame { border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: 22px; }
.report-card .table-frame, .report-card .empty { margin-bottom: 22px; }
.table-frame table.systable th { border-radius: 0 !important; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; }
.table-frame table.systable tr:last-child td { border-bottom: 0; }
.sortable { display: inline-flex; align-items: center; gap: 6px; }
.sort-mark { font-size: 8px; letter-spacing: -1px; opacity: 0.35; }
.sort-mark.on { opacity: 1; color: var(--text); }
.clickable-row { cursor: pointer; }
td.row-actions { text-align: end; white-space: nowrap; width: 1%; }
td.row-actions .btn.ghost { height: 30px; padding: 0 8px; gap: 4px; }
html[dir="rtl"] td.row-actions svg { transform: scaleX(-1); }
.ref-chip {
  display: inline-flex; padding: 2px 8px; border-radius: var(--r-sm); font-size: 12px;
  background: var(--panel-alt); border: 1px solid var(--border); color: var(--text);
}
.cell-strong { font-weight: 600; }
.badge-plain::before { display: none; }
.badge-plain { padding-inline: 10px; }

/* Appearance: tab group */
.ap-group { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; margin: 4px 0 14px; background: var(--panel-alt); }
.ap-group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ap-group-title { font-weight: 600; font-size: 13.5px; }
.ap-group-sub { color: var(--text-dim); font-size: 12px; }
.ap-tab-preview .tab, .ap-mode-switch .tab { width: 104px; height: 30px; font-size: 12.5px; }
.ap-tabrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ap-tabfield input[type="color"]:disabled { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 1100px) {
  .report-hub { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .report-card > * { margin-inline: 14px; }
  .report-head { padding: 14px; }
  .tabbar-counts .tab { width: auto; flex: 1 1 calc(50% - 4px); }
  .filter-search { min-width: 0; }
}
.report-filters .filter-input, .report-filters .combo-input-wrap, .report-filters .datepicker-display { background-color: var(--input-bg); }
.report-filters .tabbar { margin: 0 !important; }
.report-filters .filter-input, .report-filters select.filter-input { height: 38px; }
.report-filters .combo { width: 240px; }
.report-filters .combo-input-wrap { height: 38px; min-height: 38px; padding: 0 12px !important; display: flex; align-items: center; }
.report-filters .combo-input { height: 36px; padding: 0 !important; border: 0 !important; background: transparent !important; box-shadow: none !important; }
.report-filters .filter-date-group .datepicker-display { height: 38px; min-height: 38px; }
.combo-input-wrap svg { flex: 0 0 auto; }
.ref-chip { white-space: nowrap; }
.call-cards { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 16px; }
.call-card {
  padding: 14px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel-alt); cursor: pointer;
  box-shadow: var(--bevel);
}
.call-card:active { transform: translateY(1px); }
.call-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.call-card-subject { font-weight: 600; font-size: 14.5px; }
.call-card-meta { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
@media (max-width: 860px) {
  .filter-search { flex: 0 0 auto; height: 44px !important; width: 100%; }
  .report-filters { padding: 8px; }
}
@media (max-width: 640px) {
  .topbar-actions .export-group { display: none; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; }
}

/* =========================================================================
   v1.29.2 — one colour language, and a simple phone
   Rules used everywhere:
   · Accent (teal): the main action of a page, links and in-row actions only.
   · Ink: the selected tab or chip (colour set in Appearance → Tabs).
   · Grey: surfaces, tier grades, neutral statuses (Planned, New, Assigned).
   · Red / amber / green / blue: indicators only (overdue, due soon, on track, in progress).
   · One typeface for text and dates; monospace only for references and codes.
   ========================================================================= */
.mono, .date.mono, td.mono, .plan-date, .co-kicker, .setup-count, .setup-count-line, .att-kind,
.bar-chart .bar-label, .bar-chart .bar-count, .filter-date, .datepicker-display, .nav-alert-dot, .tab-count, .btn-count, .session-role {
  font-family: 'IBM Plex Sans', 'IBM Plex Sans Arabic', 'Tajawal', system-ui, sans-serif !important;
  font-variant-numeric: tabular-nums; letter-spacing: 0;
}
.ref-chip, code, pre, kbd, .cmdk-kbd, .version-pill { font-family: 'IBM Plex Mono', monospace !important; }
.co-kicker, .att-kind, .login-aside-kicker, .brand-sub { letter-spacing: 0.08em; }
.att-kind { font-size: 10.5px; font-weight: 600; }

/* Statuses */
.badge-info { background: var(--info-soft, var(--panel-alt)); color: var(--info, var(--text-muted)); border-color: color-mix(in srgb, var(--info, #6AA9F0) 30%, transparent); }

/* In-row actions: one style. Strong = the main thing to do, muted = Cancel. */
.btn.ghost { color: var(--accent-text); font-weight: 500; }
.btn.ghost.is-strong { font-weight: 600; }
.btn.ghost.is-muted { color: var(--text-muted); }
.btn.ghost.is-muted:hover { background: var(--panel-alt); color: var(--text); }
td.row-actions .btn.ghost { height: 30px; padding: 0 8px; }

/* Report centre: the open report is marked with a ring of the tab colour,
   so it reads as selected without a bright block in the middle of the page. */
.hub-item.is-active {
  background: var(--tier-platinum); color: var(--tier-ink); border-color: var(--tab-on-bg);
  box-shadow: 0 0 0 2px var(--tab-on-bg), var(--shadow-md);
}
.hub-item.tier-gold.is-active { background: var(--tier-gold); }
.hub-item.tier-silver.is-active { background: var(--tier-silver); }
.hub-item.is-active .hub-ico { background: var(--tab-on-bg); color: var(--tab-on-fg); border-color: transparent; }
.hub-item.is-active .hub-desc { opacity: 0.7; }

/* Same quiet grey for every secondary surface inside a card */
.co-head, .kpi, .section, .hub-col, .setup-card { background: var(--panel); }
.report-filters, .colpick, .permlist, .ap-group { background: var(--panel-alt); }

/* ---------- Phone and small tablet ---------- */
.m-list-title { font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 18px 2px 8px; letter-spacing: 0; text-transform: none; }
.m-list { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.m-item { display: flex; align-items: center; gap: 12px; padding: 14px; border-top: 1px solid var(--border); color: var(--text); }
.m-item:first-child { border-top: 0; }
.m-item[role="button"] { cursor: pointer; }
.m-item[role="button"]:active { background: var(--panel-alt); }
.m-item > svg { color: var(--text-dim); flex: 0 0 auto; }
html[dir="rtl"] .m-item > svg { transform: scaleX(-1); }
.m-item-main { flex: 1; min-width: 0; }
.m-item-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-item-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-item-badge { margin-top: 8px; }
.m-item .btn-sm { flex: 0 0 auto; height: 36px !important; }

.sheet-list { display: flex; flex-direction: column; }
.sheet-item {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 54px; padding: 0 6px; border: 0; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text); font: inherit; font-size: 15px; font-weight: 500; text-align: start;
}
.sheet-item:last-child { border-bottom: 0; }
.sheet-item > svg:last-child { margin-inline-start: auto; color: var(--text-dim); }
html[dir="rtl"] .sheet-item > svg:last-child { transform: scaleX(-1); }
.sheet-item.is-danger { color: var(--danger); }
.sheet-ico {
  width: 38px; height: 38px; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  background: var(--panel-alt); border: 1px solid var(--border); color: var(--text-muted);
}
.sheet-item.is-danger .sheet-ico { color: var(--danger); }
.sheet-sep { height: 10px; }
.sheet-sig { margin-top: 14px; text-align: center; color: var(--text-dim); font-size: 11px; }
.sheet-sig a { color: inherit; }

@media (max-width: 860px) {
  /* Header: name on the left; language and account on the right. Nothing else. */
  .cmdk-trigger { display: none !important; }
  .app-header { height: calc(54px + env(safe-area-inset-top)); padding-inline: 14px; }
  .hdr-brand { max-width: 46vw; }

  /* Five fixed places, no scrolling */
  .sidebar { left: 0; right: 0; bottom: 0; border-radius: 0; border: 0 !important; border-top: 1px solid var(--rail-line) !important;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(0,0,0,0.18); }
  .navlist { display: grid; grid-template-columns: repeat(5, 1fr); overflow: visible; gap: 0; }
  .navitem { min-width: 0; width: auto; height: 56px; min-height: 56px; border-radius: 14px; padding: 6px 2px; font-size: 11px; gap: 3px; }
  .navitem svg { width: 22px; height: 22px; }
  .nav-label { max-width: 100%; }
  .sidebar .navitem.active { background: transparent; box-shadow: none; color: var(--rail-text); }
  .sidebar .navitem.active .nav-ico { background: var(--rail-active); border-radius: 999px; padding: 2px 14px; box-shadow: var(--bevel-strong); }
  .nav-new { align-items: center; justify-content: center; }
  .nav-new-btn {
    width: 50px; height: 50px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent); color: var(--accent-ink); box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 6px 16px rgba(0,0,0,0.28);
  }
  .nav-new:active .nav-new-btn { transform: scale(0.96); }
  .nav-alert-dot { top: 2px; right: calc(50% - 24px); }
  html[dir="rtl"] .nav-alert-dot { left: calc(50% - 24px); right: auto; }
  .main { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
  .install-sheet { bottom: calc(80px + env(safe-area-inset-bottom)); }

  /* Pages are flat on a phone: no card inside a card */
  .report-card { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .report-card > * { margin-inline: 0; }
  .report-filters { background: transparent; border: 0; padding: 0; margin-top: 0 !important; }
  .report-filters .tabbar { display: flex; flex-wrap: nowrap; overflow-x: auto; width: 100%; scrollbar-width: none; }
  .report-filters .tabbar::-webkit-scrollbar { display: none; }
  .tabbar-counts .tab { flex: 0 0 auto; width: auto; padding: 0 12px; }
  .call-cards { margin-top: 12px; }
  .topbar { margin-bottom: 14px; }
  .topbar .date { display: none; }
  .page-sub { display: none; }
  .modal-box .modal-head { margin-bottom: 8px; }
}
@media (max-width: 640px) {
  .export-group { display: none !important; }
  .topbar-actions .btn { height: 44px; }
  #customer-list-section { padding: 0 14px; }
}
@media (max-width: 640px) {
  /* The + in the bottom menu starts a call or a visit, so pages don't repeat it */
  .topbar-actions { display: none; }
}
/* A table cell must stay a table cell, or its row line breaks */
table.systable td.sysname { display: table-cell; white-space: nowrap; }
table.systable td.sysname svg { vertical-align: -3px; margin-inline-end: 8px; }

/* =========================================================================
   v1.29.3 — colours follow the menu colour; no stray italics
   ========================================================================= */
/* Form controls never inherit or synthesise an italic face */
button, input, select, textarea, option, .btn, .tab, .colchip, .lang-switch button, .cmdk-kbd, ::placeholder {
  font-style: normal !important; font-synthesis: none;
}

/* Language switch and avatar use the same ink as the selected tab */
.lang-switch { --ls-on-bg: var(--tab-on-bg); --ls-on-fg: var(--tab-on-fg); }
.hdr-right .lang-switch { --ls-on-bg: var(--tab-on-bg); --ls-on-fg: var(--tab-on-fg); }
.user-chip .avatar, .avatar { background: var(--tab-on-bg); color: var(--tab-on-fg); }
.co-logo-empty { background: var(--tab-on-bg); color: var(--tab-on-fg); }

/* Lighter, calmer tier grades on the light side; the dark side keeps its steps */
:root[data-theme="light"] {
  --tier-silver: color-mix(in srgb, var(--panel) 97%, var(--text));
  --tier-silver-edge: color-mix(in srgb, var(--panel) 88%, var(--text));
  --tier-gold: color-mix(in srgb, var(--panel) 95%, var(--text));
  --tier-gold-edge: color-mix(in srgb, var(--panel) 86%, var(--text));
  --tier-platinum: color-mix(in srgb, var(--panel) 93%, var(--text));
  --tier-platinum-edge: color-mix(in srgb, var(--panel) 84%, var(--text));
}
:root[data-theme="light"] .hub-item { box-shadow: inset 0 1px 0 rgba(255,255,255,0.9), 0 1px 2px rgba(16,24,40,0.06); }
.hub-item .hub-ico { background: var(--panel); }
.hub-item.is-active { box-shadow: 0 0 0 2px var(--tab-on-bg), var(--shadow-sm); }
.tier-chip { background: var(--panel-alt) !important; border-color: var(--border) !important; color: var(--text) !important; }
/* The active menu item is marked in the menu's own text colour, never the accent on top of the menu colour */
.sidebar .navitem.active .nav-ico { color: var(--rail-text); }
.sidebar .navitem.active::before { background: var(--rail-text); }
/* v1.29.4: the colour box always shows the real colour; picking a colour switches to Custom */
.ap-tabfield input[type="color"], .ap-tabfield input[type="color"]:disabled { opacity: 1; cursor: pointer; width: 52px; height: 36px; }
.ap-tabhint { color: var(--text-dim); font-size: 12px; }

/* v1.30.0 — Daily backup card */
.ab-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; align-items: end; }
.ab-switch .tab { width: 90px; }
.ab-quick { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 16px; }
.ab-status {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-bottom: 16px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
}
.ab-status > div { background: var(--panel-alt); padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.ab-status span { color: var(--text-dim); font-size: 12px; }
.ab-status strong { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ab-notice { background: var(--ok-soft, var(--panel-alt)); color: var(--ok, var(--text)); border: 1px solid color-mix(in srgb, var(--ok, #4CC38A) 30%, transparent); padding: 10px 12px; border-radius: var(--r-md); margin-bottom: 14px; font-size: 13px; }
.ab-files-head { margin: 22px 0 10px; font-weight: 600; font-size: 14px; }
.ab-files-head span { color: var(--text-dim); font-weight: 400; font-size: 12px; margin-inline-start: 6px; }
.ab-foot { color: var(--text-dim); font-size: 12px; line-height: 1.6; margin: 4px 0 0; }
#autobackup-section .table-frame { margin-bottom: 12px; }
@media (max-width: 860px) {
  .ab-grid, .ab-status { grid-template-columns: 1fr; }
  #autobackup-section .report-head { margin: -16px -16px 16px !important; padding: 14px 16px; }
}
@media (max-width: 640px) {
  #autobackup-section table th:nth-child(2), #autobackup-section table td:nth-child(2) { display: none; }
}

/* v1.31.0 — Role profiles */
.rp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.rp-card {
  display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--r-lg); background: var(--panel-alt); box-shadow: var(--bevel);
}
.rp-card.is-locked { background: var(--panel); border-style: dashed; }
.rp-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.rp-name { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rp-desc { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; line-height: 1.45; }
.rp-count { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; flex: 0 0 auto; }
.rp-count strong { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rp-count span { font-size: 11px; color: var(--text-dim); }
.rp-groups { display: flex; flex-wrap: wrap; gap: 6px; }
.rp-group { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); color: var(--text-muted); }
.rp-group b { font-weight: 600; color: var(--text); margin-inline-start: 2px; font-variant-numeric: tabular-nums; }
.rp-group.is-all { border-color: var(--tab-on-bg); }
.rp-group.is-none { opacity: 0.6; }
.rp-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; }
.rp-users { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12.5px; }
.rp-actions { display: inline-flex; gap: 2px; }
.rp-actions .btn.ghost { height: 30px; padding: 0 8px; }
.rp-summary { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 12px; }
.rp-allow { color: var(--text-dim); margin-inline-end: 2px; }
.rp-chip { padding: 2px 8px; border-radius: 999px; background: var(--panel-alt); border: 1px solid var(--border); color: var(--text-muted); }
.modal-box.modal-wide { width: 640px; }
.rp-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rp-edgroup { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px 12px; background: var(--panel-alt); }
.rp-edhead { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.rp-edhead strong { font-size: 13px; }
.rp-edall .btn.ghost { height: 26px; padding: 0 6px; font-size: 12px; }
.rp-perm { display: flex; align-items: flex-start; gap: 9px; padding: 6px 0; font-size: 13px; color: var(--text); cursor: pointer; line-height: 1.4; }
.rp-perm input { margin-top: 2px; width: 16px; height: 16px; flex: 0 0 auto; accent-color: var(--tab-on-bg); }
.rp-perm input:disabled + span { color: var(--text-muted); }
@media (max-width: 860px) {
  .rp-editor { grid-template-columns: 1fr; }
  #roles-section .report-head { margin: -16px -16px 16px !important; padding: 14px 16px; }
}

/* v1.32.0 — additional role profiles on a user */
.rp-extras { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.rp-extra {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--panel-alt); cursor: pointer; font-size: 13px;
}
.rp-extra input { width: 16px; height: 16px; accent-color: var(--tab-on-bg); flex: 0 0 auto; }
.rp-extra span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-extra small { color: var(--text-dim); font-size: 11px; }
.rp-extra:has(input:checked) { border-color: var(--tab-on-bg); background: var(--panel); }
.rp-extra.is-main { opacity: 0.6; cursor: default; }
.rp-hint { color: var(--text-dim); font-size: 12px; margin-top: 6px; }
.rp-plus { margin-top: 3px; }
.field label.rp-extra { display: flex; margin: 0; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); font-weight: 500; }
.field label.rp-extra small { margin-inline-start: auto; }

/* Licence page, banner and locked screen (v1.33.0) - flat, no gradients. BY NEPTUNE UAE */
.lic-banner { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 14px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); font-size: 13px; line-height: 1.45; }
.lic-banner a { color: inherit; font-weight: 600; margin-inline-start: 6px; }
.lic-dot { flex: none; width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--accent); }
.lic-warn .lic-dot { background: var(--amber); }
.lic-danger { border-color: var(--danger); }
.lic-danger .lic-dot { background: var(--danger); }
.lic-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin: 0 0 14px; }
.lic-card h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 16px; }
.lic-card h3 { margin: 16px 0 8px; font-size: 14px; }
.lic-card p { margin: 0 0 10px; }
.lic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.lic-grid .lic-card { margin: 0; }
.lic-dl { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 6px 14px; margin: 0 0 10px; font-size: 13px; }
.lic-dl dt { color: var(--text-dim); }
.lic-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.lic-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.lic-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.lic-row:first-of-type { border-top: 0; }
.lic-row.lic-col { flex-direction: column; align-items: stretch; }
.lic-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border); font-size: 11px; font-weight: 600; white-space: nowrap; }
.lic-pill.lic-ok { color: #1f9d55; border-color: #1f9d55; }
.lic-pill.lic-warn { color: var(--amber); border-color: var(--amber); }
.lic-pill.lic-danger { color: var(--danger); border-color: var(--danger); }
.lic-small { color: var(--text-dim); font-size: 12px; }
.lic-note { padding: 10px 14px; border-radius: 10px; margin: 0 0 14px; font-size: 13px; border: 1px solid var(--border); }
.lic-note.ok { border-color: #1f9d55; }
.lic-note.bad { border-color: var(--danger); }
.lic-card textarea { width: 100%; min-height: 96px; box-sizing: border-box; margin: 0 0 10px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.lic-card textarea.lic-plain { min-height: 60px; font-family: inherit; font-size: 13px; }
.lic-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 0 0 8px; }
.lic-form input, .lic-form select { width: 100%; box-sizing: border-box; }
.lic-sig { text-align: center; color: var(--text-dim); font-size: 11px; margin: 18px 0 8px; }
.lic-sig a { color: inherit; }
@media (max-width: 600px) { .lic-dl { grid-template-columns: 1fr; gap: 0; } .lic-dl dt { margin-top: 8px; } .lic-card { padding: 14px; } }

/* ================= 1.33.3: NEPTUNE artwork, start-up animation and phone extras - BY NEPTUNE UAE (https://neptuneuae.net) ================= */
.brand-mark.is-nep { background: transparent !important; padding: 0 !important; overflow: hidden; box-shadow: 0 2px 8px -2px rgba(0,0,0,.45); }
.brand-mark.is-nep img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.app-splash img#splash-logo { border-radius: 22%; max-width: 132px; max-height: 132px; animation: splash-pop .8s cubic-bezier(.2,.9,.3,1.2) both; box-shadow: 0 14px 34px -10px rgba(0,0,0,.55); }
.app-splash-name { animation: splash-fade .8s ease-out .5s both; }
@keyframes splash-pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }
@keyframes splash-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
html.is-nep-app, html.is-nep-app body { overscroll-behavior-y: contain; -webkit-tap-highlight-color: transparent; }
html.is-nep-app a, html.is-nep-app button { -webkit-touch-callout: none; }
.bio-box { display: grid; gap: 6px; margin-top: 12px; }
.bio-box[hidden] { display: none; }
.bio-forget { border: 0; background: none; color: var(--text-muted); font: inherit; font-size: 12.5px; text-decoration: underline; cursor: pointer; padding: 6px; }
@media (max-width: 860px) {
  html.kb-open .sidebar { display: none; }
  html.kb-open .main { padding-bottom: 24px; }
  .app-header { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .main { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
  .sidebar { left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); }
}
@media (min-width: 861px) and (max-width: 1180px) and (pointer: coarse) {
  .btn, .navitem, .tab { min-height: 44px; }
  .field input, .field select { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .app-splash img#splash-logo, .app-splash-name { animation: none !important; } }

/* 2.0.3: phone dashboard actions (Maintenance 2.10.2) - Log Visit and Log a Call side by side, thumb height.
   Flat fills, no gradient. A permission the user lacks leaves the other button the full width. BY NEPTUNE UAE */
.m-actions { display: flex; gap: 10px; margin: 4px 0 6px; }
.m-action { flex: 1 1 0; min-height: 52px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-weight: 600; white-space: nowrap; color: #fff !important; border: 0; border-radius: 12px; }
.m-action-visit { background: #2b6cb0; }
.m-action-call { background: #2f855a; }
@media (max-width: 340px) { .m-action { font-size: 14px; gap: 6px; } }
