@import url('fonts/roboto.css');

/* ================================================================
   RegiFortis Admin + tenant pages — TABLER-style light theme.
   Clean "developer-grade" flat UI: white sidebar + white cards
   defined by THIN visible borders (not heavy shadows), a small
   4-6px radius (Tabler's signature), a crisp #066fd1 blue accent,
   and Tabler-style active nav (left accent bar, not a filled pill).
   Loaded after brand.css; overrides its dark tokens & components.
   The marketing landing (index.html) never loads this file.
   Font note: Tabler ships Inter; we reuse the locally-hosted Roboto
   for now (swap-in of a self-hosted Inter is a one-file change).
   ================================================================ */

:root {
  color-scheme: light;

  /* surfaces — cool light canvas (deepened a touch so white cards pop), white cards */
  --page: #e7ebf2;                 /* app canvas — darker than Tabler's #f5f7fb */
  --bg-0: #e7ebf2;
  --bg-1: #eff2f8;
  --card: #ffffff;
  --card-soft: #eef1f7;
  --card-brd: #e3e6ec;             /* Tabler thin border — the star of the look */
  --card-brd-hi: #cddcf3;
  --surface: #ffffff;              /* chart dot strokes (read by monitor JS) */

  /* brand — Tabler blue (primary) + indigo (secondary accent) */
  --brand-1: #066fd1;
  --brand-2: #4263eb;
  --brand-3: #17a2b8;
  --brand-soft: #eaf2fc;           /* active nav wash */
  --grad: linear-gradient(135deg, #066fd1 0%, #4263eb 100%);
  --glow: 0 2px 6px rgba(6, 111, 209, 0.20);

  /* text — Tabler ink scale */
  --ink: #1a2234;                  /* headings / strong */
  --ink-2: #45516b;                /* body */
  --muted: #656d77;                /* labels / hints / placeholder (Tabler secondary) */

  /* chart plumbing (consumed by monitor/resources JS via getComputedStyle) */
  --grid: #e3e6ec;
  --s1: #066fd1;  --s2: #2fb344;  --s3: #ae3ec9;  --s4: #f76707;
  --s-cpu: #066fd1;  --s-mem: #2fb344;  --s-disk: #ae3ec9;  --s-load: #f76707;

  /* status (Tabler) */
  --ok: #2fb344;
  --bad: #d63939;

  /* legacy neon var names still referenced by a couple of pages */
  --neon-cyan: #066fd1;
  --neon-magenta: #ae3ec9;
  --neon-lime: #2fb344;
  --neon-amber: #f59f00;

  --radius: 6px;

  /* squares — faint grid drawn on the page canvas (shows between the white cards) */
  --grid-line: rgba(24, 36, 51, 0.055);
  --grid-size: 32px;

  /* Tabler shadows: whisper-soft — the border carries the definition */
  --shadow-sm: 0 1px 2px 0 rgba(24, 36, 51, 0.05);
  --shadow-md: 0 1px 1px 0 rgba(24, 36, 51, 0.04), 0 2px 6px 0 rgba(24, 36, 51, 0.06);
  --shadow-lg: 0 8px 24px 0 rgba(24, 36, 51, 0.14);
  --shadow-side: 0 0 0 0 rgba(0, 0, 0, 0);
}

/* ---- page canvas: cool gray with a faint squares grid --------- */
body {
  background-color: var(--page); color: var(--ink-2);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  background-position: -1px -1px;
  background-attachment: fixed;
  font-family: "Roboto", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.9rem;
}
body::before, body::after { content: none !important; display: none !important; }

/* ---- headings / brand ----------------------------------------- */
h1 { color: var(--ink); text-shadow: none; font-weight: 600; letter-spacing: -0.01em; }
h2 { color: var(--ink); font-weight: 600; }
.brand { color: var(--ink); text-shadow: none; }
.brand .logo { background: var(--grad); box-shadow: none; border-radius: var(--radius); animation: none; }
/* Real RegiFortis logo (self-hosted SVG) — sits on its own, no gradient box */
.brand-logo { width: 30px; height: 30px; display: block; flex: 0 0 auto; }
.powered .brand-logo { width: 20px; height: 20px; }

/* ---- sidebar (white, flat, border-defined) -------------------- */
.sidebar {
  flex-basis: 260px; width: 260px;
  background: #ffffff; border-right: 1px solid var(--card-brd);
  box-shadow: var(--shadow-side);
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.sidebar .brand { padding-bottom: 1.1rem; margin-bottom: 0.9rem; border-bottom: 1px solid var(--card-brd); }
.side-nav a {
  color: var(--ink-2); font-weight: 500; font-size: 0.9rem;
  border-radius: var(--radius); padding: 0.62rem 0.8rem;
}
.side-nav a:hover { background: #f2f5fa; color: var(--ink); }
/* Tabler active: soft wash + primary text + inset left accent bar */
.side-nav a.active {
  background: var(--brand-soft); color: var(--brand-1); font-weight: 600;
  box-shadow: inset 3px 0 0 0 var(--brand-1); animation: none;
}
.side-foot a { color: var(--muted); }
.side-foot a:hover { color: var(--bad); background: #fdf1f1; }
/* Unread counter pill on a nav item (e.g. Support) */
.nav-badge { float: right; min-width: 18px; text-align: center; padding: 0.02rem 0.38rem;
  border-radius: 999px; background: var(--bad); color: #fff; font-size: 0.7rem; font-weight: 700; }

/* ---- Live-chat pop-up notifications (platform-wide toasts) ------- */
/* Sits above the floating chat launcher (bottom-right) so the two never overlap. */
#rf-toasts { position: fixed; right: 20px; bottom: 90px; z-index: 9999;
  display: flex; flex-direction: column; gap: 0.55rem; max-width: min(360px, calc(100vw - 40px)); }
.rf-toast { display: flex; gap: 0.6rem; align-items: flex-start; cursor: pointer;
  background: var(--card); color: var(--ink-2); border: 1px solid var(--card-brd);
  border-left: 3px solid var(--brand-1); border-radius: 12px; padding: 0.7rem 0.85rem;
  box-shadow: var(--shadow-md); text-decoration: none;
  animation: rf-toast-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); transition: opacity 0.35s ease, transform 0.35s ease; }
.rf-toast.out { opacity: 0; transform: translateX(20px); }
.rf-toast .ic { font-size: 1.05rem; line-height: 1.3; }
.rf-toast .tx { min-width: 0; }
.rf-toast .nm { font-weight: 700; color: var(--ink); font-size: 0.82rem; }
.rf-toast .bd { font-size: 0.84rem; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.rf-toast .cl { margin-left: auto; color: var(--muted); font-weight: 700; font-size: 0.95rem; padding: 0 0.15rem; }
.rf-toast .cl:hover { color: var(--ink); }
@keyframes rf-toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ---- Floating Live-chat widget (launcher + pop-up panel, all admin pages) ---- */
#rf-chat-fab { position: fixed; right: 20px; bottom: 20px; z-index: 9998;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer; padding: 0;
  background: var(--brand-1); color: #fff; box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center; line-height: 1;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease; }
#rf-chat-fab:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(24, 36, 51, 0.22); }
#rf-chat-fab .fab-ic { font-size: 1.5rem; }
#rf-chat-fab .fab-open { display: block; }
#rf-chat-fab .fab-close { display: none; }
#rf-chat-fab.open .fab-open { display: none; }
#rf-chat-fab.open .fab-close { display: block; }
.rf-fab-badge { position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 999px; background: var(--bad); color: #fff;
  font-size: 0.72rem; font-weight: 700; align-items: center; justify-content: center;
  border: 2px solid var(--card-soft); display: none; }
.rf-fab-badge.show { display: flex; }

#rf-chat-panel { position: fixed; right: 20px; bottom: 88px; z-index: 9998;
  width: min(384px, calc(100vw - 40px)); height: min(560px, calc(100vh - 132px));
  background: var(--card); border: 1px solid var(--card-brd); border-radius: 16px;
  box-shadow: var(--shadow-md); overflow: hidden; display: none;
  flex-direction: column; animation: rf-toast-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1); }
#rf-chat-panel.open { display: flex; }
.rf-cp-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--card-brd); background: var(--card-soft); }
.rf-cp-title { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.rf-cp-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: 0 0 auto;
  box-shadow: 0 0 0 0 rgba(52, 179, 68, 0.5); animation: lp 1.8s infinite; }
