:root {
  --bg-canvas: #f6f5f1;
  --bg-surface: #ffffff;
  --bg-subtle: #eeece6;
  --border-default: #d4d0c7;
  --border-strong: #9e9a90;

  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-inverse: #ffffff;

  --brand: #0f3d2e;
  --brand-hover: #0a2b20;
  --brand-soft: #e6f2ed;
  --brand-soft-text: #0f3d2e;

  --accent: #9a3412;
  --accent-bg: #fef3e8;
  --accent-border: #e2a77b;

  --success-text: #065f46;
  --success-bg: #ecfdf5;
  --success-border: #86efac;

  --warning-text: #92400e;
  --warning-bg: #fef3c7;
  --warning-border: #fcd34d;

  --danger-text: #991b1b;
  --danger-bg: #fee2e2;
  --danger-border: #fca5a5;

  --focus-ring: #0f3d2e;
  --shadow-elevated: 0 12px 32px rgba(24, 24, 27, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

html[data-theme="dark"] {
  --bg-canvas: #111315;
  --bg-surface: #191c20;
  --bg-subtle: #23282e;
  --border-default: #333a44;
  --border-strong: #535d6c;

  --text-primary: #f3f4f6;
  --text-secondary: #b4bcc6;
  --text-inverse: #071912;

  --brand: #25b87c;
  --brand-hover: #1e9e69;
  --brand-soft: #133025;
  --brand-soft-text: #6ee7b7;

  --accent: #fdba74;
  --accent-bg: #311d0f;
  --accent-border: #9a3412;

  --success-text: #6ee7b7;
  --success-bg: #0f2d23;
  --success-border: #1e6049;

  --warning-text: #fde68a;
  --warning-bg: #2e230d;
  --warning-border: #7c5812;

  --danger-text: #fca5a5;
  --danger-bg: #311417;
  --danger-border: #7f1d1d;

  --focus-ring: #25b87c;
  --shadow-elevated: 0 16px 40px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100dvh;
  max-width: 100%;
  overflow-x: clip;
}

[hidden] {
  display: none !important;
}

/* Base interaction affordances (R-39 & R-32) */
a[href],
button:not(:disabled),
select:not(:disabled),
summary,
label[for],
input[type="checkbox"]:not(:disabled),
input[type="radio"]:not(:disabled) {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: var(--text-inverse);
  padding: 10px 16px;
  z-index: 1000;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  border-radius: var(--radius-sm);
}

code,
pre,
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.num {
  font-variant-numeric: tabular-nums;
}

.muted-text {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.925rem;
}

/* Brand lockup */
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-stack {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--text-inverse);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.925rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
  white-space: nowrap;
}

.btn-sm {
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--brand);
  color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(0.95);
}

.btn-accent {
  background: var(--accent);
  color: #ffffff;
}

.btn-accent:hover:not(:disabled) {
  filter: brightness(0.92);
}

.btn-brand-inverse {
  background: var(--text-inverse);
  color: var(--brand);
  border-color: transparent;
}

.btn-brand-inverse:hover:not(:disabled) {
  opacity: 0.92;
}

.login-brand-actions {
  margin-top: 8px;
}

.login-card-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border-default);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.docs-inline-link {
  color: var(--brand);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* DOCS PAGE */
.docs-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 56px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.docs-sidebar {
  position: sticky;
  top: 76px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 16px;
}

.docs-sidebar-title {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.docs-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.docs-nav a {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
}

.docs-nav a:hover {
  background: var(--bg-subtle);
  color: var(--brand);
}

.docs-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.docs-hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.docs-hero h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.6vw, 2.05rem);
  letter-spacing: -0.025em;
}

.docs-endpoint-pill {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  width: fit-content;
  max-width: 100%;
}

.docs-section {
  scroll-margin-top: 96px;
}

.docs-section h2 {
  margin: 0;
  font-size: 1.15rem;
}

.docs-code-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-subtle);
}

.docs-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.docs-code-card .code-block {
  border: none;
  border-radius: 0;
}

.docs-lang-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  width: fit-content;
}

.docs-lang-tab {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
}

.docs-lang-tab[aria-selected="true"] {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.docs-mobile-toc {
  display: none;
}

@media (max-width: 900px) {
  .docs-shell {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px 12px 36px;
  }

  .docs-sidebar {
    display: none;
  }

  .docs-mobile-toc {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 6px 10px 8px;
    border-top: 1px solid var(--border-default);
    background: var(--bg-subtle);
  }

  .docs-mobile-toc a {
    flex-shrink: 0;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
  }
}

/* Forms */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.field label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.field-hint {
  font-size: 0.82rem;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
}

.field select {
  text-overflow: ellipsis;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
}

.copy-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  min-width: 0;
  max-width: 100%;
}

