/* lotusboss admin — same visual language as the MD Pay admin (C:\crypto\frontend\src\theme.css): light panels,
   indigo accent, floating rail, frosted top bar. Restyles the classes app.js already emits, so pages need no rewrite.
   Apple-design rules: feedback on press (not release), focus rings, size-specific tracking, tabular figures,
   translucent chrome with reduced-transparency / reduced-motion / more-contrast fallbacks. */

:root {
  color-scheme: light;
  --bg: #f5f5fa;
  --surface: #ffffff;
  --surface-2: #fafaff;
  --border: #ebebf3;
  --border-strong: #dcdcea;
  --line: var(--border); /* used by inline styles in app.js */
  --text: #11121c;
  --muted: #6c6d80;
  --faint: #9a9bad;
  --accent: #5145ea;
  --accent-2: #8f8cff;
  --accent-soft: #efeeff;
  --accent-ink: #3b30c9;
  --ink: #101018;
  --green: #0f8a5f;
  --green-bg: #e6f7ef;
  --red: #c4291c;
  --red-bg: #fdeeec;
  --amber: #c2570c;
  --amber-bg: #fff3e6;
  --live: #ef3a4b;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(17, 18, 40, .04), 0 10px 30px -18px rgba(17, 18, 40, .14);
  --shadow-pop: 0 18px 48px -12px rgba(17, 18, 40, .22), 0 2px 6px rgba(17, 18, 40, .06);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --rail-w: 76px;
  --rail-w-wide: 236px;
  --ease: cubic-bezier(.2, .9, .25, 1); /* critically damped: settles without overshoot */
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv11', 'ss01';
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* component display rules must not override the hidden attribute */
/* Staff permissions: render() sets deny-* on body for the current page; tagged controls hide or go read-only. */
body.deny-create [data-need="create"], body.deny-edit [data-need="edit"], body.deny-change [data-need="change"] { display: none !important; }
body.deny-edit [data-lock="edit"], body.deny-change [data-lock="change"] { pointer-events: none; opacity: .55; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh; background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); color: var(--accent-ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); }

/* ================= shell ================= */
.shell { max-width: 1560px; margin: 0 auto; padding: 0 28px 48px; }

.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px; height: 76px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); flex-shrink: 0; }
.brand:hover { color: var(--text); }
.brand-mark { display: block; }
.brand-name { font-size: 21px; font-weight: 650; letter-spacing: -0.03em; }
.brand-name b { font-weight: 650; color: var(--accent); }
.brand-tag {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 999px;
}
.top-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px; padding: 0;
  border-radius: 50%; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  cursor: pointer; box-shadow: var(--shadow); transition: border-color .12s, transform .1s var(--ease);
}
.icon-btn:hover { border-color: var(--border-strong); background: var(--surface); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.menu-toggle { display: none; }

.live-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-weight: 600;
  box-shadow: var(--shadow); font-variant-numeric: tabular-nums; transition: border-color .12s, color .12s;
}
.live-pill:hover { color: var(--text); border-color: var(--border-strong); }
.live-pill .dot { margin: 0; }
.live-pill:not(.on) .dot.live { background: var(--faint); animation: none; box-shadow: none; }
.live-pill.on { color: var(--text); }

.acct { display: flex; align-items: center; gap: 11px; }
.acct-text { display: flex; flex-direction: column; gap: 1px; line-height: 1.2; }
.acct-name { font-weight: 650; font-size: 14.5px; letter-spacing: -0.01em; }
.acct-sub { font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(140deg, var(--accent-2), var(--accent)); color: #fff; font-weight: 700; font-size: 13px;
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}

.crumbs { display: flex; align-items: center; gap: 8px; padding: 20px 0 18px; color: var(--muted); font-size: 14px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.crumbs svg { opacity: .5; }
.crumbs span { color: var(--text); font-weight: 600; }

.body { display: flex; gap: 28px; align-items: flex-start; }
.page { flex: 1; min-width: 0; }

/* ---- floating rail ---- */
.rail {
  position: sticky; top: 96px; flex-shrink: 0; width: var(--rail-w); max-height: calc(100vh - 120px);
  display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow); padding: 12px;
  transition: width .22s var(--ease);
}
.rail::-webkit-scrollbar { display: none; }
.rail.wide { width: var(--rail-w-wide); }
.rail nav { flex: 1; }
.rail-group + .rail-group { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.rail-title {
  display: none; font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint); padding: 6px 13px 4px;
}
.rail.wide .rail-title { display: block; }
.rail-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; height: 46px; padding: 0 13px; margin: 0 0 3px;
  border: 0; border-radius: 14px; background: none; color: #55566a; cursor: pointer;
  font: inherit; font-weight: 550; white-space: nowrap; box-shadow: none;
  transition: background .12s, color .12s, transform .1s var(--ease);
}
.rail-item svg { flex-shrink: 0; }
.rail-item:hover { background: var(--surface-2); color: var(--text); }
.rail-item:active { transform: scale(.97); }
.rail-item.active { background: var(--accent-soft); color: var(--accent); }
.rail-label { opacity: 0; pointer-events: none; transition: opacity .12s; }
.rail.wide .rail-label { opacity: 1; }
.rail-expand { margin-top: 8px; border-top: 1px solid var(--border); border-radius: 0 0 14px 14px; height: 52px; }
.rail-count {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--live); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center;
}
.rail:not(.wide) .rail-count { position: absolute; top: 5px; left: 28px; min-width: 18px; height: 18px; font-size: 10.5px; border: 2px solid var(--surface); }
/* collapsed: labels become tooltips */
.rail:not(.wide) .rail-item::after {
  content: attr(data-tip); position: fixed; margin-left: calc(var(--rail-w) - 12px);
  background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 600; padding: 6px 10px; border-radius: 8px;
  opacity: 0; transform: translateX(-4px); pointer-events: none; transition: opacity .12s, transform .12s var(--ease); z-index: 70;
}
.rail:not(.wide) .rail-item:hover::after, .rail:not(.wide) .rail-item:focus-visible::after { opacity: 1; transform: none; }
.backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(16, 16, 24, .35); backdrop-filter: blur(2px); }