@keyframes lp { 0% { box-shadow: 0 0 0 0 rgba(52, 179, 68, 0.45); } 70% { box-shadow: 0 0 0 7px rgba(52, 179, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 179, 68, 0); } }
.rf-cp-h1 { font-weight: 700; color: var(--ink); font-size: 0.92rem; line-height: 1.1; }
.rf-cp-online { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 210px; margin-top: 0.1rem; }
.rf-cp-actions { display: flex; align-items: center; gap: 0.3rem; flex: 0 0 auto; }
.rf-cp-actions .ic-btn { display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; text-decoration: none;
  color: var(--muted); font-size: 0.95rem; border: 1px solid transparent; background: none; padding: 0; }
.rf-cp-actions .ic-btn:hover { color: var(--brand-1); border-color: var(--card-brd); }
.rf-cp-actions .ic-btn.on { color: var(--brand-1); }
.rf-cp-msgs { flex: 1; overflow-y: auto; padding: 0.85rem; display: flex; flex-direction: column; gap: 0.5rem; }
.rf-cp-msgs .rf-cp-empty { margin: auto; color: var(--muted); font-size: 0.85rem; text-align: center; }
.rf-cp-daysep { align-self: center; font-size: 0.68rem; color: var(--muted); background: var(--card-soft);
  border: 1px solid var(--card-brd); border-radius: 999px; padding: 0.08rem 0.6rem; }