.copy-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* Alerts & Status Tags */
.inline-alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  font-size: 0.9rem;
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: var(--warning-border);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.alert-accent {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent-border);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-paid,
.status-online,
.status-active {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.status-pending,
.status-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: var(--warning-border);
}

.status-expired,
.status-offline,
.status-failed,
.status-suspended {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.status-neutral {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-color: var(--border-default);
}

/* LOGIN LAYOUT */
.login-shell {
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
}

.login-grid {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}

.login-brand-panel {
  background: var(--brand);
  color: var(--text-inverse);
  padding: clamp(28px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
}

.login-brand-panel .brand-mark {
  background: var(--text-inverse);
  color: var(--brand);
}

.login-heading {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
  max-width: 18ch;
}

.login-lead {
  margin: 0;
  max-width: 52ch;
  opacity: 0.92;
  font-size: 0.98rem;
}

.login-policy-note {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.86rem;
  line-height: 1.45;
  max-width: 54ch;
}

html[data-theme="dark"] .login-policy-note {
  border-color: rgba(7, 25, 18, 0.35);
  background: rgba(7, 25, 18, 0.14);
}

.login-spec-list {
  margin: 8px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

html[data-theme="dark"] .login-spec-list {
  border-top-color: rgba(7, 25, 18, 0.28);
}

.spec-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.875rem;
}

.spec-row dt {
  opacity: 0.85;
}

.spec-row dd {
  margin: 0;
  font-weight: 600;
}

.login-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vw, 48px);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.login-card-top h2 {
  margin: 0;
  font-size: 1.35rem;
}

/* APP SHELL */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-tag {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--brand-soft);
  color: var(--brand-soft-text);
  font-size: 0.72rem;
  font-weight: 600;
  width: fit-content;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-tab {
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
}

.nav-tab:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.nav-tab[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand-soft-text);
  border-color: var(--border-default);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-main {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

#app-content,
#app-banner-slot {
  min-width: 0;
  max-width: 100%;
}

/* OPERATIONAL BANNER */
.ops-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
}

.ops-banner-warning {
  background: var(--accent-bg);
  border-color: var(--accent-border);
}

