/* ZapCap admin console — same palette as the app: near-black, violet→pink→orange gradient, yellow accent. */
:root {
  --bg: #09090e;
  --surface: #12121a;
  --surface-2: #1a1a25;
  --surface-3: #232331;
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f5f8;
  --muted: rgba(255, 255, 255, 0.56);
  --faint: rgba(255, 255, 255, 0.32);
  --yellow: #ffe04d;
  --violet: #8c5cf5;
  --pink: #ed4799;
  --orange: #fa913d;
  --mint: #3ee0b0;
  --cyan: #45c8f0;
  --red: #ff5d6c;
  --gradient: linear-gradient(135deg, #4d1c94 0%, #db2678 55%, #fa913d 100%);
  --radius: 18px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--yellow); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- boot & auth */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--stroke-strong); border-top-color: var(--yellow); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.auth::before, .auth::after { content: ''; position: absolute; border-radius: 50%; filter: blur(110px); opacity: .5; pointer-events: none; }
.auth::before { width: 460px; height: 460px; background: var(--violet); top: -160px; left: -120px; }
.auth::after { width: 380px; height: 380px; background: var(--pink); bottom: -160px; right: -100px; opacity: .35; }
.auth-card { position: relative; z-index: 1; width: 100%; max-width: 400px; background: rgba(18, 18, 26, .86); backdrop-filter: blur(20px); border: 1px solid var(--stroke); border-radius: 26px; padding: 30px; display: grid; gap: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.auth-card h1 { font-size: 28px; font-weight: 900; }
.auth-card p { margin: 0; line-height: 1.5; }
.demo-link { font-size: 13px; text-align: center; color: var(--muted); }
.msg { min-height: 18px; font-size: 13px; color: var(--muted); }
.msg.error { color: var(--red); }
.msg.ok { color: var(--mint); }

/* ---------------------------------------------------------------- brand */
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 17px; font-weight: 900; letter-spacing: -0.02em; }
.brand small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.logo { width: 36px; height: 36px; border-radius: 11px; background: var(--yellow); color: #111; display: grid; place-items: center; box-shadow: 0 8px 24px rgba(255, 224, 77, .25); flex: none; }
.logo svg { width: 20px; height: 20px; }
.brand.big .logo { width: 48px; height: 48px; border-radius: 14px; }
.brand.big .logo svg { width: 26px; height: 26px; }

/* ---------------------------------------------------------------- form controls */
.stack { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input:not([type]), select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 12px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: rgba(255, 224, 77, .6); box-shadow: 0 0 0 3px rgba(255, 224, 77, .12); }
input[type=number] { font-variant-numeric: tabular-nums; }
.code-input { font-size: 26px; letter-spacing: .4em; text-align: center; font-weight: 800; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 10px 16px; font-weight: 700; cursor: pointer; background: var(--surface-3); transition: transform .08s, background .15s, opacity .15s; white-space: nowrap; }
.btn:hover { background: #2b2b3b; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: linear-gradient(90deg, var(--yellow), #ffb43d); color: #111; box-shadow: 0 8px 22px rgba(255, 200, 60, .22); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: var(--stroke-strong); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: rgba(255, 93, 108, .14); color: var(--red); border-color: rgba(255, 93, 108, .3); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }

/* ---------------------------------------------------------------- layout */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; border-right: 1px solid var(--stroke); background: linear-gradient(180deg, rgba(140, 92, 245, .08), transparent 40%), var(--bg); display: flex; flex-direction: column; gap: 26px; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted); font-weight: 600; }
.sidebar nav a svg { width: 18px; height: 18px; }
.sidebar nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--yellow); }
.me { margin-top: auto; display: grid; gap: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--stroke); border-radius: 16px; }
.me-email { font-size: 12px; color: var(--muted); word-break: break-all; }

.main { padding: 28px 32px 60px; min-width: 0; max-width: 1400px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 30px; font-weight: 900; }
.page-head p { margin: 6px 0 0; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.head-actions select { width: auto; padding: 8px 12px; }

.loading { padding: 60px; display: grid; place-items: center; }
.error-box { padding: 18px; border-radius: 14px; background: rgba(255, 93, 108, .1); border: 1px solid rgba(255, 93, 108, .3); color: #ffc2c8; }

/* ---------------------------------------------------------------- cards & KPIs */
.card { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 16px; font-weight: 800; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.chart { position: relative; height: 230px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 16px 16px 15px; display: grid; gap: 4px; }
.kpi::after { content: ''; position: absolute; width: 140px; height: 140px; border-radius: 50%; right: -60px; top: -70px; background: var(--accent, var(--violet)); opacity: .14; filter: blur(8px); }
.kpi .label { font-size: 12px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.kpi .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent, var(--violet)); box-shadow: 0 0 10px var(--accent, var(--violet)); }
.kpi .value { font-size: 28px; font-weight: 900; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.hero { background: var(--gradient); border: none; }
.kpi.hero .label, .kpi.hero .sub { color: rgba(255, 255, 255, .85); }
.kpi.hero::after { background: #fff; opacity: .12; }

/* ---------------------------------------------------------------- pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .02em; background: var(--surface-3); color: var(--text); white-space: nowrap; }
.pill.yellow { background: rgba(255, 224, 77, .14); color: var(--yellow); }
.pill.violet { background: rgba(140, 92, 245, .18); color: #b69bff; }
.pill.pink { background: rgba(237, 71, 153, .16); color: #ff8cc4; }
.pill.mint { background: rgba(62, 224, 176, .14); color: var(--mint); }
.pill.cyan { background: rgba(69, 200, 240, .14); color: var(--cyan); }
.pill.red { background: rgba(255, 93, 108, .15); color: var(--red); }
.pill.grad { background: var(--gradient); color: #fff; }

/* ---------------------------------------------------------------- tables & lists */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--stroke); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--stroke); vertical-align: middle; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; transition: background .12s; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.right, th.right { text-align: right; }
.table-foot { padding: 12px 16px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--stroke); }

.user-cell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gradient); display: grid; place-items: center; font-weight: 900; font-size: 14px; flex: none; color: #fff; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.user-cell b { display: block; font-weight: 700; }
.user-cell small { color: var(--muted); font-size: 12px; }

