/* =========================================================================
   BonusPage Control Panel — meta-admin theme (slate + indigo/cyan)
   Vanilla CSS, no external fonts/assets. Dark only.
   ========================================================================= */

:root {
  --bg:          #0b1020;
  --bg-grad-1:   #0e1430;
  --bg-grad-2:   #0a0f1e;
  --surface:     #121a33;
  --surface-2:   #161f3d;
  --surface-3:   #1b2549;
  --border:      #25305a;
  --border-soft: #1c2645;
  --text:        #e8ecf8;
  --muted:       #93a0c4;
  --muted-2:     #6b78a0;

  --indigo:      #6366f1;
  --indigo-2:    #818cf8;
  --cyan:        #22d3ee;
  --cyan-2:      #67e8f9;
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #22d3ee 100%);

  --green:       #34d399;
  --green-bg:    rgba(52, 211, 153, .12);
  --green-bd:    rgba(52, 211, 153, .35);
  --orange:      #fbbf24;
  --orange-bg:   rgba(251, 191, 36, .12);
  --orange-bd:   rgba(251, 191, 36, .35);
  --red:         #f87171;
  --red-bg:      rgba(248, 113, 113, .12);
  --red-bd:      rgba(248, 113, 113, .38);
  --grey:        #64748b;
  --grey-bg:     rgba(100, 116, 139, .14);
  --grey-bd:     rgba(100, 116, 139, .32);

  --radius:   16px;
  --radius-s: 10px;
  --radius-xs: 8px;
  --shadow:   0 18px 40px -18px rgba(0,0,0,.7);
  --shadow-s: 0 6px 18px -10px rgba(0,0,0,.6);
  --ring:     0 0 0 3px rgba(99,102,241,.35);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
          Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 12% -8%, rgba(99,102,241,.16), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(34,211,238,.12), transparent 55%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--cyan-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1,h2,h3,h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

.boot {
  display: grid; place-items: center; min-height: 100vh;
  color: var(--muted); font-size: 15px;
}

/* ------------------------------------------------------------------ utils */
.row { display: flex; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.row.aic { align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.center { text-align: center; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  background: rgba(11,16,32,.78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.brand-mark {
  display: flex; align-items: center; gap: 11px;
  font-weight: 800; letter-spacing: -.02em; font-size: 16px;
  cursor: pointer; user-select: none;
}
.brand-logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent-grad);
  display: grid; place-items: center;
  box-shadow: 0 6px 16px -6px rgba(99,102,241,.7);
  flex: none;
}
.brand-logo svg { width: 17px; height: 17px; display: block; }
.brand-sub { color: var(--muted-2); font-weight: 600; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }

.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  padding: 8px 14px; border-radius: 999px;
  color: var(--muted); font-weight: 600; font-size: 13.5px;
  text-decoration: none; transition: .16s;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(99,102,241,.4), rgba(34,211,238,.28));
  box-shadow: inset 0 0 0 1px rgba(129,140,248,.4);
}

.userbox { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--cyan));
  display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #06121f;
  flex: none;
}
.uname { font-weight: 600; font-size: 13.5px; }

/* ------------------------------------------------------------------ layout */
.wrap-main { max-width: 1180px; margin: 0 auto; padding: 28px 22px 80px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 26px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

.breadcrumb { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--cyan-2); }

/* ------------------------------------------------------------------ buttons */
.btn {
  --b: var(--surface-3);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-s);
  border: 1px solid var(--border);
  background: var(--b); color: var(--text);
  font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; transition: .15s; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: var(--indigo-2); background: var(--surface-3); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn .ic { width: 15px; height: 15px; }

/* Inline icons carry no width/height attributes — size them via CSS so they
   don't balloon to fill their flex container outside of buttons. */
.ic { width: 16px; height: 16px; flex: none; }
.section-note .ic { width: 18px; height: 18px; margin-top: 1px; }
.login-err .ic { width: 16px; height: 16px; }
.state .ico .ic { width: 34px; height: 34px; }

