/* ==========================================================================
   Fleet Control — core styles
   Tokens -> base -> glass surfaces -> topbar/nav -> overview -> panels,
   tables, controls -> feed -> charts -> modals/toasts -> skeletons -> phone.
   Accent hue/saturation are set at runtime by theme.js; lightness is per theme.
   ========================================================================== */

:root {
  color-scheme: dark;
  --ah: 239;
  --as: 84%;
  --accent: hsl(var(--ah) var(--as) 71%);
  --accent-2: hsl(calc(var(--ah) + 34) var(--as) 66%);
  --accent-soft: hsl(var(--ah) var(--as) 71% / .15);
  --accent-line: hsl(var(--ah) var(--as) 71% / .42);
  --on-accent: #080a16;

  --bg: #070910;
  --glass: rgba(255, 255, 255, .045);
  --glass-border: rgba(255, 255, 255, .09);
  --glass-hi: rgba(255, 255, 255, .09);
  --blur: 18px;
  --solid: #10131e;
  --tile: rgba(255, 255, 255, .045);
  --tile-border: rgba(255, 255, 255, .07);
  --line: rgba(255, 255, 255, .07);
  --hover: rgba(255, 255, 255, .045);
  --term: rgba(3, 5, 12, .5);
  --track: rgba(255, 255, 255, .14);
  --scroll: rgba(255, 255, 255, .16);
  --sk-a: rgba(255, 255, 255, .06);
  --sk-b: rgba(255, 255, 255, .14);

  --text: #e8ebf6;
  --text-2: #a9b2c7;
  --text-3: #6d7992;

  --ok: #3ddc97;     --ok-soft: rgba(61, 220, 151, .14);   --ok-line: rgba(61, 220, 151, .38);
  --warn: #f5b942;   --warn-soft: rgba(245, 185, 66, .14); --warn-line: rgba(245, 185, 66, .38);
  --danger: #ff6b72; --danger-soft: rgba(255, 107, 114, .14); --danger-line: rgba(255, 107, 114, .4);
  --violet: #b595ff; --violet-soft: rgba(181, 149, 255, .15);
  --gold: #f7cb4d;   --gold-soft: rgba(247, 203, 77, .14);
  --info: #5cc8ff;

  --shadow: 0 14px 34px -16px rgba(0, 0, 0, .65);
  --chart-grid: rgba(255, 255, 255, .07);
  --chart-text: #7f8ba3;
  --chart-dot: #0c0f1a;
  --tip-bg: rgba(16, 19, 30, .92);
  --av-l: 74%;

  --r-xl: 22px;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 9px;

  --font-ui: 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

:root[data-theme="light"] {
  color-scheme: light;
  --accent: hsl(var(--ah) var(--as) 52%);
  --accent-2: hsl(calc(var(--ah) + 34) var(--as) 54%);
  --accent-soft: hsl(var(--ah) var(--as) 52% / .12);
  --accent-line: hsl(var(--ah) var(--as) 52% / .4);
  --on-accent: #fff;

  --bg: #eef1f8;
  --glass: rgba(255, 255, 255, .64);
  --glass-border: rgba(255, 255, 255, .85);
  --glass-hi: rgba(255, 255, 255, .95);
  --solid: #ffffff;
  --tile: rgba(20, 30, 60, .04);
  --tile-border: rgba(20, 30, 60, .07);
  --line: rgba(20, 30, 60, .08);
  --hover: rgba(20, 30, 60, .04);
  --term: rgba(255, 255, 255, .6);
  --track: rgba(20, 30, 60, .2);
  --scroll: rgba(20, 30, 60, .22);
  --sk-a: rgba(20, 30, 60, .06);
  --sk-b: rgba(20, 30, 60, .13);

  --text: #111a30;
  --text-2: #475169;
  --text-3: #7a859d;

  --ok: #0f9d63;     --ok-soft: rgba(15, 157, 99, .12);   --ok-line: rgba(15, 157, 99, .35);
  --warn: #b7791f;   --warn-soft: rgba(183, 121, 31, .13); --warn-line: rgba(183, 121, 31, .38);
  --danger: #d8333f; --danger-soft: rgba(216, 51, 63, .1); --danger-line: rgba(216, 51, 63, .35);
  --violet: #7646e0; --violet-soft: rgba(118, 70, 224, .11);
  --gold: #a87a06;   --gold-soft: rgba(168, 122, 6, .13);
  --info: #0d86c4;

  --shadow: 0 12px 30px -16px rgba(30, 45, 90, .28);
  --chart-grid: rgba(20, 30, 60, .09);
  --chart-text: #6c7690;
  --chart-dot: #ffffff;
  --tip-bg: rgba(255, 255, 255, .96);
  --av-l: 36%;
}

/* theme switch: briefly animate colours, then get out of the way */
html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .35s ease, border-color .35s ease, color .35s ease, fill .35s ease, stroke .35s ease, box-shadow .35s ease !important;
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: 'tnum' 1, 'ss01' 1;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ambient background, tinted by the accent so glass has something to refract */
.aurora { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--bg); overflow: hidden; }
.aurora::before, .aurora::after { content: ''; position: absolute; border-radius: 50%; }
.aurora::before {
  width: 70vw; height: 55vw; left: -18vw; top: -26vw;
  background: radial-gradient(closest-side, hsl(var(--ah) var(--as) 58% / .42), transparent);
}
.aurora::after {
  width: 55vw; height: 50vw; right: -14vw; top: 8vh;
  background: radial-gradient(closest-side, hsl(calc(var(--ah) + 70) 80% 58% / .22), transparent);
}
:root[data-theme="light"] .aurora::before { background: radial-gradient(closest-side, hsl(var(--ah) var(--as) 70% / .34), transparent); }
:root[data-theme="light"] .aurora::after { background: radial-gradient(closest-side, hsl(calc(var(--ah) + 70) 85% 74% / .3), transparent); }

