:root {
  --pink: #ff3d81;
  --violet: #8b5cf6;
  --blue: #3b82f6;
  --cyan: #22d3ee;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --teal: #14b8a6;
  --grad-1: linear-gradient(120deg, #ff3d81, #8b5cf6 45%, #3b82f6 75%, #22d3ee);
  --grad-2: linear-gradient(120deg, #22d3ee, #3b82f6, #8b5cf6);
  --grad-3: linear-gradient(120deg, #f59e0b, #ff3d81);
  --radius: 18px;
}

/* ---------- DARK THEME (default fallback) ---------- */
body {
  --bg: #0a0a14;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-2: rgba(255, 255, 255, 0.075);
  --stroke: rgba(255, 255, 255, 0.1);
  --text: #eef0ff;
  --muted: #9aa0c3;
  --input-bg: rgba(0, 0, 0, 0.3);
  --input-focus: rgba(0, 0, 0, 0.45);
  --chip: rgba(255, 255, 255, 0.035);
  --row-hover: rgba(255, 255, 255, 0.04);
  --top-bg: rgba(10, 10, 20, 0.55);
  --side-bg: linear-gradient(180deg, rgba(255, 61, 129, 0.12), rgba(139, 92, 246, 0.09) 45%, rgba(34, 211, 238, 0.08));
  --modal-bg: linear-gradient(160deg, #15152b, #0d0d1c);
  --card-tint: linear-gradient(150deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --glow: 0 12px 30px rgba(255, 61, 129, 0.4);
}

/* ---------- LIGHT THEME (multicolour) ---------- */
body.light {
  --bg: #f3f4fd;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-2: rgba(255, 255, 255, 0.92);
  --stroke: rgba(28, 32, 90, 0.10);
  --text: #15173c;
  --muted: #5d6392;
  --input-bg: rgba(255, 255, 255, 0.95);
  --input-focus: #ffffff;
  --chip: rgba(24, 28, 90, 0.04);
  --row-hover: rgba(99, 102, 241, 0.06);
  --top-bg: rgba(255, 255, 255, 0.65);
  --side-bg: linear-gradient(180deg, rgba(255, 61, 129, 0.16), rgba(139, 92, 246, 0.13) 45%, rgba(34, 211, 238, 0.12));
  --modal-bg: linear-gradient(160deg, #ffffff, #f4f6ff);
  --card-tint: linear-gradient(150deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7));
  --shadow: 0 16px 40px rgba(62, 72, 165, 0.14);
  --glow: 0 12px 28px rgba(139, 92, 246, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .35s ease, color .35s ease;
}

body::before {
  content: '';
  position: fixed;
  inset: -30%;
  background:
    radial-gradient(40% 40% at 15% 20%, rgba(255, 61, 129, 0.30), transparent 70%),
    radial-gradient(38% 38% at 85% 15%, rgba(59, 130, 246, 0.28), transparent 70%),
    radial-gradient(45% 45% at 70% 85%, rgba(139, 92, 246, 0.30), transparent 70%),
    radial-gradient(35% 35% at 25% 90%, rgba(34, 211, 238, 0.24), transparent 70%);
  filter: blur(30px);
  animation: drift 26s ease-in-out infinite alternate;
  z-index: -2;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 46px 46px;
  z-index: -1;
  pointer-events: none;
}
body.light::after {
  background-image: linear-gradient(rgba(35, 40, 120, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35, 40, 120, 0.045) 1px, transparent 1px);
}

@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(2%, -2%, 0) scale(1.06); }
  100% { transform: translate3d(-2%, 2%, 0) scale(1.02); }
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* ============================ AUTH ============================ */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-bg {
  position: absolute; inset: 0;
  background: conic-gradient(from 180deg at 50% 50%, rgba(255,61,129,.20), rgba(139,92,246,.20), rgba(59,130,246,.20), rgba(34,211,238,.20), rgba(255,61,129,.20));
  filter: blur(90px);
  opacity: .6;
  animation: spin 30s linear infinite;
  z-index: -1;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-wrap {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 26px;
  align-items: stretch;
}
.auth-brand {
  padding: 38px 34px;
  border-radius: 26px;
  border: 1px solid var(--stroke);
  background: linear-gradient(160deg, rgba(255,61,129,.16), rgba(139,92,246,.14) 45%, rgba(34,211,238,.12));
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: center; gap: 28px;
}
.logo-xl { display: flex; gap: 16px; align-items: center; }
.logo-mark {
  width: 62px; height: 62px; border-radius: 20px;
  background: var(--grad-1);
  display: grid; place-items: center;
  font-weight: 800; font-size: 30px; color: #fff;
  box-shadow: var(--glow);
  animation: hue 8s linear infinite;
}
.logo-mark.sm { width: 40px; height: 40px; border-radius: 13px; font-size: 19px; }
@keyframes hue { to { filter: hue-rotate(360deg); } }
.auth-brand h1 { font-size: 34px; letter-spacing: -0.5px; }
.auth-brand h1 span { background: var(--grad-1); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-brand p { color: var(--muted); margin-top: 4px; }
.feature-list { list-style: none; display: grid; gap: 12px; }
.feature-list li { display: flex; gap: 12px; align-items: center; font-size: 15px; color: var(--text); opacity: .9; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.dot.c1 { background: var(--pink); box-shadow: 0 0 14px var(--pink); }
.dot.c2 { background: var(--blue); box-shadow: 0 0 14px var(--blue); }
.dot.c3 { background: var(--green); box-shadow: 0 0 14px var(--green); }
.dot.c4 { background: var(--amber); box-shadow: 0 0 14px var(--amber); }

.auth-card {
  padding: 34px;
  border-radius: 26px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  align-self: center;
}
.auth-head { margin-bottom: 20px; }
.auth-head h3 { font-size: 20px; letter-spacing: -.3px; }
.auth-head p { font-size: 13.5px; margin-top: 4px; }
.auth-tabs { display: flex; gap: 8px; background: var(--chip); padding: 6px; border-radius: 14px; margin-bottom: 26px; }
.auth-tabs .tab { flex: 1; }
.auth-form { display: grid; gap: 10px; }
.auth-form label { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 6px; }

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: transparent;
  background: var(--input-focus);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, .65), 0 0 22px rgba(139, 92, 246, .25);
}
select option { background: #ffffff; color: #15173c; }
body:not(.light) select option { background: #14142a; color: var(--text); }

/* ============================ BUTTONS ============================ */
.btn {
  border: none; cursor: pointer; font-family: inherit; font-weight: 600;
  padding: 11px 20px; border-radius: 12px; font-size: 14.5px;
  color: #fff; position: relative; overflow: hidden;
  transition: transform .15s, filter .2s, box-shadow .2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--grad-2); box-shadow: 0 10px 26px rgba(59, 130, 246, .32); }
.btn-accent { background: var(--grad-1); box-shadow: 0 10px 26px rgba(255, 61, 129, .32); }
.btn-warm { background: var(--grad-3); box-shadow: 0 10px 26px rgba(245, 158, 11, .28); }
.btn-ghost { background: var(--panel-2); border: 1px solid var(--stroke); color: var(--text); }
.btn-ghost:hover { background: var(--panel-2); filter: brightness(1.04); }
.btn-danger { background: linear-gradient(120deg, #ef4444, #ff3d81); }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; margin-top: 14px; padding: 13px; }
.icon-btn {
  border: 1px solid var(--stroke); background: var(--panel-2); color: var(--text);
  width: 36px; height: 36px; border-radius: 11px; cursor: pointer; font-size: 15px;
  display: grid; place-items: center; transition: .18s;
}
.icon-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }

/* ============================ LAYOUT ============================ */
.app-screen { display: flex; min-height: 100vh; }

.sidebar {
  width: 262px; flex: none; padding: 22px 16px;
  border-right: 1px solid var(--stroke);
  background: var(--side-bg);
  backdrop-filter: blur(18px);
  display: flex; flex-direction: column; gap: 20px;
  position: sticky; top: 0; height: 100vh;
}
.side-head { display: flex; gap: 12px; align-items: center; padding: 4px 6px 14px; border-bottom: 1px solid var(--stroke); }
.side-head strong { display: block; font-size: 16px; }
.side-head small { color: var(--muted); font-size: 12px; }
.side-nav { display: grid; gap: 5px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 14px; border-radius: 12px; border: 1px solid transparent;
  background: transparent; color: var(--muted); font-family: inherit; font-size: 14.5px;
  font-weight: 600; cursor: pointer; text-align: left; transition: .18s;
}
.nav-item .ico { font-size: 15px; opacity: .85; }
.nav-item:hover { color: var(--text); background: var(--panel-2); }
.nav-item.active {
  color: #fff; border-color: rgba(255,255,255,.16);
  background: var(--grad-1);
  box-shadow: 0 10px 26px rgba(255, 61, 129, .28);
}
.side-foot { margin-top: auto; display: grid; gap: 12px; }
.server-pill, .live-chip {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--stroke);
}
.server-pill.ok { border-color: rgba(34,197,94,.45); color: #16a34a; }
.server-pill.bad { border-color: rgba(239,68,68,.45); color: #dc2626; }
body:not(.light) .server-pill.ok { color: #86efac; }
body:not(.light) .server-pill.bad { color: #fca5a5; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: pulse 2s infinite; }
.server-pill.bad .pulse { background: var(--red); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,.55); }
  70% { box-shadow: 0 0 0 9px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--stroke); }
.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: none; display: grid; place-items: center;
  font-weight: 800; color: #fff; background: var(--grad-2); cursor: pointer; transition: transform .18s;
}
.avatar:hover { transform: scale(1.08); }
.u-meta { flex: 1; min-width: 0; }
.u-meta strong { display: block; font-size: 14px; }
.u-meta small { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 20px 30px;
  border-bottom: 1px solid var(--stroke); backdrop-filter: blur(12px);
  background: var(--top-bg); position: sticky; top: 0; z-index: 20;
}
.page-title h2 { font-size: 22px; letter-spacing: -.3px; }
.page-title p { color: var(--muted); font-size: 13.5px; }
.top-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.menu-btn { display: none; }
.views { padding: 26px 30px 60px; }
.view { display: none; animation: fade .35s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px; backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h3 { font-size: 16.5px; }
.card-head > *:last-child { margin-left: auto; }
.card-head .row > *:last-child { margin-left: 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.split-2 { display: grid; grid-template-columns: 1.15fr .85fr; gap: 20px; }
.stack { display: grid; gap: 8px; }
.stack label { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 8px; }

/* ============================ STATS ============================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
  padding: 18px; border-radius: 16px; border: 1px solid var(--stroke);
  background: var(--panel); position: relative; overflow: hidden; backdrop-filter: blur(14px);
  transition: transform .18s;
}
.stat:hover { transform: translateY(-3px); }
.stat::after {
  content: ''; position: absolute; right: -28px; top: -28px; width: 110px; height: 110px; border-radius: 50%;
  filter: blur(24px); opacity: .5; background: var(--c, var(--violet));
}
.stat .s-label { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; }
.stat .s-value { font-size: 30px; font-weight: 800; margin-top: 6px; letter-spacing: -1px; position: relative; z-index: 1; }
.stat .s-sub { font-size: 12px; color: var(--muted); margin-top: 2px; position: relative; z-index: 1; }

/* ============================ BADGES ============================ */
.badge {
  padding: 4px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .3px; text-transform: uppercase; border: 1px solid transparent; white-space: nowrap;
}
.badge-blue { background: rgba(59,130,246,.16); color: #1d4ed8; border-color: rgba(59,130,246,.35); }
.badge-pink { background: rgba(255,61,129,.16); color: #db2777; border-color: rgba(255,61,129,.35); }
.badge-red { background: rgba(239,68,68,.16); color: #dc2626; border-color: rgba(239,68,68,.35); }
.badge-green { background: rgba(34,197,94,.16); color: #16a34a; border-color: rgba(34,197,94,.35); }
.badge-amber { background: rgba(245,158,11,.16); color: #b45309; border-color: rgba(245,158,11,.35); }
.badge-violet { background: rgba(139,92,246,.16); color: #7c3aed; border-color: rgba(139,92,246,.35); }
.badge-teal { background: rgba(20,184,166,.16); color: #0d9488; border-color: rgba(20,184,166,.35); }
.badge-grey { background: rgba(148,163,184,.16); color: #64748b; border-color: rgba(148,163,184,.3); }
body:not(.light) .badge-blue { color: #93c5fd; }
body:not(.light) .badge-pink { color: #fda4c0; }
body:not(.light) .badge-red { color: #fca5a5; }
body:not(.light) .badge-green { color: #86efac; }
body:not(.light) .badge-amber { color: #fcd34d; }
body:not(.light) .badge-violet { color: #c4b5fd; }
body:not(.light) .badge-teal { color: #5eead4; }
body:not(.light) .badge-grey { color: #cbd5e1; }

/* status colours */
.s-PENDING { background: rgba(245,158,11,.18); color: #b45309; border-color: rgba(245,158,11,.4); }
.s-SENT { background: rgba(59,130,246,.18); color: #1d4ed8; border-color: rgba(59,130,246,.4); }
.s-DELIVERED { background: rgba(139,92,246,.18); color: #7c3aed; border-color: rgba(139,92,246,.4); }
.s-READ { background: rgba(34,197,94,.18); color: #15803d; border-color: rgba(34,197,94,.4); }
.s-PLAYED { background: rgba(20,184,166,.18); color: #0f766e; border-color: rgba(20,184,166,.4); }
.s-FAILED { background: rgba(239,68,68,.18); color: #dc2626; border-color: rgba(239,68,68,.4); }
.s-INCOMING { background: rgba(255,61,129,.18); color: #db2777; border-color: rgba(255,61,129,.4); }
.s-UNKNOWN { background: rgba(148,163,184,.16); color: #64748b; border-color: rgba(148,163,184,.3); }
body:not(.light) .s-PENDING { color: #fcd34d; }
body:not(.light) .s-SENT { color: #93c5fd; }
body:not(.light) .s-DELIVERED { color: #c4b5fd; }
body:not(.light) .s-READ { color: #86efac; }
body:not(.light) .s-PLAYED { color: #5eead4; }
body:not(.light) .s-FAILED { color: #fca5a5; }
body:not(.light) .s-INCOMING { color: #fda4c0; }
body:not(.light) .s-UNKNOWN { color: #cbd5e1; }

/* ============================ TABLES ============================ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; padding: 11px 12px; color: var(--muted);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700;
  border-bottom: 1px solid var(--stroke); white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--stroke); vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--row-hover); }
.table .mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.table .txt { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); padding: 24px; text-align: center; font-size: 13.5px; }

/* ============================ SESSIONS ============================ */
.session-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.session-card {
  border-radius: 16px; border: 1px solid var(--stroke); padding: 18px;
  background: var(--card-tint);
  display: grid; gap: 12px;
}
.session-card .s-head { display: flex; align-items: center; gap: 10px; }
.session-card h4 { font-size: 15px; flex: 1; word-break: break-all; }
.session-card .s-meta { font-size: 12.5px; color: var(--muted); display: grid; gap: 4px; }
.session-card .s-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.session-card .s-qr { display: flex; gap: 14px; align-items: center; }
.mini-qr {
  width: 118px; height: 118px; border-radius: 12px; background: #fff; padding: 5px;
  box-shadow: 0 8px 20px rgba(20, 25, 80, .18); image-rendering: pixelated; flex: none;
}
.mini-qr-note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.qr-live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.st-WORKING { background: var(--green); box-shadow: 0 0 12px var(--green); }
.st-SCAN_QR_CODE { background: var(--amber); box-shadow: 0 0 12px var(--amber); }
.st-STARTING { background: var(--blue); box-shadow: 0 0 12px var(--blue); }
.st-STOPPED { background: #94a3b8; box-shadow: 0 0 12px rgba(148,163,184,.7); }
.st-FAILED { background: var(--red); box-shadow: 0 0 12px var(--red); }

/* ============================ KEY BOX ============================ */
.key-box { border: 1px solid rgba(239,68,68,.3); background: rgba(239,68,68,.08); border-radius: 14px; padding: 14px; margin-bottom: 16px; }
.key-box-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.key-box-head h4 { font-size: 14px; }
.key-row { display: flex; gap: 8px; align-items: center; }
.key-row code {
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px; flex: 1;
  background: var(--chip); padding: 9px 12px; border-radius: 10px; overflow-x: auto; white-space: nowrap;
}

/* ============================ LOG ============================ */
.log-list { display: grid; gap: 8px; max-height: 320px; overflow-y: auto; }
.log-item { display: flex; gap: 10px; align-items: center; font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--chip); }
.log-item time { color: var(--muted); font-size: 11.5px; font-family: 'JetBrains Mono', monospace; flex: none; }

/* ============================ PHONE PREVIEW ============================ */
.phone { border-radius: 22px; border: 1px solid var(--stroke); background: #0b0c1a; overflow: hidden; }
.phone-top { display: flex; gap: 7px; padding: 11px 14px; background: rgba(255,255,255,.06); }
.phone-dot { width: 10px; height: 10px; border-radius: 50%; }
.phone-dot.r { background: #ff5f57; } .phone-dot.y { background: #febc2e; } .phone-dot.g { background: #28c840; }
.phone-body { padding: 26px 18px; min-height: 260px; background: radial-gradient(60% 50% at 80% 0%, rgba(139,92,246,.28), transparent 70%), #0a0c18; }
.bubble { background: var(--grad-2); padding: 11px 14px; border-radius: 14px 14px 14px 4px; max-width: 85%; font-size: 14px; line-height: 1.45; word-break: break-word; box-shadow: 0 8px 20px rgba(59,130,246,.25); }
.bubble-meta { font-size: 11.5px; color: #9aa0c3; margin-bottom: 8px; }
.bubble-meta.right { text-align: right; margin: 8px 0 0; }

/* ============================ MODAL ============================ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(40, 42, 90, .35); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .2s ease; }
body:not(.light) .modal-backdrop { background: rgba(5, 5, 14, .72); }
.modal { width: min(520px, 100%); max-height: 90vh; overflow-y: auto; border-radius: 22px; border: 1px solid var(--stroke); background: var(--modal-bg); box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--stroke); }
.modal-head h3 { font-size: 17px; flex: 1; }
.modal-body { padding: 20px; display: grid; gap: 14px; }
.qr-wrap { display: grid; place-items: center; padding: 14px; border-radius: 16px; background: #fff; border: 1px solid var(--stroke); }
.qr-wrap img { width: 260px; height: 260px; image-rendering: pixelated; }
.qr-wrap img.qr-loading { opacity: .25; filter: grayscale(1); }
.pair-code { font-family: 'JetBrains Mono', monospace; font-size: 34px; text-align: center; letter-spacing: 5px; padding: 16px; border-radius: 14px; background: var(--chip); border: 1px dashed var(--stroke); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; min-width: 130px; padding: 7px 11px; font-size: 13px; }

/* ============================ TOASTS ============================ */
.toasts { position: fixed; right: 22px; bottom: 22px; display: grid; gap: 10px; z-index: 200; }
.toast {
  padding: 13px 17px; border-radius: 13px; font-size: 14px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--stroke); backdrop-filter: blur(12px);
  box-shadow: var(--shadow); animation: slideIn .28s ease; max-width: 380px;
}
.toast.ok { border-color: rgba(34,197,94,.5); color: #16a34a; }
.toast.err { border-color: rgba(239,68,68,.5); color: #dc2626; }
.toast.info { border-color: rgba(59,130,246,.5); color: #1d4ed8; }
body:not(.light) .toast.ok { color: #86efac; }
body:not(.light) .toast.err { color: #fca5a5; }
body:not(.light) .toast.info { color: #93c5fd; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================ FORM MSG ============================ */
.form-msg { font-size: 13px; min-height: 18px; margin-top: 6px; }
.form-msg.ok { color: #16a34a; }
.form-msg.err { color: #dc2626; }
body:not(.light) .form-msg.ok { color: #86efac; }
body:not(.light) .form-msg.err { color: #fca5a5; }

/* ============================ USERS & QUOTAS ============================ */
.quota-wrap { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.quota-bar {
  height: 7px; border-radius: 999px; background: var(--chip); overflow: hidden;
  border: 1px solid var(--stroke); min-width: 90px;
}
.quota-bar.wide { width: 100%; margin-bottom: 18px; height: 9px; }
.quota-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #22d3ee);
  transition: width .4s ease;
}
.quota-bar.full .quota-fill { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.quota-cell { display: grid; gap: 6px; min-width: 120px; }
.quota-cell .quota-bar { width: 100%; }
.check-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13.5px; color: var(--text); }
.check-row input { width: 18px; height: 18px; accent-color: #8b5cf6; }
.admin-only { display: none; }
body.admin .admin-only { display: flex; }
.table .addr { max-width: 220px; white-space: normal; line-height: 1.4; }
.detail-grid { display: grid; gap: 8px; }
.detail-row {
  display: flex; justify-content: space-between; gap: 14px; padding: 9px 12px;
  border-radius: 10px; background: var(--chip); font-size: 13.5px;
}
.detail-row span { color: var(--muted); font-weight: 600; }
.detail-row strong { text-align: right; word-break: break-word; }
.modal form.stack { gap: 6px; }
.modal .row > div > label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }

/* ============================ COMPOSE / UPLOAD ============================ */
.compose-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; align-items: start; }
.preview-card { position: sticky; top: 92px; }
.tabs { display: flex; gap: 8px; }
.compose-tabs { background: var(--chip); padding: 6px; border-radius: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.compose-tabs .tab { flex: 1; }
.tab {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  padding: 9px 15px; border-radius: 10px; font-family: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; transition: .18s; white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active {
  color: #fff; background: var(--grad-1); border-color: rgba(255,255,255,.16);
  box-shadow: 0 8px 20px rgba(255, 61, 129, .28);
}
.upload-zone {
  position: relative; border: 2px dashed var(--stroke); border-radius: 16px;
  padding: 22px; text-align: center; transition: .2s; background: var(--chip);
}
.upload-zone:hover { border-color: var(--violet); background: rgba(139, 92, 246, .06); }
.upload-zone.compact { padding: 16px; }
.upload-zone input[type='file'] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-hint { display: grid; gap: 5px; justify-items: center; pointer-events: none; }
.upload-icon { font-size: 26px; }
.upload-hint strong { font-size: 14.5px; }
.upload-hint small { color: var(--muted); font-size: 12px; }
.file-chip {
  display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--stroke);
}
.file-chip strong { display: block; font-size: 13.5px; word-break: break-all; }
.file-chip small { color: var(--muted); font-size: 12px; }
.file-thumb { width: 58px; height: 58px; object-fit: cover; border-radius: 10px; flex: none; }
.file-icon {
  width: 52px; height: 52px; border-radius: 12px; flex: none; display: grid; place-items: center;
  font-size: 22px; background: var(--grad-1); color: #fff;
}
.preview-media { margin-top: 10px; }
.preview-img { max-width: 85%; border-radius: 12px; display: block; box-shadow: 0 8px 20px rgba(0,0,0,.3); }
.preview-file {
  background: rgba(255,255,255,.1); padding: 9px 12px; border-radius: 12px; font-size: 13px;
  display: inline-block; max-width: 85%;
}
.media-cell { font-size: 12px; color: var(--muted); margin-top: 4px; }
.media-cell a { color: var(--violet); text-decoration: none; font-weight: 700; }
.bulk-preview {
  border: 1px solid var(--stroke); border-radius: 14px; padding: 12px; background: var(--chip);
  max-height: 300px; overflow: auto;
}
.progress { height: 10px; border-radius: 999px; background: var(--chip); overflow: hidden; border: 1px solid var(--stroke); }
.progress-bar {
  height: 100%; width: 0%; border-radius: 999px;
  background: var(--grad-1); transition: width .4s ease;
}
@media (max-width: 1080px) {
  .compose-grid { grid-template-columns: 1fr; }
  .preview-card { position: static; }
}

/* ============================ RESPONSIVE ============================ */
@media (max-width: 1080px) {
  .split, .split-2 { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { padding: 26px; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .28s ease; z-index: 60; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .views { padding: 18px 14px 50px; }
  .topbar { padding: 14px 16px; }
}