.btn-primary {
  border: none;
  background: var(--accent-grad);
  color: #06121f; font-weight: 700;
  box-shadow: 0 10px 24px -12px rgba(99,102,241,.9);
}
.btn-primary:hover { filter: brightness(1.07); background: var(--accent-grad); }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-danger { background: var(--red-bg); border-color: var(--red-bd); color: #fecaca; }
.btn-danger:hover { background: rgba(248,113,113,.2); border-color: var(--red); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: var(--radius-xs); }
.btn-block { width: 100%; }

/* ------------------------------------------------------------------ cards */
.card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-s);
}
.card-pad { padding: 18px 20px; }

.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
}

/* instance card */
.inst {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 19px 17px;
  transition: .18s;
}
.inst::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent-grad); opacity: .7;
}
.inst:hover { border-color: var(--border); transform: translateY(-2px); box-shadow: var(--shadow); }
.inst-top { display: flex; align-items: flex-start; gap: 10px; }
.inst-brand { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.inst-domain { font-size: 13px; color: var(--cyan-2); word-break: break-all; }
.inst-domain:hover { text-decoration: underline; }

.stats { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .k { font-size: 11px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 14px; font-weight: 700; }

.inst-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.inst-actions .btn { flex: 1 1 auto; }

/* ------------------------------------------------------------------ pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
  border: 1px solid var(--grey-bd); background: var(--grey-bg); color: var(--muted);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.green  { color: var(--green);  background: var(--green-bg);  border-color: var(--green-bd); }
.pill.orange { color: var(--orange); background: var(--orange-bg); border-color: var(--orange-bd); }
.pill.red    { color: var(--red);    background: var(--red-bg);    border-color: var(--red-bd); }
.pill.grey   { color: var(--muted);  background: var(--grey-bg);   border-color: var(--grey-bd); }
.pill.cyan   { color: var(--cyan);   background: rgba(34,211,238,.12); border-color: rgba(34,211,238,.32); }
.pill.indigo { color: var(--indigo-2); background: rgba(99,102,241,.14); border-color: rgba(99,102,241,.34); }
.pill .raw { color: var(--muted-2); font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 7px; font-size: 11.5px; font-weight: 700;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--muted);
}

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted-2); }
.field .hint.err { color: var(--red); }

.input, .select, .textarea {
  width: 100%; padding: 10px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-s);
  font: inherit; font-size: 14px; transition: .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--indigo-2); box-shadow: var(--ring); background: #0a0f22;
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2393a0c4' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}

.form-grid { display: grid; gap: 0 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.check {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: var(--radius-s);
  background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; font-size: 13.5px; font-weight: 600; user-select: none; transition: .14s;
}
.check:hover { border-color: var(--indigo-2); }
.check input { accent-color: var(--indigo); width: 16px; height: 16px; cursor: pointer; }
.check-grid { display: grid; gap: 9px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 42px; height: 24px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border); transition: .18s; flex: none; position: relative;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted); transition: .18s;
}
.switch input:checked + .track { background: linear-gradient(135deg, var(--indigo), var(--cyan)); border-color: transparent; }
.switch input:checked + .track::after { left: 21px; background: #06121f; }
.switch .lbl { font-size: 13.5px; font-weight: 600; }

/* color field */
.colorfield { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.colorfield label { font-size: 12px; font-weight: 600; color: var(--muted); flex: 1 1 auto; min-width: 0; }
.colorfield .cwrap { display: flex; align-items: center; gap: 6px; flex: none; }
.colorfield input[type=color] {
  width: 34px; height: 34px; padding: 0; border: 1px solid var(--border);
  border-radius: 9px; background: none; cursor: pointer; flex: none;
}
.colorfield input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
.colorfield input[type=color]::-webkit-color-swatch { border: none; border-radius: 6px; }
.colorfield input[type=text] { width: 92px; font-family: var(--mono); font-size: 12.5px; }
.color-grid { display: grid; gap: 2px 18px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* sections */
.section { margin-top: 18px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-head h3 { font-size: 16px; }
.section-head .eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--cyan); font-weight: 700; }
.section-note {
  font-size: 12.5px; color: var(--orange);
  background: var(--orange-bg); border: 1px solid var(--orange-bd);
  padding: 8px 12px; border-radius: var(--radius-s); margin-bottom: 14px;
  display: flex; gap: 8px; align-items: flex-start;
}
.divider { height: 1px; background: var(--border-soft); margin: 18px 0; border: 0; }
.sub-h { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); font-weight: 700; margin: 16px 0 10px; }

/* ------------------------------------------------------------------ table */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius-s); }
table.rules { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.rules th, table.rules td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--border-soft); }
table.rules th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); background: var(--surface); position: sticky; top: 0; }
table.rules tr:last-child td { border-bottom: none; }
table.rules input.input { padding: 6px 8px; font-size: 12.5px; }
table.rules td .input { min-width: 64px; }
table.rules td.lbl-col .input { min-width: 120px; }