.feed { list-style: none; margin: 0; padding: 0; display: grid; }
.feed li { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--stroke); }
.feed li:last-child { border-bottom: none; }
.feed .ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; flex: none; }
.feed .what { flex: 1; min-width: 0; }
.feed .what b { font-weight: 700; }
.feed .what small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amt { font-weight: 800; font-variant-numeric: tabular-nums; }
.amt.plus { color: var(--mint); }
.ico.yellow { background: rgba(255, 224, 77, .14); }
.ico.violet { background: rgba(140, 92, 245, .18); }
.ico.mint { background: rgba(62, 224, 176, .14); }
.ico.cyan { background: rgba(69, 200, 240, .14); }
.ico.pink { background: rgba(237, 71, 153, .16); }

.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--gradient); border-radius: 99px; }

/* ---------------------------------------------------------------- toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search { flex: 1; min-width: 220px; position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }
.search input { padding-left: 38px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 13px; border-radius: 999px; border: 1px solid var(--stroke-strong); background: transparent; cursor: pointer; font-weight: 700; font-size: 13px; color: var(--muted); }
.chip.on { background: var(--text); color: #111; border-color: var(--text); }

/* ---------------------------------------------------------------- notice */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: rgba(255, 224, 77, .07); border: 1px solid rgba(255, 224, 77, .22); margin-bottom: 18px; line-height: 1.5; color: rgba(255, 255, 255, .85); }
.notice svg { width: 18px; height: 18px; color: var(--yellow); flex: none; margin-top: 2px; }

/* ---------------------------------------------------------------- plans */
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.plan { display: grid; gap: 12px; position: relative; transition: border-color .2s, box-shadow .2s; }
.plan.dirty { border-color: rgba(255, 224, 77, .5); box-shadow: 0 0 0 3px rgba(255, 224, 77, .08); }
.plan.inactive { opacity: .62; }
.plan-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.emoji-input { width: 64px !important; height: 56px; font-size: 30px; text-align: center; padding: 4px !important; border-radius: 14px !important; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 0.8fr; gap: 10px; }
.plan-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 4px; border-top: 1px solid var(--stroke); margin-top: 2px; padding-top: 12px; }
.permin { font-size: 12px; color: var(--muted); font-weight: 600; }
.pid { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan .badge-preview { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch span { width: 42px; height: 24px; border-radius: 99px; background: var(--surface-3); position: relative; transition: background .2s; }
.switch span::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform .2s; }
.switch input:checked + span { background: var(--mint); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--muted); }

/* ---------------------------------------------------------------- drawer */
.drawer { position: fixed; inset: 0; z-index: 40; display: flex; justify-content: flex-end; background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); animation: fade .15s ease; }
.drawer-panel { width: min(480px, 100%); height: 100%; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--stroke); padding: 22px; display: grid; gap: 18px; align-content: start; animation: slide .2s ease; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 14px; }
.drawer-head .who { flex: 1; min-width: 0; }
.drawer-head h2 { font-size: 20px; font-weight: 800; }
.drawer-head small { color: var(--muted); word-break: break-all; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--stroke); cursor: pointer; flex: none; }
.icon-btn svg { width: 16px; height: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.stat small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.stat b { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.segmented { display: inline-grid; grid-auto-flow: column; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.segmented label { cursor: pointer; }
.segmented input { display: none; }
.segmented span { display: block; padding: 7px 14px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--muted); }
.segmented input:checked + span { background: var(--surface-3); color: var(--text); }
.adjust-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: end; }
.section-title { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.drawer-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- toast */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; z-index: 60; background: var(--text); color: #111; font-weight: 700; padding: 12px 18px; border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, .5); transition: transform .25s, opacity .25s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); color: #fff; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 12px 16px; border-right: none; border-bottom: 1px solid var(--stroke); background: rgba(9, 9, 14, .92); backdrop-filter: blur(14px); overflow-x: auto; }
  .sidebar .brand small, .sidebar .brand b { display: none; }
  .sidebar nav { display: flex; gap: 4px; }
  .sidebar nav a { padding: 8px 10px; }
  .sidebar nav a span { display: none; }
  .sidebar nav a.active { box-shadow: inset 0 -2px 0 var(--yellow); }
  .me { margin: 0 0 0 auto; padding: 0; background: none; border: none; display: flex; align-items: center; }
  .me-email { display: none; }
  .main { padding: 20px 16px 50px; }
  .page-head h1 { font-size: 24px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr; }
  .kpi .value { font-size: 24px; }
}
