:root { --bg:#0f1216; --panel:#171c23; --line:#262d37; --ink:#e6eaf0; --muted:#8b96a5; --accent:#4f9cf9; --ok:#3fb950; --bad:#f85149; --warn:#d29922; }
* { box-sizing: border-box; }
body { margin:0; font:14px/1.5 system-ui, sans-serif; background:var(--bg); color:var(--ink); }
header { display:flex; justify-content:space-between; align-items:center; padding:14px 22px; border-bottom:1px solid var(--line); }
h1 { font-size:17px; margin:0; }
h2 { font-size:15px; margin:0 0 12px; }
main { padding:22px; max-width:1100px; margin:0 auto; }
/* ---- app shell: sidebar + content ---- */
#shell { display:flex; min-height:100vh; }
#shell[hidden] { display:none !important; }
#sidebar { width:230px; flex-shrink:0; background:#0d0d0d; border-right:1px solid #2b2b2b; display:flex; flex-direction:column; padding:18px 14px; }
#sidebar .brand-lockup.side { display:flex; align-items:center; gap:10px; margin:6px 6px 26px; }
#sidebar .brand-mark { width:36px; height:36px; border-radius:9px; }
#sidebar .brand-word { font-size:15px; font-weight:700; color:#fff; }
#nav { display:flex; flex-direction:column; gap:6px; }
/* icon on the right of the label, label group right-aligned (matches rtkpremium portal) */
.nav-item { display:flex; align-items:center; justify-content:flex-end; gap:12px; width:100%; background:none; border:none; color:var(--muted); padding:11px 12px; border-radius:8px; cursor:pointer; font:inherit; font-weight:500; }
.nav-item span { order:1; }
.nav-item svg { order:2; flex-shrink:0; }
.nav-item:hover { background:#1b1b1b; color:var(--ink); }
.nav-item.active { background:#1b1b1b; color:var(--accent); }
/* hidden must beat the display:flex above (else admin/users tabs show for viewers) */
.nav-item[hidden] { display:none !important; }
.sidebar-foot { margin-top:auto; border-top:1px solid #2b2b2b; padding-top:12px; }
.sidebar-foot #who { padding:4px 12px 10px; font-size:12px; line-height:1.7; }
/* min-width:0 lets this flex child shrink below its content's intrinsic width, so a
   wide .table-wrap scrolls internally instead of stretching the page (horizontal overflow). */
#content { flex:1; min-width:0; max-width:none; margin:0; padding:26px 32px; background:#0d0d0d; }
.page-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; flex-wrap:wrap; gap:10px; }
.head-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.small { font-size:12px; }
.viewtoggle { display:flex; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
.viewtoggle button { background:transparent; border:none; color:var(--muted); padding:7px 16px; cursor:pointer; font:inherit; }
.viewtoggle button.active { background:var(--panel); color:var(--ink); }
.search { width:100%; max-width:420px; margin-bottom:16px; padding:9px 12px; background:#0c0f13; border:1px solid var(--line); border-radius:8px; color:var(--ink); font:inherit; }
button { font:inherit; }
.btn { background:var(--accent); color:#06121f; border:none; padding:7px 13px; border-radius:7px; cursor:pointer; font-weight:600; }
.btn.ghost { background:transparent; color:var(--accent); border:1px solid var(--line); }
input, select { background:#0c0f13; border:1px solid var(--line); color:var(--ink); padding:8px 10px; border-radius:7px; }
form#login-form { display:flex; gap:8px; }

/* ---- two-panel login (mimics rtkpremium.xyz sign-in) ---- */
#login-view.login-wrap { position:fixed; inset:0; z-index:50; display:flex; background:var(--bg); }
/* hidden must win over the display:flex above, or the overlay never goes away after sign-in */
#login-view[hidden] { display:none !important; }
.login-left, .login-right { flex:1; display:flex; flex-direction:column; justify-content:center; padding:48px; }
.login-left { align-items:center; }
.login-right { border-left:1px solid var(--line); padding-left:72px; }
.login-box { width:100%; max-width:340px; }
.signin-title { text-align:right; font-size:30px; font-weight:600; color:#c4ccd6; margin:0 0 26px; }
.login-box label { display:block; font-size:13px; color:#cfd5dc; margin:14px 0 6px; }
.login-box input { width:100%; padding:11px 12px; background:#0c0f13; border:1px solid var(--line); border-radius:8px; color:var(--ink); font:inherit; }
.btn-primary { width:100%; margin-top:22px; padding:12px; background:#1d4e74; color:#e6eef6; border:none; border-radius:8px; font-weight:600; cursor:pointer; }
.btn-primary:hover { background:#235d8a; }
.linkbtn { display:block; margin:14px auto 0; background:none; border:none; color:var(--accent); cursor:pointer; font:inherit; }
.invite-note { margin-top:20px; text-align:center; }
#sso-area .btn { width:100%; text-align:center; box-sizing:border-box; }
.brand-lockup { display:flex; align-items:center; gap:14px; margin-bottom:40px; }
.brand-mark { width:46px; height:46px; border-radius:11px; }
.brand-word { font-size:21px; font-weight:700; color:#fff; }
.brand-title { font-size:30px; font-weight:700; color:#878f9b; margin:0 0 10px; }
.brand-sub { color:#9aa3af; margin:0 0 24px; max-width:420px; }
.btn-support { display:inline-block; width:max-content; background:#1a73e8; color:#fff; padding:10px 24px; border-radius:8px; font-weight:600; text-decoration:none; }
.btn-support:hover { background:#1b66c9; }
.pager { display:flex; align-items:center; gap:10px; margin-top:12px; color:var(--muted); font-size:13px; }
.btn.ghost[disabled] { opacity:.4; cursor:default; }

@media (max-width:760px) {
  #login-view.login-wrap { flex-direction:column; }
  .login-left, .login-right { padding:30px 22px; }
  .login-right { border-left:none; border-top:1px solid var(--line); padding-left:22px; }
  .signin-title { font-size:26px; }
  .brand-title { font-size:24px; }
  /* sidebar becomes a top bar; nav scrolls horizontally */
  #shell { flex-direction:column; min-height:auto; }
  #sidebar { width:auto; border-right:none; border-bottom:1px solid #2b2b2b; padding:12px; }
  #sidebar .brand-lockup.side { margin:0 0 10px; }
  #nav { flex-direction:row; flex-wrap:wrap; gap:4px; }
  .nav-item { width:auto; justify-content:flex-start; min-height:42px; }
  .sidebar-foot { margin-top:12px; }
  #content { padding:18px 14px; }
  .page-head { align-items:flex-start; }
  /* comfortable tap targets */
  .btn, .viewtoggle button, .btn-primary, .search { min-height:42px; }
  .rcard-stats { gap:34px; }
}
/* Hide the login screen during boot for an already-signed-in user (the inline head
   script adds .booting when a token exists), so it doesn't flash before boot() swaps
   in the app. Cleared on boot success, or on a stale token to reveal login. */
html.booting #login-view { display:none !important; }
.hint { color:var(--muted); }
.error { color:var(--bad); }
code { background:#0c0f13; padding:1px 5px; border-radius:4px; }
/* wide tables scroll horizontally within their card rather than overflow the page.
   The min-width only forces a scroll when the container is narrower than it (phones +
   portrait tablets); on a wide desktop the table just fills 100% as before. */
.table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
.table-wrap table { min-width:520px; }
table { width:100%; border-collapse:collapse; margin-top:8px; }
th, td { text-align:left; padding:9px 10px; border-bottom:1px solid var(--line); }
th { color:var(--muted); font-weight:600; font-size:12px; text-transform:uppercase; letter-spacing:.04em; }
tr.click { cursor:pointer; }
tr.click:hover { background:var(--panel); }
tr.click:hover td:first-child { color:var(--accent); }
td.chev, th.chev { width:28px; text-align:right; color:var(--muted); font-size:18px; line-height:1; }
tr.click td.chev { transition:transform .1s ease; }
tr.click:hover td.chev { color:var(--accent); }
.card { background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:16px; margin-bottom:14px; }
.grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:16px; }

/* reseller cards — formalised */
.rcard { padding:20px; }
.rcard-head { display:flex; flex-direction:column; align-items:center; text-align:center; gap:7px; padding-bottom:14px; border-bottom:1px solid var(--line); margin-bottom:18px; }
.rcard-name { font-size:16px; font-weight:700; letter-spacing:.01em; }
.rcard-id { font-size:12px; color:var(--muted); margin-top:1px; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }
.rcard-stats { display:flex; justify-content:center; gap:48px; margin-bottom:18px; }
.stat { text-align:center; }
.stat-num { font-size:30px; font-weight:700; line-height:1; }
.stat-label { font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); margin-top:7px; }
.rcard-actions { display:flex; justify-content:center; gap:8px; }
/* alias block — consistent stacked layout across cards */
.alias { margin-top:16px; text-align:left; }
.alias-label { font-size:12px; color:var(--muted); margin-bottom:6px; }
.alias-email { display:block; background:#0c0f13; border:1px solid var(--line); border-radius:7px; padding:8px 10px; font-size:12px; word-break:break-all; margin-bottom:8px; }
.alias .copy { padding:4px 12px; }
.pill { display:inline-block; padding:2px 8px; border-radius:99px; font-size:12px; font-weight:600; }
.pill.ok { background:rgba(63,185,80,.15); color:var(--ok); }
.pill.bad { background:rgba(248,81,73,.15); color:var(--bad); }
.pill.warn { background:rgba(210,153,34,.15); color:var(--warn); }
.muted { color:var(--muted); }
.row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.crumbs { margin-bottom:12px; color:var(--muted); }
.crumbs a { color:var(--accent); cursor:pointer; text-decoration:none; }
.big { font-size:26px; font-weight:700; }
fieldset { border:1px solid var(--line); border-radius:9px; margin:0 0 14px; padding:14px; }
fieldset legend { color:var(--muted); padding:0 6px; }
label { display:block; margin:8px 0 3px; color:var(--muted); font-size:12px; }
label input { width:100%; }