.rf-cp-m { max-width: 82%; display: flex; flex-direction: column; gap: 0.15rem; }
.rf-cp-m.me { align-self: flex-end; align-items: flex-end; }
.rf-cp-m .meta { font-size: 0.66rem; color: var(--muted); padding: 0 0.25rem; }
.rf-cp-m .bub { padding: 0.45rem 0.7rem; border-radius: 13px; background: var(--card-soft);
  border: 1px solid var(--card-brd); color: var(--ink-2); font-size: 0.88rem; line-height: 1.4;
  white-space: pre-wrap; word-break: break-word; }
.rf-cp-m.me .bub { background: var(--brand-1); color: #fff; border-color: var(--brand-1); }
.rf-cp-composer { display: flex; gap: 0.5rem; align-items: flex-end; padding: 0.6rem 0.7rem;
  border-top: 1px solid var(--card-brd); background: var(--card-soft); }
.rf-cp-composer textarea { flex: 1; min-height: 38px; max-height: 120px; resize: none; margin: 0;
  padding: 0.5rem 0.65rem; font-size: 0.88rem; line-height: 1.35; }
.rf-cp-composer button { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px; padding: 0;
  font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; }
.rf-cp-status { font-size: 0.74rem; color: var(--muted); text-align: center; }
.rf-cp-status:not(:empty) { padding: 0.3rem 0.9rem 0.5rem; }

/* New-message preview that emerges from the launcher (replaces corner toasts). */
#rf-chat-peek { position: fixed; right: 20px; bottom: 88px; z-index: 9998; cursor: pointer;
  width: min(320px, calc(100vw - 40px)); background: var(--card); color: var(--ink-2);
  border: 1px solid var(--card-brd); border-left: 3px solid var(--brand-1);
  border-radius: 14px; box-shadow: var(--shadow-md); overflow: hidden; display: none; }
#rf-chat-peek.show { display: block; animation: rf-toast-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); }
#rf-chat-peek .pk-head { display: flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--card-brd); background: var(--card-soft); }
#rf-chat-peek .pk-title { display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.75rem; font-weight: 700; color: var(--ink); }
#rf-chat-peek .pk-close { margin-left: auto; color: var(--muted); font-weight: 700;
  font-size: 1rem; line-height: 1; padding: 0 0.15rem; }
#rf-chat-peek .pk-close:hover { color: var(--ink); }
#rf-chat-peek .pk-rows { padding: 0.25rem; display: flex; flex-direction: column; }
#rf-chat-peek .pk-row { padding: 0.4rem 0.5rem; border-radius: 9px; }
#rf-chat-peek .pk-row + .pk-row { border-top: 1px solid var(--card-brd); }
#rf-chat-peek .pk-name { font-size: 0.78rem; font-weight: 700; color: var(--ink); }
#rf-chat-peek .pk-body { font-size: 0.82rem; color: var(--ink-2); margin-top: 0.1rem; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#rf-chat-peek .pk-more { padding: 0.25rem 0.55rem 0.45rem; font-size: 0.72rem; color: var(--muted); }