.ops-banner-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.ops-banner-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.ops-banner h1,
.page-header h1 {
  margin: 0;
  font-size: clamp(1.3rem, 2.2vw, 1.65rem);
  letter-spacing: -0.02em;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

/* METRIC STRIP (asymmetric hierarchy, real DB metrics only) */
.metrics-strip {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-box-primary {
  background: var(--brand);
  color: var(--text-inverse);
  border-color: var(--brand);
}

.metric-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.metric-box-primary .metric-label {
  color: var(--text-inverse);
  opacity: 0.86;
}

.metric-value {
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.metric-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.metric-box-primary .metric-sub {
  color: var(--text-inverse);
  opacity: 0.82;
}

/* PANELS & CARDS */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
  max-width: 100%;
}

.split-layout > * {
  min-width: 0;
  max-width: 100%;
}

/* TOOLBAR & TABLES */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar input[type="search"],
.toolbar select {
  min-height: 40px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-default);
  vertical-align: middle;
}

th {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* STATES (R-27) */
.state-box {
  padding: 28px 20px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.state-box h3 {
  margin: 0;
  font-size: 1rem;
}

.state-box p {
  margin: 0;
  color: var(--text-secondary);
  max-width: 48ch;
  font-size: 0.9rem;
}

/* CODE & GUIDE BLOCKS */
.code-block {
  margin: 0;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.steps-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.92rem;
}

/* QR PREVIEW */
.qr-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  text-align: center;
}

.qr-preview-box img {
  width: 240px;
  height: 240px;
  aspect-ratio: 1 / 1;
  background: #ffffff;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
}

/* PAYMENT SUCCESS CHECKMARK + ONE-SHOT CONFETTI BURST */
.qr-success-stage {
  position: relative;
  width: 240px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.qr-success-badge {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: var(--success-bg);
  border: 3px solid var(--success-text);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: qrPopIn 360ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.qr-success-badge svg {
  width: 60px;
  height: 60px;
}

.qr-success-check {
  fill: none;
  stroke: var(--success-text);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 64;
  stroke-dashoffset: 64;
  animation: qrDrawCheck 420ms 180ms ease-out forwards;
}

.confetti-piece {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  pointer-events: none;
  opacity: 0;
  animation: qrConfettiBurst 1150ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes qrPopIn {
  0% { transform: scale(0.55); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes qrDrawCheck {
  to { stroke-dashoffset: 0; }
}

@keyframes qrConfettiBurst {
  0% {
    transform: translate(-50%, -50%) rotate(0deg) scale(0.6);
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(var(--rot)) scale(1);
    opacity: 0;
  }
}

/* QRIS IMAGE UPLOADER */
.qris-upload-box {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  min-width: 0;
  max-width: 100%;
}

.qris-upload-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.qris-upload-info strong {
  font-size: 0.9rem;
}

.qris-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.qris-file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.qris-file-label:hover {
  background: var(--brand-soft);
  color: var(--brand-soft-text);
  border-color: var(--brand);
}

.qris-file-input:focus-visible + .qris-file-label {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  font-size: 0.9rem;
  font-weight: 500;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--brand);
  flex-shrink: 0;
}

details.guide-disclosure {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--bg-subtle);
}

details.guide-disclosure summary {
  font-weight: 600;
  font-size: 0.92rem;
}

details.guide-disclosure[open] summary {
  margin-bottom: 12px;
}

/* AUTH MODE TABS */
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
}

.auth-tab {
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
}

.auth-tab[aria-selected="true"] {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}

/* PWA INSTALL POPUP */
.pwa-install-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 460px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 110;
}

.pwa-install-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.pwa-install-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pwa-install-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 19, 21, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  margin: 0;
  font-size: 1.1rem;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* TOAST */
.toast-region {
  position: fixed;
  right: 16px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 120;
  max-width: min(380px, calc(100vw - 32px));
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-elevated);
  font-size: 0.9rem;
  font-weight: 500;
}

.toast-success {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
}

.toast-danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

/* MOBILE TAB BAR (hidden on desktop) */
.mobile-tab-bar {
  display: none;
}

/* TABLET BREAKPOINT (761px - 980px) */
@media (max-width: 980px) {
  .login-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* MOBILE BREAKPOINT (<= 760px) */
@media (max-width: 760px) {
  .desktop-nav {
    display: none;
  }

  .topbar-inner {
    padding: 8px 12px;
    gap: 8px;
  }

  .topbar-left {
    gap: 8px;
    min-width: 0;
    flex: 1;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 0.8rem;
  }

  .brand-name {
    font-size: 1rem;
  }

  .role-tag {
    max-width: 110px;
    font-size: 0.68rem;
  }

  .topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }

  .topbar-actions .btn {
    min-height: 36px;
    padding: 0 9px;
    font-size: 0.78rem;
  }

  .mobile-tab-bar {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 6px 10px 8px;
    border-top: 1px solid var(--border-default);
    background: var(--bg-subtle);
  }

  .mobile-tab-bar .nav-tab {
    min-height: 42px;
    padding: 6px 4px;
    font-size: 0.78rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
  }

  .mobile-tab-bar .nav-tab[aria-current="page"] {
    background: var(--bg-surface);
    color: var(--brand);
    border-color: var(--border-default);
    font-weight: 700;
  }

  .app-main {
    padding: 14px 12px 32px;
    gap: 14px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .page-header .toolbar-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .page-header > .btn {
    width: 100%;
  }

  .ops-banner {
    padding: 14px;
    gap: 10px;
  }

  .ops-banner .btn {
    width: 100%;
  }

  .metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .metric-box {
    padding: 13px 14px;
    gap: 4px;
  }

  .metric-box-primary {
    grid-column: 1 / -1;
  }

  .metric-value {
    font-size: 1.2rem;
  }

  .metric-box-primary .metric-value {
    font-size: 1.5rem;
  }

  .panel {
    padding: 14px;
    gap: 12px;
  }

  .panel-header {
    gap: 8px;
  }

  .form-grid-2 {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar-group {
    width: 100%;
  }

  .toolbar input[type="search"],
  .toolbar select {
    width: 100%;
    flex: 1;
    min-height: 44px;
  }

  .copy-row {
    flex-direction: column;
  }

  .copy-row .btn {
    width: 100%;
    min-height: 44px;
  }

  .qris-upload-box {
    flex-direction: column;
    align-items: stretch;
  }

  .qris-file-label {
    width: 100%;
  }

  .login-brand-panel {
    padding: 24px 16px;
    gap: 16px;
  }

  .login-form-panel {
    padding: 16px 12px 28px;
  }

  .login-card {
    padding: 20px 16px;
  }

  .toast-region {
    left: 12px;
    right: 12px;
    bottom: 16px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