/* login: no chrome */
body.is-auth .top, body.is-auth .crumbs, body.is-auth .rail { display: none; }
body.is-auth .shell { padding: 0; max-width: none; }

/* ================= page furniture ================= */
#root > section, .page section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px 28px; margin: 0 0 22px;
  overflow-x: auto; /* wide tables scroll inside their card instead of widening the page */
}
.page section section { box-shadow: none; background: var(--surface-2); padding: 18px 20px; }
section.compact { padding: 18px 20px; }
h2 { font-size: 21px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; margin: 0 0 6px; }
#root > section:first-child > h2:first-child, #dash-shell > section:first-of-type > h2 { font-size: 24px; letter-spacing: -0.03em; }
h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; margin: 18px 0 8px; }
p { margin: 0 0 12px; }
.hint, .muted { color: var(--muted); }
.hint { font-size: 13.5px; }
.ok { color: var(--green); }
.err { color: var(--red); }
.status { min-height: 1.2em; font-size: 13.5px; margin: 6px 0 0; }
ol, ul { padding-left: 20px; }
li { margin-bottom: 4px; }

/* ---- buttons: feedback lives on the press ---- */
button, .btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border: 0; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff !important; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--accent) 75%, transparent);
  transition: background .12s, box-shadow .12s, border-color .12s, transform .1s var(--ease);
}
button:hover, .btn:hover { background: var(--accent-ink); }
button:active, .btn:active { transform: scale(.97); }
button:disabled { opacity: .55; cursor: default; transform: none; }
button.ghost, .btn.ghost {
  background: var(--surface); color: var(--text) !important; border: 1px solid var(--border-strong); box-shadow: none;
}
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); border-color: #c9c9dc; }
button.danger, .btn.danger { background: var(--red); box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--red) 70%, transparent); }
button.danger:hover, .btn.danger:hover { background: #a3200f; }
.sm, button.sm, .btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 10px; }
.icon-btn, .rail-item { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rail-item, .icon-btn { box-shadow: none; }
/* the rail toggle is a <button>: undo the global white button text so it's visible on the white rail */
button.rail-item { color: inherit !important; justify-content: flex-start; }
button.rail-item:hover { color: var(--text) !important; }
.icon-btn { box-shadow: var(--shadow); color: var(--text) !important; }

/* ---- inputs ---- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 6px; }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px 13px; width: 100%; max-width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); vertical-align: middle; }
input[type=number] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--accent-soft); }
input::placeholder { color: var(--faint); }
select { width: auto; cursor: pointer; }
form { margin: 0; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.row label { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.filters input, .filters select { width: auto; border-radius: 10px !important; padding: 8px 11px !important; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.toggleBtn { box-shadow: none !important; }
.toggleBtn:not(.active) { background: var(--surface) !important; color: var(--text) !important; }

/* ---- status dots ---- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-right: 6px; vertical-align: middle; }
.dot.ok { background: #1db954; box-shadow: 0 0 0 3px var(--green-bg); }
.dot.warn { background: #f5a623; box-shadow: 0 0 0 3px var(--amber-bg); }
.dot.err { background: var(--live); box-shadow: 0 0 0 3px var(--red-bg); }
.dot.live { background: var(--live); animation: pulse 1.8s var(--ease) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239, 58, 75, .45); } 70% { box-shadow: 0 0 0 7px rgba(239, 58, 75, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 58, 75, 0); } }

/* ---- stat tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin: 0 0 22px; }
.tile {
  position: relative; display: flex; flex-direction: column; min-height: 150px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 22px 24px; box-shadow: var(--shadow);
  transition: border-color .12s, transform .16s var(--ease);
}
.tile:hover { border-color: var(--border-strong); }
.tile .label { font-size: 14px; font-weight: 550; color: #44455a; }
.tile .value { font-size: 40px; font-weight: 700; letter-spacing: -0.045em; line-height: 1; margin-top: 16px; display: inline-block; font-variant-numeric: tabular-nums; }
.tile .suffix { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: -0.01em; }
.tile .sub { margin-top: auto; padding-top: 14px; font-size: 13px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
/* the first dashboard figure is the headline */
#dash-shell > .tiles .tile:first-child {
  background: radial-gradient(130% 120% at 100% 0%, #2b2842 0%, var(--ink) 58%); border-color: transparent; color: #fff;
}
#dash-shell > .tiles .tile:first-child .label, #dash-shell > .tiles .tile:first-child .sub { color: #b7b8cc; }
section .tiles { margin-bottom: 8px; }
section .tile { box-shadow: none; background: var(--surface-2); min-height: 120px; border-radius: 18px; }
section .tile .value { font-size: 30px; }

/* ---- host health meters ---- */
.health { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px 24px; margin: 14px 0 10px; }
.health .row { justify-content: space-between; font-weight: 600; font-size: 13.5px; }
.meter { height: 8px; border-radius: 999px; background: #ececf4; overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .6s var(--ease); }
.meter.hot > span { background: linear-gradient(90deg, #ffb86b, #ef5a3a); }
.meter.cool > span { background: linear-gradient(90deg, #7fe0c0, #1db98a); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: #8b8ca0; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr, tr { transition: background .1s; }
tr:hover > td { background: var(--surface-2); }
tr:last-child > td { border-bottom: 0; }
.page section > table, .page section > div > table { margin-top: 8px; }

/* ---- tabs: segmented pill ---- */
.tabs {
  display: inline-flex !important; gap: 4px !important; flex-wrap: wrap; padding: 5px; margin: 14px 0 16px !important;
  background: #ebebf4; border: 0 !important; border-radius: 14px;
}
.tabbtn {
  height: 34px; padding: 0 15px; border: 0; border-radius: 10px; background: transparent; color: var(--muted) !important;
  font-weight: 600; box-shadow: none;
}
.tabbtn:hover { background: transparent; color: var(--text) !important; }
.tabbtn.active { background: var(--surface); color: var(--text) !important; box-shadow: 0 1px 3px rgba(17, 18, 40, .1); }
.tabbtn .muted { font-weight: 500; margin-left: 2px; }

/* ---- code ---- */
code {
  font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 6px; color: var(--accent-ink); overflow-wrap: anywhere;
}
pre, .codebox {
  background: var(--ink); color: #e7e7f3; padding: 14px 16px; border-radius: var(--radius-sm); overflow: auto; margin: 8px 0 14px;
}
pre code, .codebox code { background: none; border: 0; padding: 0; color: inherit; }

/* ---- chips ---- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #f0f0f6; color: var(--muted); white-space: nowrap;
}
.chip.ok { background: var(--green-bg); color: var(--green); }
.chip.err { background: var(--red-bg); color: var(--red); }
.chip.live { background: #fff0f1; color: var(--live); }
.chip.muted { background: transparent; }

/* ---- Live tab tiles ---- */
.live-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.livetile-row { padding: 14px !important; gap: 16px !important; }
.livetile-row .nm { font-size: 15px !important; letter-spacing: -0.015em; }
.livetile-row video { border-radius: 14px; }
.livetile-row > div:nth-child(2) { border-radius: 14px !important; }

/* ---- login ---- */
.login-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(60% 50% at 15% 0%, color-mix(in srgb, var(--accent-2) 22%, transparent), transparent 70%),
    radial-gradient(50% 40% at 100% 100%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%), var(--bg);
}
.login-card { width: 100%; max-width: 410px; padding: 34px !important; border-radius: 24px !important; box-shadow: var(--shadow-pop) !important; }
.login-card h2 { font-size: 26px; letter-spacing: -0.03em; }
.login-card form { display: grid; gap: 12px; margin-top: 18px; }
.login-card button { height: 46px; font-size: 15px; }

/* ================= responsive ================= */
@media (max-width: 1180px) { .acct-text { display: none; } }
@media (max-width: 860px) {
  .shell { padding: 0 16px 32px; }
  .top { height: 64px; gap: 10px; }
  .menu-toggle { display: inline-grid; }
  .brand-name { font-size: 18px; }
  .brand-tag, .acct { display: none; }
  .crumbs { padding: 14px 0 12px; }
  .rail {
    position: fixed; top: 0; left: 0; bottom: 0; max-height: none; z-index: 50; width: 260px !important;
    border-radius: 0 24px 24px 0; transform: translateX(-105%); transition: transform .24s var(--ease);
  }
  .rail.open { transform: none; }
  .rail .rail-label { opacity: 1; }
  .rail .rail-title { display: block; }
  .rail .rail-item::after { display: none; }
  .rail .rail-count { position: static !important; border: 0 !important; }
  .rail-expand { display: none; }
  #root > section, .page section { padding: 18px; border-radius: 18px; }
  .tile .value { font-size: 32px; }
  .livetile-row { grid-template-columns: 1fr !important; }
}

/* ================= accessibility ================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .top { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .backdrop { backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --border: #b9b9cc; --border-strong: #8e8ea6; --muted: #45465a; }
}