/* Attention pulse on the launcher when a new message arrives. */
#rf-chat-fab.ping { animation: rf-fab-ping 0.9s ease; }
@keyframes rf-fab-ping {
  0%, 100% { transform: none; }
  15% { transform: translateY(-4px) scale(1.06); }
  40% { transform: translateY(0) scale(0.98); }
  65% { transform: translateY(-2px) scale(1.03); }
}

@media (max-width: 560px) {
  #rf-chat-panel { right: 12px; left: 12px; width: auto; bottom: 84px; height: min(70vh, calc(100vh - 120px)); }
  #rf-chat-fab { right: 14px; bottom: 14px; }
  #rf-chat-peek { right: 12px; left: 12px; width: auto; bottom: 80px; }
}

/* ---- cards & tiles (white, THIN border, minimal shadow) ------- */
.card, .tile {
  background: var(--card); border: 1px solid var(--card-brd);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.card::before { content: none; }
.card:hover, .tile:hover { border-color: #cfd6e2; box-shadow: var(--shadow-md); }
.newlink { box-shadow: none; border-color: var(--card-brd-hi); }
.tile { position: relative; overflow: hidden; }
.tile::before { background: var(--brand-1); box-shadow: none; }
.tile .label { color: var(--muted); font-family: inherit; text-shadow: none; letter-spacing: 0.02em; font-weight: 600; text-transform: uppercase; font-size: 0.72rem; }
.tile .value { color: var(--ink); text-shadow: none; }

/* ---- buttons (Tabler solids: crisp, small radius) ------------- */
button, .btn {
  color: #fff; background: var(--brand-1);
  border-radius: var(--radius); font-weight: 600; font-size: 0.88rem;
  box-shadow: none;
}
button:hover, .btn:hover { background: #0561ba; box-shadow: none; }
.btn-ghost, button.mini, .btnlike, .kebab, .icon-btn {
  background: #ffffff; color: var(--ink-2);
  border: 1px solid var(--card-brd); box-shadow: none;
}
.btn-ghost:hover, button.mini:hover, .btnlike:hover, .kebab:hover, .icon-btn:hover {
  background: #f2f5fa; border-color: #cfd6e2; color: var(--brand-1); box-shadow: none; transform: none;
}
.kebab.on { background: var(--brand-1); color: #fff; border-color: transparent; box-shadow: none; animation: none; }
button.danger, .btn-danger { background: #fceded; color: var(--bad); border: 1px solid #f4c9c9; box-shadow: none; }
button.danger:hover, .btn-danger:hover { background: #f8dede; box-shadow: none; }

/* ---- forms ---------------------------------------------------- */
label { color: var(--ink-2); font-weight: 500; }
input[type=text], input[type=email], input[type=password], input:not([type]),
select, textarea {
  background: #ffffff; border: 1px solid var(--card-brd); color: var(--ink);
  border-radius: var(--radius);
}
input::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-1); box-shadow: 0 0 0 3px rgba(6, 111, 209, 0.16);
}
select option { background: #ffffff; color: var(--ink); }

/* ---- tables --------------------------------------------------- */
th {
  color: var(--muted); font-family: inherit; letter-spacing: 0.02em;
  text-transform: uppercase; font-size: 0.72rem; font-weight: 700;
}
th, td { border-bottom: 1px solid var(--card-brd); }
td.name { color: var(--ink); }
table tr:hover td { background: #f6f8fc; }
tr.total td { border-top: 2px solid #d3d9e4; }
tr.edit-row td { background: #f6f8fc; }
code { background: #eef3fb; color: #0561ba; border: 1px solid var(--card-brd); }

/* ---- usage / limit bars --------------------------------------- */
.use-track { background: #eaeef5; }
.use-val { color: var(--ink); }
.use-fill { background: var(--brand-1); }

/* ---- filters (range switch / tenant picker) ------------------- */
.filters a { background: #ffffff; color: var(--ink-2); border: 1px solid var(--card-brd); border-radius: var(--radius); }
.filters a:hover { background: #f2f5fa; color: var(--brand-1); }
.filters a.active { background: var(--brand-1); color: #fff; border-color: transparent; box-shadow: none; animation: none; }

/* ---- flashes / callouts --------------------------------------- */
.flash.ok { background: #e8f7ec; color: #1c7a34; border-color: #bce6c6; }
.flash.bad, .error { background: #fceded; color: #b52b2b; border-color: #f4c9c9; }
.welcome { background: var(--brand-soft); border-color: var(--card-brd-hi); }
.welcome strong { color: var(--brand-1); }

/* ---- links / misc --------------------------------------------- */
.tenant-url { color: var(--brand-1); background: #eef3fb; }
.linklike, .back, summary { color: var(--brand-1); }
.muted, .note, .hint, .empty { color: var(--muted); }

/* ---- row action menu (kebab dropdown) ------------------------- */
.menu {
  background: #ffffff; border: 1px solid var(--card-brd); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.menu a, .menu button { color: var(--ink-2); background: transparent; box-shadow: none; }
.menu a:hover, .menu button:hover { background: #f2f5fa; color: var(--brand-1); box-shadow: none; }
.menu .menu-head { color: var(--muted); }
.menu .sep { background: var(--card-brd); }
.menu .danger-item { color: var(--bad); }
.menu .danger-item:hover { background: #fceded; color: var(--bad); }

/* ---- side drawer ---------------------------------------------- */
.drawer-backdrop { background: rgba(26, 34, 52, 0.42); }
.drawer-panel { background: #ffffff; border-left: 1px solid var(--card-brd); box-shadow: var(--shadow-lg); }
.drawer-head { background: #f6f8fc; border-bottom: 1px solid var(--card-brd); }
.drawer-frame { background: #ffffff; }

/* ---- centered modal ------------------------------------------- */
.modal-backdrop { background: rgba(26, 34, 52, 0.42); }
.modal-box { background: #ffffff; border: 1px solid var(--card-brd); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.modal-head { border-bottom: 1px solid var(--card-brd); }
.pm-frame { background: #ffffff; }
.kv > div > span:first-child { color: var(--muted); }

/* ---- tooltip (charts) — light card ---------------------------- */
.tooltip {
  background: #ffffff; border: 1px solid var(--card-brd); color: var(--ink);
  box-shadow: var(--shadow-lg); border-radius: var(--radius);
}
.tooltip .tv { color: var(--ink); }
.tooltip .tl { color: var(--ink-2); }
.tooltip .tt { color: var(--muted); }

/* ---- scrollbars ----------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: #c3cbd9 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c3cbd9; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #a6b0c2; }

/* ---- subtle, calm motion -------------------------------------- */
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card, .tile { animation: rise-in 0.35s ease both; }
.tiles .tile:nth-child(2) { animation-delay: 0.04s; }
.tiles .tile:nth-child(3) { animation-delay: 0.08s; }
.tiles .tile:nth-child(4) { animation-delay: 0.12s; }
.tiles .tile:nth-child(5) { animation-delay: 0.16s; }
.tiles .tile:nth-child(6) { animation-delay: 0.20s; }

/* ================================================================
   TABLER CHROME — sidebar logo-header, top bar, breadcrumb,
   fluid content column, and a collapsible sidebar.
   ================================================================ */

/* ---- content column: let the top bar span full width ---------- */
.main { padding: 0; }
.main > .wrap { max-width: 1560px; margin: 0 auto; padding: 1.25rem 1.75rem 2.5rem; }

/* ---- sidebar becomes a Tabler nav: logo-header + section ------ */
.sidebar { padding: 0 0.75rem 1.25rem; transition: margin-left 0.25s ease; gap: 0.12rem; }
.sidebar .brand {
  height: 60px; margin: 0 0 0.4rem; padding: 0 0.4rem;
  border-bottom: 1px solid var(--card-brd);
}
.menu-label {
  padding: 0.95rem 0.8rem 0.4rem; font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}

/* ---- top bar --------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: flex-start; gap: 1rem;
  height: 60px; padding: 0 1.75rem; margin-bottom: 0;
  background: #ffffff; border-bottom: 1px solid var(--card-brd);
  box-shadow: none;
}
.nav-toggle {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--radius); cursor: pointer; flex: 0 0 auto;
  background: #ffffff; border: 1px solid var(--card-brd); box-shadow: none; color: var(--ink-2);
}
.nav-toggle .nt-ico { display: block; transition: transform 0.25s ease; }
.nav-toggle:hover { background: #f2f5fa; color: var(--brand-1); box-shadow: none; transform: none; }
/* chevron points left when the sidebar is open, right when it's collapsed */
body.nav-collapsed .nav-toggle .nt-ico { transform: rotate(180deg); }
.topbar-title { display: flex; align-items: center; gap: 0.55rem; font-weight: 600; font-size: 1rem; color: var(--ink); }
.topbar-title .tb-ic { font-size: 1.1rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.45rem; }
.top-ic {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius);
  background: #ffffff; border: 1px solid var(--card-brd); color: var(--ink-2);
  text-decoration: none; cursor: pointer; font-size: 1rem; box-shadow: none;
}
.top-ic:hover { background: #f2f5fa; color: var(--brand-1); box-shadow: none; transform: none; }
.top-ic.danger:hover { background: #fceded; color: var(--bad); }
.admin-chip {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.24rem 0.7rem 0.24rem 0.28rem;
  border-radius: var(--radius); background: #ffffff; border: 1px solid var(--card-brd);
}
.admin-chip .ava { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 0.8rem; }
.admin-chip .who { font-size: 0.86rem; font-weight: 600; color: var(--ink-2); }

/* ---- breadcrumb ------------------------------------------------ */
.breadcrumb {
  display: flex; align-items: center; gap: 0.5rem;
  max-width: 1560px; width: 100%; margin: 0 auto;
  padding: 1.1rem 1.75rem 0; font-size: 0.8rem; color: var(--muted);
}
.breadcrumb a { color: var(--brand-1); text-decoration: none; margin: 0; }
.breadcrumb a:hover { text-decoration: underline; color: var(--brand-1); }
.breadcrumb .sep { color: var(--muted); }
.breadcrumb .cur { color: var(--ink-2); font-weight: 600; }

/* ---- collapsible sidebar (desktop: slide out) ----------------- */
body.admin.nav-collapsed .sidebar { margin-left: -280px; }

/* ---- mobile: sidebar becomes an off-canvas overlay ------------ */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh; width: 260px; flex-direction: column;
    margin-left: -280px; z-index: 200; box-shadow: var(--shadow-lg);
    padding: 0 0.75rem 1.25rem; border-right: 1px solid var(--card-brd);
  }
  .sidebar .brand { margin: 0 0 0.4rem; }
  .side-nav { flex-direction: column; }
  body.admin.nav-collapsed .sidebar { margin-left: 0; }
  .main { padding: 0; }
  .topbar { padding: 0 1rem; }
  .topbar-title { font-size: 0.95rem; }
  .admin-chip .who { display: none; }
  .breadcrumb, .main > .wrap { padding-left: 1rem; padding-right: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}

/* ================================================================
   DARK THEME — deep navy blue. Toggled by setting
   <html data-theme="dark">; persisted in localStorage('rf_theme')
   and applied before first paint by a tiny per-page <head> script,
   flipped by the top-bar toggle (admin) or the floating toggle
   (tenant pages). Higher specificity than :root so it wins cleanly.
   ================================================================ */
:root[data-theme="dark"] {
  color-scheme: dark;

  /* surfaces — navy canvas, lifted navy cards */
  --page: #0e1626;
  --bg-0: #0e1626;
  --bg-1: #121c30;
  --card: #16223a;
  --card-soft: #1b2942;
  --card-brd: #26324c;
  --card-brd-hi: #2f4a7a;
  --surface: #16223a;

  /* brand — brighter azure/indigo so it reads on navy */
  --brand-1: #4d8dfd;
  --brand-2: #6f8cff;
  --brand-3: #35c2d6;
  --brand-soft: rgba(77, 141, 253, 0.14);
  --grad: linear-gradient(135deg, #4d8dfd 0%, #6f8cff 100%);
  --glow: 0 2px 10px rgba(77, 141, 253, 0.35);

  /* text */
  --ink: #eaf0fb;
  --ink-2: #b4c0d6;
  --muted: #7f8ca6;

  /* chart plumbing — brightened for a dark backdrop */
  --grid: #222e46;
  --s1: #4d8dfd;  --s2: #35d6a4;  --s3: #b98cff;  --s4: #ffb057;
  --s-cpu: #4d8dfd;  --s-mem: #35d6a4;  --s-disk: #b98cff;  --s-load: #ffb057;

  --ok: #35d6a4;
  --bad: #ff6b6b;

  --neon-cyan: #4d8dfd;
  --neon-magenta: #b98cff;
  --neon-lime: #35d6a4;
  --neon-amber: #ffb057;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-md: 0 2px 6px 0 rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 12px 34px 0 rgba(0, 0, 0, 0.55);
  --shadow-side: 0 0 0 0 rgba(0, 0, 0, 0);

  /* per-theme surface bits consumed by the shared [data-theme] repaint block */
  --input-bg: #0f1a2e;
  --card-brd-hover: #33415f;
  --scroll-thumb: #33405c;
  --scroll-thumb-hi: #43527a;

  /* squares — lighten the grid lines so they read on the navy canvas */
  --grid-line: rgba(255, 255, 255, 0.05);
}

/* ================================================================
   EMERALD THEME — deep forest green with an emerald/teal accent.
   A third option (data-theme="emerald"), distinct from the cool
   blue light + navy dark. It shares the non-light repaint block
   below via the [data-theme] attribute selector, so only the design
   tokens live here.
   ================================================================ */
:root[data-theme="emerald"] {
  color-scheme: dark;

  /* surfaces — deep green canvas, lifted green cards */
  --page: #0a1a13;
  --bg-0: #0a1a13;
  --bg-1: #0f241a;
  --card: #10271c;
  --card-soft: #163325;
  --card-brd: #204a35;
  --card-brd-hi: #2f6e4d;
  --surface: #10271c;

  /* brand — emerald / teal so it pops on green */
  --brand-1: #10b981;
  --brand-2: #34d399;
  --brand-3: #2dd4bf;
  --brand-soft: rgba(16, 185, 129, 0.16);
  --grad: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --glow: 0 2px 10px rgba(16, 185, 129, 0.35);

  /* text */
  --ink: #e8f6ee;
  --ink-2: #b0cebe;
  --muted: #7a9a89;

  /* chart plumbing — a distinct, readable series set on green */
  --grid: #1c3a2b;
  --s1: #10b981;  --s2: #38bdf8;  --s3: #a78bfa;  --s4: #fbbf24;
  --s-cpu: #10b981;  --s-mem: #38bdf8;  --s-disk: #a78bfa;  --s-load: #fbbf24;

  --ok: #34d399;
  --bad: #fb7185;

  --neon-cyan: #10b981;
  --neon-magenta: #a78bfa;
  --neon-lime: #34d399;
  --neon-amber: #fbbf24;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-md: 0 2px 6px 0 rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 12px 34px 0 rgba(0, 0, 0, 0.55);
  --shadow-side: 0 0 0 0 rgba(0, 0, 0, 0);

  /* per-theme surface bits consumed by the shared [data-theme] repaint block */
  --input-bg: #0b2016;
  --card-brd-hover: #2b5a41;
  --scroll-thumb: #2f5c45;
  --scroll-thumb-hi: #3f7a5c;

  /* squares — faint light grid on the green canvas */
  --grid-line: rgba(255, 255, 255, 0.05);
}

/* --- repaint the surfaces that hardcode light values (ALL non-light
       themes: dark, emerald, and any future data-theme value) --- */
:root[data-theme] body { background-color: var(--page); color: var(--ink-2); }
:root[data-theme] .sidebar,
:root[data-theme] .topbar { background: var(--card); border-color: var(--card-brd); }
:root[data-theme] .sidebar { border-right-color: var(--card-brd); }
:root[data-theme] .sidebar .brand { border-bottom-color: var(--card-brd); }
:root[data-theme] .side-nav a:hover { background: rgba(255, 255, 255, 0.05); color: var(--ink); }

:root[data-theme] .nav-toggle,
:root[data-theme] .top-ic,
:root[data-theme] .admin-chip,
:root[data-theme] .btn-ghost,
:root[data-theme] button.mini,
:root[data-theme] .btnlike,
:root[data-theme] .kebab,
:root[data-theme] .icon-btn,
:root[data-theme] .filters a,
:root[data-theme] .theme-fab { background: var(--card-soft); border-color: var(--card-brd); color: var(--ink-2); }
:root[data-theme] .nav-toggle span { background: var(--ink-2); }
:root[data-theme] .nav-toggle:hover,
:root[data-theme] .top-ic:hover,
:root[data-theme] .btn-ghost:hover,
:root[data-theme] button.mini:hover,
:root[data-theme] .btnlike:hover,
:root[data-theme] .kebab:hover,
:root[data-theme] .icon-btn:hover,
:root[data-theme] .filters a:hover,
:root[data-theme] .theme-fab:hover { background: rgba(255, 255, 255, 0.07); color: var(--brand-1); }

:root[data-theme] input[type=text],
:root[data-theme] input[type=email],
:root[data-theme] input[type=password],
:root[data-theme] input:not([type]),
:root[data-theme] select,
:root[data-theme] textarea { background: var(--input-bg); border-color: var(--card-brd); color: var(--ink); }
:root[data-theme] select option { background: var(--card); color: var(--ink); }

:root[data-theme] table tr:hover td,
:root[data-theme] tr.edit-row td { background: rgba(255, 255, 255, 0.03); }
:root[data-theme] tr.total td { border-top-color: var(--card-brd); }
:root[data-theme] code,
:root[data-theme] .tenant-url { background: var(--brand-soft); color: var(--brand-1); border-color: var(--card-brd); }

:root[data-theme] .menu,
:root[data-theme] .drawer-panel,
:root[data-theme] .modal-box,
:root[data-theme] .tooltip,
:root[data-theme] .pm-frame,
:root[data-theme] .drawer-frame { background: var(--card); border-color: var(--card-brd); }
:root[data-theme] .drawer-head { background: var(--card-soft); border-bottom-color: var(--card-brd); }
:root[data-theme] .menu a:hover,
:root[data-theme] .menu button:hover { background: rgba(255, 255, 255, 0.05); }

:root[data-theme] .use-track { background: rgba(255, 255, 255, 0.08); }
:root[data-theme] .flash.ok { background: rgba(53, 214, 164, 0.13); color: #6fe3bf; border-color: rgba(53, 214, 164, 0.30); }
:root[data-theme] .flash.bad,
:root[data-theme] .error { background: rgba(255, 107, 107, 0.13); color: #ff9d9d; border-color: rgba(255, 107, 107, 0.30); }
:root[data-theme] button.danger,
:root[data-theme] .btn-danger { background: rgba(255, 107, 107, 0.14); color: #ff9d9d; border-color: rgba(255, 107, 107, 0.30); }
:root[data-theme] .menu .danger-item:hover,
:root[data-theme] .side-foot a:hover { background: rgba(255, 107, 107, 0.14); }

:root[data-theme] .card:hover,
:root[data-theme] .tile:hover { border-color: var(--card-brd-hover); }
:root[data-theme] * { scrollbar-color: var(--scroll-thumb) transparent; }
:root[data-theme] ::-webkit-scrollbar-thumb { background: var(--scroll-thumb); }
:root[data-theme] ::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hi); }

/* --- floating theme toggle (tenant public pages have no top bar) --- */
.theme-fab {
  position: fixed; top: 1rem; right: 1rem; z-index: 60;
  width: 42px; height: 42px; border-radius: var(--radius);
  display: inline-grid; place-items: center; cursor: pointer; font-size: 1.05rem;
  background: #ffffff; border: 1px solid var(--card-brd); color: var(--ink-2);
  box-shadow: var(--shadow-sm); line-height: 1;
}
.theme-fab:hover { color: var(--brand-1); border-color: var(--card-brd-hi); }
/* tenant landing badge hardcodes a light bg inline — repaint for any dark theme */
:root[data-theme] .t-card .badge { background: rgba(255, 255, 255, 0.06) !important; }
