:root {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #121a2d;
  --surface-raised: #18233b;
  --line: #263552;
  --text: #e8eefb;
  --muted: #9eacc5;
  --accent: #6ea8fe;
  --accent-strong: #3879e8;
  --danger: #ff6b78;
  --success: #63d7a4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 410px); padding: 32px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 24px 70px #0005; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 20px; border-radius: 16px; background: #193969; color: #b6d2ff; font-size: 32px; font-weight: 800; }
.brand-mark.small { width: 38px; height: 38px; margin: 0; border-radius: 12px; font-size: 25px; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
h1, h2, h3, p { margin-top: 0; }
.auth-card h1 { margin-bottom: 7px; font-size: 28px; }
.muted, .hint { color: var(--muted); line-height: 1.55; }
label { display: grid; gap: 7px; margin: 16px 0; color: #cbd6e9; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: #0c1425; color: var(--text); }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #6ea8fe22; }
button { border: 0; border-radius: 10px; padding: 10px 14px; color: var(--text); background: var(--surface-raised); }
button:hover { filter: brightness(1.12); }
button:disabled { cursor: wait; opacity: .6; }
.primary { background: var(--accent-strong); color: white; font-weight: 750; }
.secondary { border: 1px solid var(--line); background: var(--surface); }
.danger { background: #702b39; color: #ffe0e4; }
.success { color: var(--success); }
.wide { width: 100%; }
.link-button { display: block; margin: 13px auto 0; padding: 4px; background: transparent; color: #a9c8ff; }
.message { min-height: 22px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }
.message.success { color: var(--success); }
.secret { overflow-wrap: anywhere; color: #cbd6e9; font-family: ui-monospace, monospace; font-size: 12px; }
.mfa-qr { display: block; width: 190px; height: 190px; margin: 14px auto; padding: 8px; border-radius: 12px; background: white; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; padding: 20px 14px 14px; border-right: 1px solid var(--line); background: #0e1628; }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 7px 22px; color: var(--text); font-weight: 800; text-decoration: none; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 550; }
#admin-nav { display: grid; gap: 5px; overflow: auto; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid transparent; background: transparent; color: #bcc9df; text-align: left; }
.nav-item.active { border-color: #28446f; background: #172a49; color: #fff; }
.nav-item .nav-icon { width: 20px; text-align: center; }
.side-footer { display: grid; gap: 10px; margin-top: auto; padding: 15px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.side-signout { width: 100%; background: #19253b; text-align: left; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 21px clamp(18px, 4vw, 46px); border-bottom: 1px solid var(--line); background: #0b1020ee; backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-size: 25px; }
.page-content { display: grid; gap: 18px; padding: 24px clamp(18px, 4vw, 46px) 48px; }
.card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.card h2, .card h3 { margin-bottom: 10px; font-size: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 12px; }
.stat { padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(145deg, #162440, #111a2b); }
.stat span { display: block; color: var(--muted); font-size: 12px; }
.stat strong { display: block; margin-top: 9px; font-size: 26px; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.toolbar, .form-row, .inline-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.toolbar > *, .form-row > * { flex: 1 1 160px; }
.form-row button, .toolbar button { flex: 0 0 auto; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
td { overflow-wrap: anywhere; }
td small { display: block; margin-top: 4px; color: var(--muted); }
.table-action { padding: 6px 9px; border: 1px solid var(--line); background: #18243a; font-size: 12px; }
.table-action.danger { border-color: #71323e; background: #702b39; color: #ffe0e4; }
.tag { display: inline-block; padding: 4px 8px; border: 1px solid var(--line); border-radius: 99px; color: #c4d2e8; font-size: 11px; }
.tag.active, .tag.resolved { border-color: #28664d; color: var(--success); }
.tag.suspended, .tag.expired, .tag.canceled { border-color: #71323e; color: #ff9aa4; }
.empty { padding: 20px; color: var(--muted); text-align: center; }
.stack { display: grid; gap: 10px; }
.check-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 7px; }
.check-item { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: #0f1728; }
.check-item input { width: auto; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: ui-monospace, monospace; font-size: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 5; max-width: min(420px, calc(100vw - 40px)); padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: #1b2942; box-shadow: 0 10px 40px #0007; }
.toast.error { border-color: #943a49; }

/* Pagination & Shop Picker */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.pagination-range { color: var(--muted); font-size: 13px; font-weight: 600; }
.pagination-actions { display: flex; align-items: center; gap: 8px; }
.shop-picker { display: grid; gap: 8px; margin: 12px 0; width: 100%; }
.shop-picker-label { font-size: 13px; color: #cbd6e9; font-weight: 650; }
.shop-picker-selected { padding: 9px 12px; border: 1px solid var(--accent); border-radius: 10px; background: #132238; color: var(--text); font-size: 13px; word-break: break-all; }
.shop-picker-results { display: grid; gap: 6px; max-height: 220px; overflow-y: auto; padding: 4px 0; }
.shop-picker-item { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.shop-picker-item:hover { border-color: var(--accent); background: #172640; }
.shop-picker-item.active { border-color: var(--accent); background: #1d3357; }
.shop-picker-item-name { font-weight: 600; font-size: 13px; color: #fff; }
.shop-picker-item-meta { font-size: 11px; color: var(--muted); word-break: break-all; }

@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); } }
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding-bottom: 12px; }
  #admin-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side-footer { grid-template-columns: 1fr auto; align-items: center; margin-top: 12px; }
  .grid-two { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .auth-card { padding: 24px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .topbar h1 { font-size: 21px; }
}

/* =====================================================================
   Online-Only Rule: Persistent Offline Banner & Read-Only Protection
   ===================================================================== */
.ipos-offline-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000000;
  background: #dc2626;
  color: #ffffff;
  padding: 10px 16px;
  text-align: center;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
body.is-offline .ipos-offline-banner {
  display: block !important;
}
body.is-offline {
  padding-top: 42px !important;
}
body.is-offline .sidebar,
body.is-offline .topbar {
  top: 42px !important;
}

.netb {
  font-size: 11.5px;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.18) !important;
  color: #10b981 !important;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.netb.off, body.is-offline .netb {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
}

.offline-stale-notice {
  display: none;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  margin: 10px 0 16px;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.35);
  text-align: center;
}
body.is-offline .offline-stale-notice {
  display: block !important;
}

body.is-offline button[type="submit"],
body.is-offline .primary,
body.is-offline button.primary {
  opacity: 0.72 !important;
  cursor: pointer !important;
}

body.is-offline #refresh-page {
  opacity: 0.42 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}