/* ------------------------------------------------------------------ pre/log */
.logbox {
  background: #060a16; border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 14px 16px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  color: #b9c5e6; white-space: pre-wrap; word-break: break-word;
  max-height: 440px; overflow: auto; margin: 0;
}
.logbox::-webkit-scrollbar { width: 10px; height: 10px; }
.logbox::-webkit-scrollbar-thumb { background: #2a3666; border-radius: 6px; border: 2px solid #060a16; }

/* ------------------------------------------------------------------ login */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; padding: 32px 30px; }
.login-logo {
  width: 54px; height: 54px; border-radius: 15px; margin: 0 auto 16px;
  background: var(--accent-grad); display: grid; place-items: center;
  box-shadow: 0 12px 30px -10px rgba(99,102,241,.8);
}
.login-logo svg { width: 30px; height: 30px; }
.login-card h1 { font-size: 22px; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); margin: 6px 0 24px; font-size: 13.5px; }
.login-err {
  background: var(--red-bg); border: 1px solid var(--red-bd); color: #fecaca;
  padding: 9px 12px; border-radius: var(--radius-s); font-size: 13px; margin-bottom: 14px;
  display: flex; gap: 8px; align-items: center;
}
.totp-input { letter-spacing: .5em; text-align: center; font-family: var(--mono); font-size: 22px; font-weight: 700; }

/* ------------------------------------------------------------------ states */
.state { text-align: center; padding: 56px 24px; color: var(--muted); }
.state .ico { font-size: 34px; margin-bottom: 12px; opacity: .8; }
.state h3 { color: var(--text); margin-bottom: 6px; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.18); border-top-color: var(--cyan);
  animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px;
}
.spinner.lg { width: 34px; height: 34px; border-width: 3.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: var(--radius);
  height: 196px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ------------------------------------------------------------------ toasts */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-s);
  background: var(--surface-2); border: 1px solid var(--border);
  box-shadow: var(--shadow); font-size: 13.5px;
  animation: toast-in .22s cubic-bezier(.2,.9,.3,1.2);
}
.toast.out { animation: toast-out .2s forwards; }
.toast .bar { width: 3px; align-self: stretch; border-radius: 3px; background: var(--indigo); flex: none; }
.toast.ok .bar { background: var(--green); }
.toast.err .bar { background: var(--red); }
.toast.info .bar { background: var(--cyan); }
.toast .t-title { font-weight: 700; }
.toast .t-msg { color: var(--muted); font-size: 12.5px; margin-top: 2px; word-break: break-word; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ------------------------------------------------------------------ modal */
.modal-back {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(4,7,16,.66); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 22px;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 430px; padding: 24px 24px 20px;
  animation: pop .18s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { opacity: 0; transform: scale(.95) translateY(8px); } }
.modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ------------------------------------------------------------------ qr */
.qr-box { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.qr-box img { width: 168px; height: 168px; border-radius: var(--radius-s); background: #fff; padding: 8px; flex: none; }
.secret {
  font-family: var(--mono); font-size: 13px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 8px 10px; word-break: break-all; user-select: all;
}

/* success / provision */
.success-panel {
  border: 1px solid var(--green-bd); background: var(--green-bg);
  border-radius: var(--radius); padding: 20px;
}
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; align-items: center; font-size: 14px; }
.kv .k { color: var(--muted); font-size: 12.5px; }
.copybox { display: flex; gap: 8px; align-items: center; }
.copybox code {
  font-family: var(--mono); background: var(--bg); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: var(--radius-xs); font-size: 13px; flex: 1 1 auto; word-break: break-all;
}

/* ------------------------------------------------------------------ detail sub-nav */
.subnav {
  display: flex; gap: 4px; margin: 2px 0 18px; overflow-x: auto;
  scrollbar-width: none; border-bottom: 1px solid var(--border-soft);
}
.subnav::-webkit-scrollbar { display: none; }
.subnav-item {
  padding: 9px 16px; color: var(--muted); font-weight: 600; font-size: 13.5px;
  white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subnav-item:hover { color: var(--text); text-decoration: none; }
.subnav-item.active { color: var(--cyan-2); border-bottom-color: var(--cyan); }

/* ------------------------------------------------------------------ list rows (deals / links) */
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border-soft); border-radius: var(--radius-s);
  background: var(--surface); margin-bottom: 10px;
}
.list-row .thumb {
  width: 44px; height: 44px; border-radius: 8px; object-fit: contain;
  background: var(--bg); border: 1px solid var(--border); flex: none;
}
.list-row .grow { min-width: 0; }
.list-row .title { font-weight: 700; }
.list-row .sub { color: var(--muted); font-size: 12.5px; word-break: break-word; }
.row-actions { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.drag-handle { cursor: grab; color: var(--muted-2); flex: none; touch-action: none; }
.list-row.dragging { opacity: .5; border-color: var(--indigo-2); }
.tagchips { display: flex; flex-wrap: wrap; gap: 6px; }
.tagchip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px;
  border-radius: 7px; font-size: 12px; background: var(--surface-3);
  border: 1px solid var(--border); color: var(--text);
}
.tagchip button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1; padding: 0; }

