/* ============================================================
   XiaoAd — International Klein Blue enterprise console
   #002FA7 · square geometry · regular weight only
   ============================================================ */

:root {
  --ikb: #002fa7;
  --ikb-deep: #001c66;
  --ikb-ink: #00143f;
  --ikb-mid: #2f57c9;
  --ikb-tint: #eef2fc;
  --ikb-line: rgba(0, 47, 167, 0.18);

  --ink: #0f1320;
  --ink-2: #3b4356;
  --muted: #737b8f;
  --muted-2: #a1a8b8;

  --paper: #f5f6f9;
  --surface: #ffffff;
  --line: #e2e6ee;
  --line-2: #cfd5e1;

  --ok: #157347;
  --ok-bg: #e8f5ee;
  --err: #b3261e;
  --err-bg: #fbeaea;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --info: var(--ikb);
  --info-bg: var(--ikb-tint);

  --r: 0px;
  --sb-w: 248px;

  --font: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, b, strong, th { font-weight: 400; }
button, input, select, textarea { font: inherit; font-weight: 400; color: inherit; }
button { cursor: pointer; }
code { font-family: var(--mono); font-size: 0.86em; color: var(--ikb); }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ---------- Typographic primitives ---------- */
.kicker {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ikb);
}
.h-title { margin: 0; font-size: 22px; letter-spacing: 0.01em; color: var(--ink); }
.h-desc  { margin: 6px 0 0; color: var(--muted); font-weight: 300; }
.card-title { margin: 0; font-size: 16px; color: var(--ink); }
.hint { font-style: normal; color: var(--muted-2); margin-left: 8px; font-size: 12px; letter-spacing: 0; text-transform: none; }

.brand-square {
  display: inline-block;
  width: 14px; height: 14px;
  background: currentColor;
}
.brand-word {
  font-size: 13px;
  letter-spacing: 0.34em;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  min-height: 100vh;
}

.login-hero {
  position: relative;
  background: var(--ikb);
  color: #fff;
  padding: 56px 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.hero-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at 20% 30%, #000 30%, transparent 80%);
}
.hero-content { position: relative; z-index: 1; }
.hero-brand {
  display: flex; align-items: center; gap: 14px;
  color: #fff;
  margin-bottom: 96px;
}
.hero-title {
  margin: 0;
  font-size: 56px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: #fff;
}
.hero-sub {
  margin: 28px 0 0;
  max-width: 440px;
  font-size: 16px;
  font-weight: 300;
  color: rgba(255,255,255,0.78);
}
.hero-points {
  list-style: none;
  margin: 56px 0 0;
  padding: 0;
  display: grid;
  gap: 14px;
  max-width: 420px;
}
.hero-points li {
  display: flex; gap: 18px; align-items: baseline;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.9);
  font-weight: 300;
}
.pt-num { font-family: var(--mono); font-size: 12px; color: rgba(255,255,255,0.55); }
.hero-foot {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.5);
}

.login-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 56px 40px;
  background: var(--surface);
  position: relative;
}
.login-box { width: 100%; max-width: 380px; }
.login-legal {
  position: absolute; bottom: 28px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--muted-2);
}

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 40px 28px; min-height: 40vh; }
  .hero-brand { margin-bottom: 40px; }
  .hero-title { font-size: 38px; }
  .hero-points { display: none; }
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sb-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--ikb-ink);
  color: rgba(255,255,255,0.86);
  display: flex;
  flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
}
.sb-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 28px 24px 24px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sb-nav { display: flex; flex-direction: column; padding: 16px 12px; gap: 2px; }
.sb-nav button {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  color: rgba(255,255,255,0.66);
  letter-spacing: 0.04em;
  transition: background .15s, color .15s, border-color .15s;
}
.sb-nav button:hover { color: #fff; background: rgba(255,255,255,0.04); }
.sb-nav button.active {
  color: #fff;
  background: rgba(255,255,255,0.08);
  border-left-color: #fff;
}
.sb-sep { height: 1px; background: rgba(255,255,255,0.08); margin: 10px 14px; }

.nav-ico {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.72;
}
.sb-nav button:hover .nav-ico,
.sb-nav button.active .nav-ico { opacity: 1; }

.sb-queue {
  margin-top: auto;
  padding: 20px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sb-label { margin: 0 0 10px; font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: rgba(255,255,255,0.45); }
.q-bar { height: 3px; background: rgba(255,255,255,0.12); position: relative; overflow: hidden; }
.q-bar span { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #fff; transition: width .4s ease; }
.sb-val { margin: 10px 0 0; font-family: var(--mono); font-size: 12px; color: rgba(255,255,255,0.75); }

.sb-user {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px 22px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.avatar {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--ikb);
  color: #fff;
  letter-spacing: 0.05em;
}
.sb-user-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sb-user-name { color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255,255,255,0.45); }
.icon-btn {
  background: transparent; border: 1px solid transparent;
  color: inherit; opacity: .7;
  width: 30px; height: 30px; display: grid; place-items: center;
}
.icon-btn:hover { opacity: 1; border-color: currentColor; }

/* Main */
.main { padding: 32px 40px 64px; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 20px;
  padding-bottom: 22px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.tb-right { display: flex; align-items: center; gap: 10px; }
.quota-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--line-2);
  background: var(--surface);
}
.qc-label { font-size: 11px; letter-spacing: 0.2em; color: var(--ikb); }
.qc-val   { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-2);
  letter-spacing: 0.08em;
  line-height: 1.2;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--ikb); color: var(--ikb); }