/* ---- glass surfaces ----------------------------------------------------- */
.panel, .stat, .roll, .card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hi);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  backdrop-filter: blur(var(--blur)) saturate(150%);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .panel, .stat, .roll, .card { background: var(--solid); }
}

/* ---- msa banner --------------------------------------------------------- */
.msa-banner { background: var(--warn-soft); border-bottom: 1px solid var(--warn-line); position: relative; z-index: 41; }
.msa-banner__inner { max-width: 1280px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 12px; }
.msa-banner__icon { width: 22px; height: 22px; border-radius: 50%; background: var(--warn); color: #1a1100; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.msa-banner__text { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.msa-banner__text strong { color: var(--warn); }
.msa-banner__text a { color: var(--accent); text-decoration: underline; }

/* ---- topbar ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  padding-top: var(--safe-t);
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.topbar__inner { max-width: 1280px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; order: 0; min-width: 0; }
.brand__mark { display: flex; align-items: flex-end; gap: 3px; width: 28px; height: 28px; padding: 4px; border-radius: 9px; background: var(--tile); border: 1px solid var(--tile-border); }
.brand__mark i { flex: 1; border-radius: 2px; background: linear-gradient(180deg, var(--accent), var(--accent-2)); }
.brand__mark i:nth-child(1) { height: 45%; } .brand__mark i:nth-child(2) { height: 100%; } .brand__mark i:nth-child(3) { height: 68%; }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__text strong { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.brand__text small { font-size: 12px; color: var(--text-3); }

.topbar__controls { order: 1; margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar__tools { order: 2; display: flex; align-items: center; gap: 8px; }

.players {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--glass-border); background: var(--tile); font-size: 12.5px; color: var(--text-2); white-space: nowrap;
}
.players svg { width: 15px; height: 15px; }
.players__n { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.players--ok { border-color: var(--ok-line); } .players--ok svg, .players--ok .players__n { color: var(--ok); }
.players--warn { border-color: var(--warn-line); } .players--warn svg, .players--warn .players__n { color: var(--warn); }
.players--staff { border-color: var(--danger-line); } .players--staff svg, .players--staff .players__n { color: var(--danger); }

.switch {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 13px 6px 8px; border-radius: 999px;
  border: 1px solid var(--glass-border); background: var(--tile); color: var(--text-2);
  font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: border-color .2s, color .2s, background .2s;
}
.switch:hover { color: var(--text); background: var(--hover); }
.switch:disabled { opacity: .55; cursor: wait; }
.switch__track { width: 28px; height: 16px; border-radius: 99px; background: var(--track); position: relative; transition: background .25s; flex-shrink: 0; }
.switch__track i { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform .28s cubic-bezier(.3, 1.5, .5, 1); }
.switch[aria-pressed="true"] { color: var(--text); border-color: var(--ok-line); }
.switch[aria-pressed="true"] .switch__track { background: var(--ok); }
.switch[aria-pressed="true"] .switch__track i { transform: translateX(12px); }

.conn { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); padding: 0 6px; }
.conn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); transition: background .3s, box-shadow .3s; }
.conn__dot--up { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.conn__dot--down { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.icon-btn {
  width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--glass-border); background: var(--tile);
  color: var(--text-2); display: inline-grid; place-items: center; cursor: pointer; padding: 0; flex-shrink: 0;
  transition: background .18s, color .18s, border-color .18s, transform .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); border-color: var(--accent-line); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn--sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn--sm svg { width: 15px; height: 15px; }
.icon-btn--danger:hover { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }

.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle svg { position: absolute; transition: transform .45s cubic-bezier(.3, 1.2, .4, 1), opacity .3s; }
:root[data-theme="dark"] .i-sun { transform: translateY(0) rotate(0); opacity: 1; }
:root[data-theme="dark"] .i-moon { transform: translateY(26px) rotate(-60deg); opacity: 0; }
:root[data-theme="light"] .i-sun { transform: translateY(-26px) rotate(60deg); opacity: 0; }
:root[data-theme="light"] .i-moon { transform: translateY(0) rotate(0); opacity: 1; }

.accent-wrap { position: relative; }
.accent-dot { width: 16px; height: 16px; border-radius: 50%; background: conic-gradient(from 210deg, var(--accent), var(--accent-2), var(--accent)); box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.accent-pop {
  position: absolute; right: 0; top: calc(100% + 10px); display: flex; gap: 8px; padding: 10px; border-radius: 16px;
  background: var(--tip-bg); border: 1px solid var(--glass-border); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  opacity: 0; transform: translateY(-6px) scale(.96); transform-origin: top right; pointer-events: none;
  transition: opacity .18s, transform .22s cubic-bezier(.3, 1.3, .5, 1); z-index: 60;
}
.accent-pop.is-open { opacity: 1; transform: none; pointer-events: auto; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; background: var(--sw); cursor: pointer; padding: 0; transition: transform .15s, border-color .15s; }
.swatch:hover { transform: scale(1.12); }
.swatch[aria-checked="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg); }

/* ---- main nav ----------------------------------------------------------- */
.app { max-width: 1280px; margin: 0 auto; padding: 0 24px 56px; }
.tabs { position: relative; display: inline-flex; gap: 2px; padding: 4px; margin: 22px 0 16px; border-radius: 15px; background: var(--tile); border: 1px solid var(--tile-border); }
.tab { position: relative; z-index: 1; padding: 8px 18px; border-radius: 11px; font-weight: 600; font-size: 13.5px; color: var(--text-2); transition: color .2s; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); }
.tabs__ind {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: 0; border-radius: 11px; background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-line); transition: transform .42s cubic-bezier(.3, .95, .3, 1), width .42s cubic-bezier(.3, .95, .3, 1);
}
.bottomnav { display: none; }