/* ------------------------------------------------------------------ analytics */
.stat-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 18px; }
.stat-card { padding: 16px 18px; }
.stat-card .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); }
.stat-card .big { font-size: 26px; font-weight: 800; margin-top: 4px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding-top: 8px; }
.bars .col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bars .bar { width: 100%; background: var(--accent-grad); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars .blabel { font-size: 9px; color: var(--muted-2); white-space: nowrap; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.rank-row:last-child { border-bottom: none; }
.rank-row .n { color: var(--muted-2); font-weight: 700; width: 22px; flex: none; }
.rank-row .grow { min-width: 0; }
.rank-row .val { font-weight: 700; flex: none; }

/* ------------------------------------------------------------------ responsive */
/* single-column card grid earlier than the card min-width would force */
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  /* Topbar wraps: brand + user stay on row 1, the nav drops to its own
     full-width row below and scrolls horizontally if needed. */
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 8px 10px; }
  .brand-mark { order: 1; font-size: 15px; }
  .brand-sub { display: none; }
  .userbox { order: 2; margin-left: auto; gap: 8px; }
  .uname { display: none; }
  .nav {
    order: 3; flex-basis: 100%; margin-left: 0; gap: 6px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 2px; scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; }

  .wrap-main { padding: 18px 13px 64px; }
  .page-head { margin-bottom: 18px; }
  .page-head h1 { font-size: 22px; }

  /* 16px inputs prevent iOS Safari from auto-zooming on focus */
  .input, .select, .textarea, table.rules input.input { font-size: 16px; }

  /* action buttons span the row so they're easy to tap */
  .row.wrap > .btn { flex: 1 1 auto; }
  .inst-actions .btn { flex: 1 1 140px; }

  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv .k { margin-top: 8px; }
  .copybox { flex-wrap: wrap; }

  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .qr-box img { width: 150px; height: 150px; }
  .logbox { font-size: 12px; max-height: 360px; }
  .section { margin-top: 14px; }
  /* Stack list rows: content on top, actions wrap to their own line below —
     otherwise the buttons crush the title/sub column on a phone. */
  .list-row { flex-wrap: wrap; }
  .list-row .grow { min-width: 140px; }
  .row-actions { flex-basis: 100%; justify-content: flex-start; margin-top: 4px; }
}

@media (max-width: 460px) {
  body { font-size: 14.5px; }
  .card-pad { padding: 15px 14px; }
  .inst { padding: 16px 15px 15px; }
  .page-head h1 { font-size: 20px; }
  .section-head h3 { font-size: 15px; }

  .btn { padding: 10px 14px; }      /* bigger touch target */
  .btn-sm { padding: 8px 11px; }

  /* stacked, full-width confirm/cancel in dialogs */
  .modal { padding: 20px 18px 16px; }
  .modal-actions { flex-direction: column-reverse; gap: 8px; }
  .modal-actions .btn { width: 100%; }

  .colorfield input[type=text] { width: 76px; }
  .login-card { padding: 26px 20px; }
  .login-screen { padding: 16px; }
}
