:root {
  --blue: #1267e8;
  --blue-strong: #0755c9;
  --blue-soft: #eaf3ff;
  --navy: #13233a;
  --text: #26364d;
  --muted: #708096;
  --line: #e2e9f2;
  --surface: rgba(255, 255, 255, .96);
  --success: #10a875;
  --success-soft: #e8f9f3;
  --danger: #ef5261;
  --warning: #f6a623;
  --shadow: 0 20px 55px rgba(29, 63, 108, .11);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: #f4f7fb;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: radial-gradient(circle at top left, #eef6ff 0, #f5f7fb 38%, #f4f7fb 100%); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); line-height: 1.6; }
.eyebrow { margin: 0 0 7px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .15em; }

.ambient { position: fixed; z-index: -1; border-radius: 999px; filter: blur(6px); opacity: .5; }
.ambient-one { width: 380px; height: 380px; left: -120px; top: -90px; background: #b9dcff; }
.ambient-two { width: 420px; height: 420px; right: -160px; bottom: -180px; background: #dce9ff; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: min(440px, 100%); padding: 42px; border: 1px solid rgba(255,255,255,.9); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.login-card h1 { margin: 8px 0 10px; color: var(--navy); font-size: 30px; letter-spacing: -.03em; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--navy); font-size: 21px; font-weight: 700; }
.brand b { color: var(--blue); }
.brand-login { margin-bottom: 36px; font-size: 24px; }
.brand-mark { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border: 4px solid var(--blue); border-radius: 50%; }
.brand-mark::before, .brand-mark::after, .brand-mark span { content: ""; position: absolute; border-radius: 2px; background: var(--blue); }
.brand-mark::before { width: 14px; height: 4px; right: -7px; top: 7px; transform: rotate(45deg); }
.brand-mark::after { width: 14px; height: 4px; right: -8px; bottom: 7px; transform: rotate(-45deg); }
.brand-mark span { width: 12px; height: 4px; right: -6px; top: 12px; }

.stack { display: grid; gap: 17px; margin-top: 28px; }
label { display: grid; gap: 8px; color: #43536a; font-size: 13px; font-weight: 700; }
input, select { min-height: 43px; border: 1px solid #d8e1ec; border-radius: 11px; background: #fff; color: var(--text); padding: 0 13px; outline: none; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus { border-color: #72adfb; box-shadow: 0 0 0 4px rgba(18, 103, 232, .1); }
.language-select { min-height: 36px; padding-right: 30px; }
.login-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

.button { min-height: 42px; border: 0; border-radius: 11px; padding: 0 17px; font-weight: 800; white-space: nowrap; transition: transform .15s, opacity .15s, box-shadow .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button.primary { color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-strong)); box-shadow: 0 8px 20px rgba(18, 103, 232, .22); }
.button.success { color: #fff; background: linear-gradient(135deg, #10b981, #079466); box-shadow: 0 8px 20px rgba(16, 168, 117, .2); }
.button.ghost { color: #506078; background: #f0f4f9; }
.button.danger { color: var(--danger); background: #fff0f2; }
.button.wide { width: 100%; }
.button.compact { min-height: 34px; padding: 0 12px; border-radius: 9px; font-size: 12px; }

.notice { margin-top: 15px; padding: 11px 13px; border-radius: 10px; font-size: 13px; }
.notice.error { color: #a72c3a; background: #fff0f2; border: 1px solid #ffd6dc; }

.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; height: 72px; padding: 0 32px; border-bottom: 1px solid rgba(220,228,240,.85); background: rgba(255,255,255,.9); backdrop-filter: blur(18px); }
.topbar-actions { display: flex; align-items: center; gap: 13px; }
.connection { display: flex; align-items: center; gap: 7px; color: #4f6077; font-size: 12px; font-weight: 700; }
.connection i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(16,168,117,.12); }
.connection.offline i { background: var(--danger); box-shadow: 0 0 0 4px rgba(239,82,97,.12); }
.user-chip { display: flex; align-items: center; gap: 9px; min-width: 145px; }
.user-chip > span { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 11px; color: #fff; background: linear-gradient(135deg, #2c7df0, #1557bb); font-weight: 800; }
.user-chip div { display: grid; }
.user-chip strong { color: var(--navy); font-size: 13px; }
.user-chip small { color: var(--muted); font-size: 11px; }

.workspace { width: min(1540px, 100%); margin: 0 auto; padding: 32px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.page-heading h1 { margin: 0; color: var(--navy); font-size: clamp(27px, 3vw, 37px); letter-spacing: -.04em; }
.page-heading .muted { margin: 8px 0 0; }
.server-clock { color: #586980; font-size: 13px; font-weight: 700; }
.filters { display: flex; gap: 10px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 22px; }
.stat-card { position: relative; overflow: hidden; padding: 21px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: 0 8px 25px rgba(42,68,105,.05); }
.stat-card::after { content: ""; position: absolute; width: 70px; height: 70px; right: -24px; top: -25px; border-radius: 50%; background: var(--blue-soft); }
.stat-card small { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card strong { display: block; margin-top: 10px; color: var(--navy); font-size: 30px; letter-spacing: -.04em; }
.stat-card em { display: block; margin-top: 4px; color: #8895a7; font-size: 11px; font-style: normal; }
.stat-card.success strong { color: var(--success); }

.panel { border: 1px solid var(--line); border-radius: 19px; background: var(--surface); box-shadow: 0 10px 30px rgba(42,68,105,.055); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; color: var(--navy); font-size: 18px; letter-spacing: -.02em; }
.count-pill { display: grid; place-items: center; min-width: 30px; height: 30px; border-radius: 10px; color: var(--blue); background: var(--blue-soft); font-weight: 800; }
.scanner-grid { display: grid; grid-template-columns: minmax(330px, .78fr) minmax(560px, 1.45fr); gap: 20px; align-items: start; }
.queue-panel, .preview-panel { min-height: 620px; }
.task-list { display: grid; gap: 11px; max-height: 600px; overflow: auto; padding: 16px; }
.task-card { display: grid; gap: 13px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #fff; transition: border-color .2s, box-shadow .2s; }
.task-card:hover { border-color: #aecdf8; box-shadow: 0 8px 20px rgba(18,103,232,.06); }
.task-card.active { border-color: #61a1f7; background: #f8fbff; }
.task-top, .task-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.task-account { display: grid; gap: 3px; }
.task-account strong { color: var(--navy); font-size: 13px; }
.task-account small { color: var(--muted); font-size: 11px; }
.mini-countdown { color: var(--blue); font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 850; }
.mini-countdown.urgent, .countdown.urgent { color: var(--danger); }
.status-pill { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 999px; color: #53657c; background: #eff3f8; font-size: 10px; font-weight: 800; }
.status-pill.available, .status-pill.plus_success { color: #087c58; background: var(--success-soft); }
.status-pill.claimed, .status-pill.confirmed, .status-pill.verifying { color: #075cbf; background: var(--blue-soft); }
.status-pill.expired, .status-pill.not_plus, .status-pill.verification_error, .status-pill.setup_error { color: #b03241; background: #fff0f2; }
.empty-list { display: grid; place-items: center; min-height: 220px; padding: 30px; color: var(--muted); text-align: center; }

.preview-heading { border-bottom: 0; }
.countdown { min-width: 92px; padding: 9px 12px; border-radius: 12px; color: var(--blue); background: var(--blue-soft); font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; text-align: center; }
.preview-meta { display: grid; grid-template-columns: 1fr 1fr 1fr; margin: 0 20px 14px; border: 1px solid var(--line); border-radius: 13px; background: #f8fafc; }
.preview-meta > span { display: grid; gap: 4px; padding: 11px 13px; border-right: 1px solid var(--line); }
.preview-meta > span:last-child { border-right: 0; }
.preview-meta small { color: var(--muted); font-size: 10px; }
.preview-meta strong { overflow: hidden; color: var(--navy); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.preview-mode-warning { display: flex; align-items: center; gap: 10px; margin: 0 20px 12px; padding: 10px 12px; border: 1px solid #f0b453; border-radius: 8px; color: #71430c; background: #fff6e8; font-size: 12px; }
.preview-mode-warning strong { flex: 0 0 auto; color: #a65b00; font-size: 11px; text-transform: uppercase; }
.preview-stage { position: relative; height: 470px; margin: 0 20px; overflow: auto; border: 1px solid #dbe4ef; border-radius: 15px; background: #edf2f7; }
.preview-stage.empty { background: linear-gradient(145deg, #f3f7fb, #eaf0f7); }
.preview-stage.empty .preview-canvas { display: none; }
.preview-canvas { display: grid; place-items: center; width: max-content; min-width: 100%; height: max-content; min-height: 100%; background: #fff; }
.preview-stage.scale-actual .preview-canvas img { display: block; width: auto; max-width: none; height: auto; max-height: none; object-fit: none; image-rendering: auto; }
.preview-stage.scale-fit { overflow: hidden; }
.preview-stage.scale-fit .preview-canvas { width: 100%; height: 100%; }
.preview-stage.scale-fit .preview-canvas img { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; image-rendering: auto; }
.preview-stage:fullscreen { width: 100vw; height: 100vh; margin: 0; border: 0; border-radius: 0; }
.preview-empty { position: absolute; z-index: 1; display: grid; place-content: center; justify-items: center; inset: 0; padding: 40px; color: var(--muted); text-align: center; }
.preview-empty h3 { margin: 13px 0 5px; color: var(--navy); }
.preview-empty p { margin: 0; font-size: 13px; line-height: 1.65; }
.preview-icon { display: grid; place-items: center; width: 62px; height: 62px; margin: auto; border-radius: 18px; color: var(--blue); background: #fff; box-shadow: 0 10px 30px rgba(18,103,232,.12); font-size: 33px; }
.preview-loading { position: absolute; z-index: 2; display: grid; place-items: center; gap: 9px; inset: 0; color: #51627a; background: rgba(244,248,252,.94); }
.preview-loading span { width: 28px; height: 28px; border: 3px solid #c9ddf7; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.preview-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; padding: 13px 20px; }
.preview-toolbar p { display: flex; flex: 1 1 220px; align-items: center; gap: 8px; min-width: 0; margin: 0; color: var(--muted); font-size: 11px; }
.read-only-dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.preview-toolbar-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; max-width: 100%; margin-left: auto; }
.preview-scale-control { display: inline-flex; min-width: 112px; padding: 2px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #f1f5f9; }
.preview-scale-button { flex: 1 1 auto; min-width: 48px; height: 28px; padding: 0 8px; border: 0; border-radius: 6px; color: #66758a; background: transparent; font: inherit; font-size: 11px; font-weight: 800; white-space: nowrap; cursor: pointer; }
.preview-scale-button.active { color: var(--blue); background: #fff; box-shadow: 0 1px 4px rgba(24,54,91,.14); }
.preview-scale-button:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
#confirmButton { width: calc(100% - 40px); margin: 0 20px 20px; }
.history-panel { margin-top: 20px; }

.admin-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; margin-bottom: 20px; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr 1.1fr auto; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.account-list { display: grid; max-height: 330px; overflow: auto; }
.account-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 20px; border-bottom: 1px solid #edf1f6; }
.account-row:last-child { border-bottom: 0; }
.account-row .identity { display: flex; align-items: center; gap: 11px; }
.account-row .avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--blue); background: var(--blue-soft); font-weight: 850; }
.account-row strong, .account-row small { display: block; }
.account-row strong { color: var(--navy); font-size: 13px; }
.account-row small { color: var(--muted); font-size: 11px; }
.distribution-panel { min-height: 390px; }
.runtime-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.runtime-chip { padding: 6px 9px; border-radius: 9px; color: #53657c; background: #f0f4f8; font-size: 10px; font-weight: 800; }

.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 18px; border-bottom: 1px solid #edf1f6; text-align: left; white-space: nowrap; }
th { color: #7b899b; background: #fafbfd; font-size: 10px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
td { color: #45566d; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }

.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: 360px; padding: 13px 16px; border-radius: 12px; color: #fff; background: #243750; box-shadow: 0 15px 35px rgba(12,26,45,.22); font-size: 13px; }
.toast.error { background: #bd3545; }

@media (max-width: 1100px) {
  .scanner-grid, .admin-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .queue-panel, .preview-panel { min-height: auto; }
  .inline-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .topbar { height: auto; padding: 13px 16px; align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .connection, .user-chip div { display: none; }
  .workspace { padding: 20px 14px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .filters { width: 100%; }
  .filters > * { flex: 1; min-width: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-card strong { font-size: 25px; }
  .scanner-grid { grid-template-columns: minmax(0, 1fr); }
  .preview-mode-warning { align-items: flex-start; margin: 0 12px 10px; }
  .preview-stage { height: 390px; margin: 0 12px; }
  .preview-toolbar { padding: 12px; }
  .preview-toolbar p { flex-basis: 100%; }
  .preview-toolbar-actions { width: 100%; justify-content: space-between; margin-left: 0; }
  .preview-meta { grid-template-columns: 1fr; margin: 0 12px 12px; }
  .preview-meta > span { border-right: 0; border-bottom: 1px solid var(--line); }
  .preview-meta > span:last-child { border-bottom: 0; }
  .inline-form { grid-template-columns: 1fr; }
  .login-card { padding: 30px 24px; }
}