/* ---- overview strips ---------------------------------------------------- */
.statstrip { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 12px; }
.stat { border-radius: var(--r-lg); padding: 14px 16px; display: flex; align-items: center; gap: 13px; min-width: 0; }
.stat__icon { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; flex-shrink: 0; background: var(--tile); color: var(--text-2); }
.stat__icon svg { width: 19px; height: 19px; }
.stat__icon--ok { background: var(--ok-soft); color: var(--ok); }
.stat__icon--accent { background: var(--accent-soft); color: var(--accent); }
.stat__icon--warn { background: var(--warn-soft); color: var(--warn); }
.stat__icon--violet { background: var(--violet-soft); color: var(--violet); }
.stat__icon--gold { background: var(--gold-soft); color: var(--gold); }
.stat__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.stat__label { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.stat__value { font-size: 21px; font-weight: 650; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.stat__value--sm { font-size: 15px; font-weight: 600; letter-spacing: 0; white-space: normal; line-height: 1.25; }
.stat__value--usd { color: var(--ok); }
.stat__of { font-size: 13px; color: var(--text-3); font-weight: 500; margin-left: 6px; }
.dual { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.stat__inr { font-size: 13px; font-weight: 600; color: var(--gold); }
.inr-value { display: none; }
body.show-inr .inr-value { display: inline; }

.rolling { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.roll { border-radius: var(--r-lg); padding: 14px 18px; display: flex; flex-direction: column; gap: 6px; --rc: var(--info); }
.roll--30 { --rc: var(--violet); } .roll--60 { --rc: var(--gold); }
.roll__head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.roll__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--rc) 22%, transparent); }
.roll__shards { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.roll__shards small { font-size: 13px; color: var(--text-3); font-weight: 500; letter-spacing: 0; }
.roll__cur { display: flex; gap: 8px; }
.tag { font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 7px; font-variant-numeric: tabular-nums; }
.tag--usd { background: var(--ok-soft); color: var(--ok); }
.tag--inr { background: var(--gold-soft); color: var(--gold); }

/* ---- layout + panels ---------------------------------------------------- */
.view { margin-top: 16px; }
.view.is-entering { animation: viewIn .3s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
.panel { border-radius: var(--r-xl); overflow: hidden; min-width: 0; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel__head h2 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.panel__sub { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.panel__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hint { font-size: 12.5px; color: var(--text-3); }
.hint--pad { display: block; padding: 0 20px 16px; }

/* ---- buttons / inputs --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 15px; border-radius: 10px;
  border: 1px solid var(--glass-border); background: var(--tile); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: background .18s, border-color .18s, transform .12s, filter .18s;
}
.btn:hover { background: var(--hover); border-color: var(--accent-line); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn--sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; }
.btn--primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--on-accent); box-shadow: 0 6px 18px -8px var(--accent); }
.btn--primary:hover { filter: brightness(1.08); background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-color: transparent; }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn svg { width: 15px; height: 15px; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

.input, .select, .field input, .field select, .searchbox {
  height: 38px; border-radius: 10px; border: 1px solid var(--glass-border); background: var(--tile); padding: 0 12px; color: var(--text); min-width: 0;
  transition: border-color .18s, box-shadow .18s;
}
.input:focus, .select:focus, .field input:focus, .field select:focus, .searchbox:focus-within { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.select, .field select { cursor: pointer; }
.select option, .field select option { background: var(--solid); color: var(--text); }
.input--mono { font-family: var(--font-mono); font-size: 13px; }
.select:disabled { opacity: .4; }

.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--tile); border: 1px solid var(--tile-border); gap: 2px; }
.seg__btn { border: 0; background: transparent; color: var(--text-2); font-size: 12.5px; font-weight: 600; padding: 6px 13px; border-radius: 8px; cursor: pointer; transition: background .2s, color .2s; }
.seg__btn:hover { color: var(--text); }
.seg__btn.is-active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-line); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips--scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips--scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--tile-border); background: var(--tile); color: var(--text-2);
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .18s, color .18s, border-color .18s;
}
.chip:hover { color: var(--text); }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.chip__n { font-size: 11.5px; opacity: .75; font-variant-numeric: tabular-nums; }
.chip--ok.is-active { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.chip--warn.is-active { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.chip--danger.is-active { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.chip--violet.is-active { background: var(--violet-soft); border-color: var(--violet-soft); color: var(--violet); }

/* ---- tables ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.bot-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.bot-table thead th { text-align: left; padding: 10px 16px; font-size: 12.5px; color: var(--text-3); font-weight: 500; border-bottom: 1px solid var(--line); white-space: nowrap; }
.bot-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.bot-table tbody tr:last-child td { border-bottom: 0; }
.bot-table tbody tr[data-bot-id] { cursor: pointer; transition: background .15s; }
.bot-table tbody tr[data-bot-id]:hover { background: var(--hover); }
.bot-table th:first-child, .bot-table td:first-child { padding-left: 20px; }
.bot-table th:last-child, .bot-table td:last-child { padding-right: 20px; }
.bot-table__empty td { color: var(--text-3); text-align: center; padding: 28px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bot-table .col-proxy { display: none; }

.acct { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  --hue: 240; width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; text-transform: uppercase;
  background: hsl(var(--hue) 70% 60% / .17); color: hsl(var(--hue) 80% var(--av-l));
}
.acct__name { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct__id { display: block; font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }
.sub { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; }

.badge, .perf {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--online { background: var(--ok-soft); color: var(--ok); }
.badge--online::before { animation: pulse 2.6s ease-out infinite; }
.badge--connecting, .badge--reconnecting, .badge--cooldown { background: var(--warn-soft); color: var(--warn); }
.badge--offline, .badge--error { background: var(--danger-soft); color: var(--danger); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70%, 100% { box-shadow: 0 0 0 6px transparent; } }
.perf--optimal { background: var(--ok-soft); color: var(--ok); }
.perf--low { background: var(--warn-soft); color: var(--warn); }
.perf--stalled { background: var(--danger-soft); color: var(--danger); }
.perf--unknown { color: var(--text-3); }

.ping { display: inline-flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ping::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.ping--good::before { background: var(--ok); } .ping--ok::before { background: var(--warn); } .ping--bad::before { background: var(--danger); }
.proxy-tag { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); }
.proxy-tag--none { color: var(--text-3); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.share { display: block; height: 4px; border-radius: 3px; background: var(--tile); margin-top: 6px; overflow: hidden; min-width: 70px; }
.share i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s cubic-bezier(.2, .8, .3, 1); }

@keyframes rowFlash { 0% { background: var(--ok-soft); } 100% { background: transparent; } }
.row-flash { animation: rowFlash 1.4s ease-out; }

/* ---- dispatcher --------------------------------------------------------- */
.dispatch { display: grid; grid-template-columns: auto minmax(150px, 220px) 1fr; gap: 10px; align-items: center; padding: 16px 20px; }
.dispatch__form { display: flex; gap: 8px; min-width: 0; }
.dispatch__form .input { flex: 1; }
.macros { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 16px; }
.macros button {
  border: 1px solid var(--tile-border); background: var(--tile); color: var(--text-2); border-radius: 8px; padding: 5px 11px;
  font-family: var(--font-mono); font-size: 12px; cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.macros button:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

/* ---- fleet feed --------------------------------------------------------- */
.panel--feed { display: flex; flex-direction: column; height: 560px; }
.panel__head--feed { flex-shrink: 0; flex-wrap: wrap; row-gap: 10px; }
.feed-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.feed-tabs::-webkit-scrollbar { display: none; }
.feed-tab { border: 0; background: transparent; color: var(--text-2); padding: 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .18s, color .18s; }
.feed-tab:hover { color: var(--text); }
.feed-tab.is-active { background: var(--accent-soft); color: var(--accent); }
.feed { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px 20px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55; background: var(--term); display: flex; flex-direction: column; }
.feed__empty { color: var(--text-3); padding: 28px 0; text-align: center; font-family: var(--font-ui); }
.feed-line { display: flex; gap: 10px; padding: 3px 0; white-space: pre-wrap; word-break: break-word; }
.feed-line__ts { color: var(--text-3); flex-shrink: 0; }
.feed-line__tag { flex-shrink: 0; font-weight: 600; }
.feed-line__tag--chat { color: var(--ok); } .feed-line__tag--whisper { color: var(--violet); }
.feed-line__tag--system { color: var(--text-3); } .feed-line__tag--error { color: var(--danger); } .feed-line__tag--outgoing { color: var(--accent); }
.feed-line__body { min-width: 0; }
.feed-line.is-new { animation: lineIn .35s ease-out; }
@keyframes lineIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- economy ------------------------------------------------------------ */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; padding: 16px 20px 20px; }
.tile { background: var(--tile); border: 1px solid var(--tile-border); border-radius: var(--r-md); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile__label { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.tile__value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile--usd .tile__value { color: var(--ok); }
.tile__sub { font-size: 13px; font-weight: 600; color: var(--gold); }
.projgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; padding: 16px 20px 20px; }
.projcard { background: var(--tile); border: 1px solid var(--tile-border); border-radius: var(--r-md); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.projcard--empty { color: var(--text-3); text-align: center; grid-column: 1 / -1; padding: 26px; }
.projcard__label { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.projcard__shards { font-size: 13px; color: var(--text-2); }
.projcard__cur { display: flex; align-items: baseline; gap: 8px; }
.projcard__usd { font-size: 21px; font-weight: 650; color: var(--ok); letter-spacing: -.015em; }
.projcard__inr { font-size: 14px; font-weight: 600; color: var(--gold); }
.projcard__net { font-size: 12.5px; font-weight: 500; }
.projcard__net.is-positive { color: var(--ok); } .projcard__net.is-negative { color: var(--danger); }

/* ---- charts ------------------------------------------------------------- */
.chart-wrap { position: relative; height: 230px; margin: 8px 12px 12px; }
.chart-wrap--lg { height: 310px; margin: 12px 12px 14px; }
.chart-wrap--sm { height: 170px; }
.chart-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }
.chart-tip {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity .12s; white-space: nowrap;
  background: var(--tip-bg); border: 1px solid var(--glass-border); border-radius: 10px; padding: 7px 11px; font-size: 12.5px; box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.chart-tip.is-on { opacity: 1; }
.chart-tip b { display: block; font-weight: 600; margin-bottom: 2px; }
.chart-tip__row { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.chart-tip__row i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---- modals / toasts ---------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(4, 6, 12, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .2s ease both;
}
:root[data-theme="light"] .modal-overlay { background: rgba(30, 40, 70, .28); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--solid); border: 1px solid var(--glass-border); border-radius: var(--r-xl); width: 100%; max-width: 480px; max-height: calc(100dvh - 40px); overflow-y: auto; box-shadow: 0 30px 80px -20px rgba(0,0,0,.6); animation: pop .3s cubic-bezier(.2, 1.1, .3, 1) both; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal__head h3 { font-size: 16px; font-weight: 650; }
.modal__close { background: none; border: 0; color: var(--text-3); font-size: 24px; line-height: 1; cursor: pointer; width: 32px; height: 32px; border-radius: 9px; }
.modal__close:hover { color: var(--text); background: var(--hover); }
.modal__body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal__hint { font-size: 13px; color: var(--text-2); line-height: 1.55; }
.modal__error { background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger); padding: 9px 12px; border-radius: 10px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.field em { font-style: normal; color: var(--text-3); }
.field-row { display: flex; gap: 10px; }
.field--grow { flex: 1; min-width: 0; }
.field--narrow { width: 98px; flex-shrink: 0; }
.field--check { flex-direction: row; align-items: center; gap: 9px; color: var(--text); }
.field--check input { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

.toasts { position: fixed; z-index: 90; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 14px; font-size: 13.5px; font-weight: 500;
  background: var(--tip-bg); border: 1px solid var(--glass-border); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); animation: toastIn .34s cubic-bezier(.2, 1.2, .3, 1) both;
}
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.toast--ok::before { background: var(--ok); } .toast--error::before { background: var(--danger); } .toast--warn::before { background: var(--warn); }
.toast.is-out { animation: toastOut .25s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---- skeleton loading --------------------------------------------------- */
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -80% 0; } }
body.is-loading .sk {
  display: inline-block; min-width: 5ch; border-radius: 8px; color: transparent !important; -webkit-text-fill-color: transparent; user-select: none; pointer-events: none;
  background: linear-gradient(100deg, var(--sk-a) 30%, var(--sk-b) 50%, var(--sk-a) 70%); background-size: 220% 100%; animation: shimmer 1.5s linear infinite;
}
body.is-loading .stat__value.sk, body.is-loading .tile__value.sk { min-width: 9ch; }
body.is-loading .roll__shards .sk { min-width: 6ch; }
body.is-loading .stat__of { opacity: 0; }
.sk-line { display: block; height: 12px; border-radius: 6px; background: linear-gradient(100deg, var(--sk-a) 30%, var(--sk-b) 50%, var(--sk-a) 70%); background-size: 220% 100%; animation: shimmer 1.5s linear infinite; }
.sk-block { border-radius: var(--r-md); background: linear-gradient(100deg, var(--sk-a) 30%, var(--sk-b) 50%, var(--sk-a) 70%); background-size: 220% 100%; animation: shimmer 1.5s linear infinite; }
.skrow td { padding-top: 16px !important; padding-bottom: 16px !important; }
.skrow .sk-av { width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0; }

/* the one orchestrated moment: overview + roster settle in once after first data */
.intro { animation: intro .7s cubic-bezier(.2, .8, .25, 1) both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes intro { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

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

/* ---- breakpoints -------------------------------------------------------- */
@media (min-width: 1000px) {
  .layout--fleet, #fleetView { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); grid-template-areas: "bots feed" "dispatch feed"; grid-template-rows: auto 1fr; align-items: start; }
  .panel--bots { grid-area: bots; }
  .panel--dispatch { grid-area: dispatch; }
  .panel--feed { grid-area: feed; position: sticky; top: calc(78px + var(--safe-t)); height: calc(100vh - 110px); min-height: 460px; }
  #fleetView .dispatch { grid-template-columns: auto 1fr; }
  #fleetView .dispatch__form { grid-column: 1 / -1; }
}
@media (max-width: 999px) { .rolling { grid-template-columns: repeat(3, 1fr); } }

@media (max-width: 720px) {
  body { font-size: 14.5px; padding-bottom: calc(92px + var(--safe-b)); }
  .topbar__inner { flex-wrap: wrap; padding: 10px 14px 10px; gap: 10px 12px; }
  .brand__text small, #connLabel, .players__l { display: none; }
  .brand__text strong { font-size: 15px; }
  .topbar__tools { order: 1; margin-left: auto; }
  .topbar__controls {
    order: 2; flex: 1 1 100%; margin: 0 -14px; padding: 0 14px 2px; overflow-x: auto; scrollbar-width: none; gap: 8px;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 18px), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 18px), transparent 100%);
  }
  .topbar__controls::-webkit-scrollbar { display: none; }
  .players, .switch { flex-shrink: 0; }
  .icon-btn { width: 40px; height: 40px; }
  .accent-pop { right: -48px; }

  .app { padding: 0 14px 24px; }
  .tabs { display: none; }
  #overview { margin-top: 14px; }
  .statstrip { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat__icon { width: 34px; height: 34px; border-radius: 10px; }
  .stat__icon svg { width: 17px; height: 17px; }
  .stat__value { font-size: 17px; }
  .stat--server { grid-column: 1 / -1; }
  .rolling { display: grid; grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 74%; overflow-x: auto; scroll-snap-type: x mandatory; margin: 10px -14px 0; padding: 0 14px 4px; scrollbar-width: none; gap: 10px; }
  .rolling::-webkit-scrollbar { display: none; }
  .roll { scroll-snap-align: center; padding: 12px 16px; }
  .roll__shards { font-size: 23px; }

  .bottomnav {
    display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; z-index: 45; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); padding: 6px; border-radius: 24px;
    background: color-mix(in srgb, var(--solid) 72%, transparent); border: 1px solid var(--glass-border); box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hi);
    -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
  }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px 7px; border-radius: 18px; font-size: 11.5px; font-weight: 600; color: var(--text-3); transition: background .25s, color .25s; }
  .bottomnav a svg { width: 21px; height: 21px; }
  .bottomnav a.is-active { color: var(--accent); background: var(--accent-soft); }
  .toasts { bottom: calc(94px + var(--safe-b)); }

  .layout { gap: 12px; }
  .panel { border-radius: 20px; }
  .panel__head { padding: 14px 16px; }
  .panel__head h2 { font-size: 15.5px; }
  .tiles, .projgrid { padding: 12px 14px 16px; gap: 10px; grid-template-columns: 1fr 1fr; }
  .projcard--empty { grid-column: 1 / -1; }
  .tile__value { font-size: 19px; } .projcard__usd { font-size: 18px; }

  /* roster + earnings tables become cards */
  .bot-table, .bot-table tbody, .bot-table tr, .bot-table td { display: block; }
  .bot-table thead { display: none; }
  .bot-table tbody tr {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-areas: "acc acc acc status" "c1 c2 c3 c4"; gap: 12px 10px;
    padding: 14px 16px; border-bottom: 1px solid var(--line);
  }
  .bot-table tbody tr:last-child { border-bottom: 0; }
  .bot-table tbody tr[data-bot-id]:active { background: var(--hover); }
  .bot-table td, .bot-table td:first-child, .bot-table td:last-child { padding: 0; border: 0; }
  .bot-table td[data-c="acc"] { grid-area: acc; }
  .bot-table td[data-c="status"] { grid-area: status; justify-self: end; }
  .bot-table td[data-c="c1"] { grid-area: c1; } .bot-table td[data-c="c2"] { grid-area: c2; }
  .bot-table td[data-c="c3"] { grid-area: c3; } .bot-table td[data-c="c4"] { grid-area: c4; }
  .bot-table td[data-label]:not([data-c="acc"]):not([data-c="status"])::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--text-3); margin-bottom: 2px; }
  .bot-table .col-proxy, .bot-table .col-actions { display: none; }
  .bot-table__empty { display: block !important; padding: 0 !important; }
  .bot-table__empty td { padding: 26px 16px !important; }
  .bot-table .skrow { display: block; }
  .bot-table--econ tbody tr { grid-template-areas: "acc acc acc status" "c1 c2 c3 c4"; }

  .dispatch { grid-template-columns: 1fr; padding: 14px 16px; }
  .dispatch .seg { width: 100%; } .dispatch .seg__btn { flex: 1; }
  .macros { padding: 0 16px 14px; }
  .panel--feed { height: 62vh; min-height: 420px; }
  .feed { padding: 10px 14px; font-size: 12px; }

  .btn { height: 42px; } .btn--sm { height: 36px; }
  .input, .select, .field input, .field select { height: 44px; font-size: 16px; }
  textarea { font-size: 16px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 24px 24px 0 0; max-height: 92dvh; padding-bottom: var(--safe-b); animation: sheet .38s cubic-bezier(.2, .9, .25, 1) both; }
  @keyframes sheet { from { transform: translateY(100%); } to { transform: none; } }
  .field-row { flex-wrap: wrap; } .field--narrow { width: calc(50% - 5px); }
  .chart-wrap { height: 200px; margin: 6px 6px 10px; }
  .chart-wrap--lg { height: 240px; }
}

/* tablets / small laptops: the switches drop to their own scrollable row instead of overflowing */
@media (max-width: 1060px) {
  .topbar__inner { flex-wrap: wrap; gap: 10px 12px; }
  .topbar__tools { order: 1; margin-left: auto; }
  .topbar__controls {
    order: 2; flex: 1 1 100%; margin: 0; overflow-x: auto; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
            mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  }
  .topbar__controls::-webkit-scrollbar { display: none; }
  .players, .switch { flex-shrink: 0; }
}