.btn-primary { background: var(--ikb); border-color: var(--ikb); color: #fff; }
.btn-primary:hover { background: var(--ikb-deep); border-color: var(--ikb-deep); color: #fff; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; margin-top: 8px; padding: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: none; padding: 0; color: var(--ikb); letter-spacing: 0.04em; }
.link-btn:hover { text-decoration: underline; }
.file-btn { position: relative; cursor: pointer; }

.seg { display: inline-flex; border: 1px solid var(--line-2); }
.seg button {
  padding: 7px 14px;
  background: transparent; border: none;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.active { background: var(--ikb); color: #fff; }

/* ---------- Cards / Stats ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 24px 26px 26px;
  margin-bottom: 20px;
}
.card-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.card-note { background: var(--ikb-tint); border-color: var(--ikb-line); }
.rules { margin: 12px 0 0; padding-left: 20px; color: var(--ink-2); font-weight: 300; }
.rules li { margin-bottom: 8px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 20px;
}
.stat { background: var(--surface); padding: 20px 22px; }
.stat-label { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.stat-num { margin: 0; font-size: 30px; line-height: 1.1; letter-spacing: -0.01em; font-family: var(--mono); color: var(--ink); }
.stat-num.accent { color: var(--ikb); }

/* Overview layout */
.ov-banner {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.8fr);
  gap: 20px;
  padding: 22px 24px;
  margin-bottom: 18px;
  background:
    linear-gradient(135deg, rgba(0, 47, 167, 0.08), transparent 55%),
    var(--surface);
  border: 1px solid var(--line);
}
.ov-banner-text h3 {
  margin: 4px 0 8px;
  font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.ov-banner-text p#ov-sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-weight: 300;
  max-width: 42em;
}
.ov-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ov-banner-side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: center;
}
.ov-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.ov-chip span {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.ov-chip b {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  font-weight: 400;
}
.ov-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 18px;
}
.ov-metric {
  background: var(--surface);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 88px;
}
.ov-metric span {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.ov-metric strong {
  font-family: var(--mono);
  font-size: 26px;
  line-height: 1;
  font-weight: 400;
  color: var(--ink);
}
.ov-metric.ok strong { color: var(--ikb); }
.ov-mid, .ov-lists { margin-bottom: 18px; }
.ov-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.ov-steps li {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.ov-steps li:last-child { border-bottom: none; }
.ov-steps em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ikb);
  letter-spacing: 0.08em;
}
.ov-steps b {
  display: block;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 2px;
}
.ov-steps span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 300;
}
.ov-bars { margin-top: 18px; display: grid; gap: 10px; }
.ov-bar-row {
  display: grid;
  grid-template-columns: 52px 1fr 36px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--ink-2);
}
.ov-bar-row b { font-family: var(--mono); font-weight: 400; text-align: right; }
.ov-bar {
  height: 4px;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.ov-bar i {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  display: block;
}

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.two-col.wide-left { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.two-col > * { margin-bottom: 0; }

.quota-rows { display: grid; gap: 22px; }
.qr-head { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--ink-2); }
.qr-head span:last-child { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.progress { height: 4px; background: var(--line); position: relative; }
.progress span { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--ikb); transition: width .4s ease; }

.recent { list-style: none; margin: 0; padding: 0; }
.recent li {
  display: grid; grid-template-columns: 84px 1fr auto; gap: 14px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.recent li:last-child { border-bottom: none; }
.recent .rc-id { font-family: var(--mono); color: var(--muted); }
.recent .rc-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.recent .empty { display: block; text-align: center; color: var(--muted-2); padding: 20px 0; }

/* ---------- Forms ---------- */
.stack { display: flex; flex-direction: column; gap: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.field { display: block; margin: 8px 0 10px; }
.field > span, .field-head > span {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-head { display: flex; justify-content: space-between; align-items: baseline; }
.counter { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.counter b { color: var(--ikb); }

input, select, textarea {
  display: block; width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.6; min-height: 180px; }
input:focus, select:focus, textarea:focus { border-color: var(--ikb); box-shadow: 0 0 0 3px rgba(0,47,167,0.10); }
input::placeholder, textarea::placeholder { color: var(--muted-2); font-weight: 300; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.batch-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: -2px; }
.batch-tools .btn { padding: 8px 14px; font-size: 13px; }
.mailbox-tools {
  flex-wrap: nowrap;
  align-items: center;
  margin-top: 0;
  gap: 8px;
}
.mailbox-tools select {
  display: inline-flex;
  width: auto;
  min-width: 110px;
  height: 36px;
  box-sizing: border-box;
  padding: 0 32px 0 10px;
  font-size: 13px;
  line-height: 1.2;
  margin: 0;
}
.mailbox-tools input[type="search"] {
  display: inline-flex;
  width: 200px;
  min-width: 140px;
  height: 36px;
  box-sizing: border-box;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.2;
  margin: 0;
}
.mailbox-tools .btn {
  height: 36px;
  box-sizing: border-box;
  padding: 0 14px;
  font-size: 13px;
}
.mailbox-table th,
.mailbox-table td {
  padding: 10px 12px;
  white-space: nowrap;
}
.mailbox-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.mailbox-table .col-ops {
  width: 88px;
  text-align: center;
  max-width: none;
}
.mailbox-table .acc-btn {
  padding: 5px 10px;
  font-size: 12px;
}

.form-foot {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 18px;
  border-top: 1px solid var(--line);
}
.msg { margin: 0; color: var(--muted); font-weight: 300; min-height: 1.4em; }
.msg-err { color: var(--err); }
.msg-ok { color: var(--ok); }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filters select { width: auto; min-width: 140px; padding: 8px 36px 8px 12px; }

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.pager-info {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.pager-actions,
.pager-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pager-pages {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}
.pager-pages button {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-2);
  letter-spacing: 0;
}
.pager-pages button:hover { border-color: var(--ikb); color: var(--ikb); }
.pager-pages button.active {
  background: var(--ikb);
  border-color: var(--ikb);
  color: #fff;
}
.pager-pages button:disabled { opacity: 0.4; cursor: default; }
.pager .btn { padding: 8px 14px; font-size: 12px; margin: 0; }
.pager .btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  background: var(--paper);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(0,47,167,0.025); }
td.mono, .mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
td.empty { text-align: center; color: var(--muted-2); padding: 36px 0; }
.cell-err { color: var(--muted); font-size: 12px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-mail { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 10px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.tag::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.tag-success { color: var(--ok);   background: var(--ok-bg);   border-color: rgba(21,115,71,0.25); }
.tag-failed  { color: var(--err);  background: var(--err-bg);  border-color: rgba(179,38,30,0.25); }
.tag-queued  { color: var(--warn); background: var(--warn-bg); border-color: rgba(138,90,0,0.25); }
.tag-running { color: var(--info); background: var(--info-bg); border-color: var(--ikb-line); }
.tag-running::before { animation: blink 1.1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

.pkg { font-family: var(--mono); font-size: 12px; color: var(--ikb); border: 1px solid var(--ikb-line); padding: 1px 6px; }

.copy-link {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ikb);
  border: 1px solid var(--ikb-line);
  padding: 4px 10px;
  background: var(--ikb-tint);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.copy-link:hover { background: var(--ikb); color: #fff; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .btn { padding: 6px 12px; font-size: 12px; }

.accounts-table .col-ops {
  text-align: center;
  min-width: 280px;
}
.accounts-table .col-check { width: 36px; text-align: center; }
th.col-check, td.col-check { width: 36px; text-align: center; }
.acc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  min-width: 280px;
}
.acc-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ikb-line);
  background: var(--ikb-tint);
  color: var(--ikb);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.04em;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
  border-radius: 0;
  box-shadow: none;
  transition: background .15s, color .15s, border-color .15s;
}
.acc-btn:hover:not(:disabled) {
  background: var(--ikb);
  border-color: var(--ikb);
  color: #fff;
}
.acc-btn:disabled:not(.is-busy) {
  opacity: 0.38;
  cursor: not-allowed;
}
.acc-btn.is-busy {
  opacity: 1;
  background: var(--ikb);
  border-color: var(--ikb);
  color: #fff;
  cursor: wait;
}
.role-pill { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.role-pill.admin { color: var(--ikb); }

/* ---------- Modal / Toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal-bg { position: absolute; inset: 0; background: rgba(0,20,63,0.55); backdrop-filter: blur(2px); }
.modal-box {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  background: var(--surface);
  border-top: 3px solid var(--ikb);
  padding: 26px 28px 24px;
  box-shadow: 0 30px 80px rgba(0,20,63,0.35);
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.modal-box-sm { width: min(420px, calc(100vw - 32px)); }
.confirm-msg {
  margin: 0 0 4px;
  color: var(--ink-2);
  font-weight: 300;
  line-height: 1.55;
  font-size: 14px;
}
.live-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px 18px;
  background:
    linear-gradient(90deg, rgba(0, 47, 167, 0.06), transparent 55%),
    var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ikb);
}
.live-progress.hidden { display: none; }
.live-progress-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
}
.live-kicker {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ikb);
  font-weight: 400;
}
.live-stat {
  font-size: 13px;
  color: var(--ink-2);
}
.live-stat b {
  font-family: var(--mono);
  font-weight: 400;
  color: var(--ink);
  margin-left: 4px;
}
.live-stat.ok b { color: var(--ok); }
.live-stat.err b { color: var(--err); }

.btn-danger {
  background: var(--err);
  border-color: var(--err);
  color: #fff;
}
.btn-danger:hover {
  background: #8f1e18;
  border-color: #8f1e18;
  color: #fff;
}
#confirm-modal { z-index: 70; }
#copy-modal { z-index: 80; }
.copy-modal-url {
  min-height: 96px;
  max-height: 220px;
  word-break: break-all;
  font-size: 12px;
  line-height: 1.5;
}

.toast {
  position: fixed; right: 28px; bottom: 28px; z-index: 60;
  background: var(--ikb-ink); color: #fff;
  padding: 12px 18px;
  border-left: 3px solid #fff;
  font-size: 13px;
  letter-spacing: 0.04em;
  box-shadow: 0 16px 40px rgba(0,20,63,0.35);
  max-width: 420px;
}
.toast.err { border-left-color: #ff8a80; }

/* ---------- Responsive ---------- */
.sb-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px; z-index: 40;
  width: 42px; height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ikb);
  font-size: 18px;
}
.sb-close { display: none; margin-left: auto; background: transparent; border: none; color: #fff; font-size: 16px; }
.sb-backdrop { display: none; }

.pkg-list { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; }
.pkg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  font-size: 13px;
}
.pkg-row-main {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 48px auto;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.pkg-row.pkg-ok { border-left: 3px solid var(--ok); }
.pkg-row.pkg-miss { border-left: 3px solid var(--line-2); opacity: 0.92; }

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  width: 100%;
}
.settings-card { width: 100%; max-width: none; }
.modal-box-wide { max-width: 640px; width: calc(100vw - 32px); }
.modal-box-mailbox {
  max-width: min(920px, calc(100vw - 40px));
  width: min(920px, calc(100vw - 40px));
  max-height: min(72vh, 640px);
  height: auto;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 14px;
}
.mailbox-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 10px;
  flex: 0 1 auto;
  min-height: 0;
  min-width: 0;
  align-items: stretch;
  height: 340px;
}
.mailbox-list-wrap {
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 340px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid rgba(0, 47, 167, 0.12);
}
.mailbox-list-wrap.table-wrap {
  overflow-x: hidden;
}
.mailbox-list-wrap table {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}
.mailbox-list-wrap th,
.mailbox-list-wrap td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 8px 10px;
  font-size: 12px;
}
.mailbox-list-wrap th:nth-child(1),
.mailbox-list-wrap td:nth-child(1) { width: 64px; }
.mailbox-list-wrap th:nth-child(2),
.mailbox-list-wrap td:nth-child(2) { width: 42%; }
.mailbox-list-wrap th:nth-child(3),
.mailbox-list-wrap td:nth-child(3) { width: 28%; }
.mailbox-list-wrap th:nth-child(4),
.mailbox-list-wrap td:nth-child(4) { width: 110px; }
.mailbox-detail {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  flex: 1;
  min-height: 0;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  font-size: 12px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(0, 47, 167, 0.12);
  background: rgba(0, 47, 167, 0.03);
  line-height: 1.4;
}
.mailbox-detail-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}
.mailbox-detail-pane .kicker { margin-bottom: 6px; }
.modal-box-mailbox .modal-head { margin-bottom: 8px; }
.modal-box-mailbox #mailbox-modal-msg:empty { display: none; }
.modal-box-mailbox #mailbox-modal-msg {
  margin: 0 0 8px;
  font-size: 12px;
}
@media (max-width: 900px) {
  .mailbox-layout { grid-template-columns: 1fr; height: auto; }
  .modal-box-mailbox { max-height: calc(100vh - 32px); }
  .mailbox-list-wrap { max-height: 220px; height: 220px; }
  .mailbox-detail-pane { height: 220px; }
}
.modal-box-qrwall {
  max-width: min(1280px, calc(100vw - 24px));
  width: min(1280px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  padding-bottom: 14px;
}
.gcash-head-actions .btn { white-space: nowrap; }
.gcash-modal-tip { margin: 12px 0 0; }
.qr-wall {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  overflow-y: auto;
  max-height: min(78vh, 760px);
  padding: 4px 2px 8px;
  margin-right: -4px;
}
.qr-wall-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 40px 12px;
  font-weight: 400;
  font-size: 13px;
}
.qr-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  min-width: 0;
}
.qr-tile-well {
  width: 175px;
  height: 175px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 0;
  overflow: hidden;
}
.qr-tile-well canvas,
.qr-tile-well img,
.qr-tile canvas,
.qr-tile img {
  width: 175px;
  height: 175px;
  max-width: 175px;
  display: block;
  background: #fff;
  image-rendering: pixelated;
}
.qr-tile-page {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  position: relative;
  background: #fff;
}
.qr-tile-page iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  border: 0;
  pointer-events: none;
  transform: translate(-742px, -356px) scale(0.35);
  transform-origin: top left;
}
.qr-tile-mail,
.qr-tile-pkg {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.qr-tile-pkg { font-family: var(--font); color: var(--muted); font-size: 11px; }
.qr-tile .copy-link {
  padding: 3px 10px;
  font-size: 11px;
}
.qr-tile-pending {
  border-color: var(--ikb-line);
}
.qr-tile-done {
  border-color: var(--ikb-line);
  background: var(--ikb-tint);
}
.qr-tile-hold {
  width: 175px;
  height: 175px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 12px;
}
.qr-tile-paid {
  width: 175px;
  height: 175px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--ikb);
  font-size: 13px;
  letter-spacing: 0.16em;
  border: 1px solid var(--ikb-line);
}
.qr-tile-paid span {
  padding: 6px 10px;
  border: 1px solid var(--ikb);
}
@media (max-width: 1100px) {
  .qr-wall { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .qr-wall { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .qr-wall { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.table-wrap table { min-width: 640px; }

@media (max-width: 1100px) {
  .two-col, .two-col.wide-left { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .settings-layout { grid-template-columns: 1fr; }
  .pkg-row-main { grid-template-columns: 1fr 1fr; }
  .ov-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-banner { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sb-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sb-close { display: inline-block; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: min(86vw, 280px);
    height: 100vh;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  body.sb-open .sidebar { transform: translateX(0); }
  body.sb-open::before {
    content: "";
    position: fixed; inset: 0; z-index: 45;
    background: rgba(0, 20, 63, 0.45);
  }
  .sb-queue { display: none; }
  .main { padding: 64px 14px 40px; max-width: 100vw; overflow-x: hidden; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .h-title { font-size: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-num { font-size: 22px; }
  .card { padding: 14px; }
  .table-wrap { margin: 0 -4px; }
  .table-wrap table { min-width: 560px; font-size: 12px; }
  .pager { flex-direction: column; align-items: stretch; gap: 8px; }
  .pager-actions, .pager-nav { flex-wrap: wrap; }
  .pkg-row-main { grid-template-columns: 1fr; gap: 4px; }
  .settings-layout { grid-template-columns: 1fr; }
  .ov-metrics { grid-template-columns: 1fr 1fr; }
  .ov-banner-side { grid-template-columns: 1fr 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-hero { min-height: 220px; padding: 28px 22px; }
  .hero-title { font-size: 28px; }
  .hero-points { display: none; }
  .login-side { padding: 28px 18px; }
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .form-foot { flex-wrap: wrap; }
  .batch-tools { flex-wrap: wrap; }
  .modal-box { width: calc(100vw - 24px); max-width: 520px; margin: 12px; }
}
@media (max-width: 480px) {
  .stat-row { grid-template-columns: 1fr; }
  .quota-chip { font-size: 12px; }
  .tb-right { width: 100%; justify-content: space-between; }
}
