:root {
  color-scheme: dark;
  --background: #0d1117;
  --surface: #151b23;
  --surface-2: #1b232e;
  --surface-inset: #10161d;
  --surface-raised: #19212b;
  --border: #2a3441;
  --border-strong: #3a4655;
  --text: #f2f5f8;
  --muted: #8d99a8;
  --accent: #d64747;
  --accent-hover: #e15454;
  --success: #53b483;
  --warning: #d5a34f;
  --danger: #e36a6a;
  --accent-soft: #211719;
  --accent-border: #61383b;
  --success-soft: #14241c;
  --focus: #ef7676;
  --radius: 10px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --duration-micro: 120ms;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; overflow-x: clip; }
body { margin: 0; background: var(--background); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.muted { margin: 0; color: var(--muted); line-height: 1.6; }
.small-copy { font-size: 12px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 23px; letter-spacing: -.03em; }
h2 { margin: 0; font-size: 25px; letter-spacing: -.03em; }
h3 { margin: 0; font-size: 16px; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #0d1117 0%, #11161d 50%, #0d1117 100%); }
.login-card { width: min(100%, 410px); padding: 32px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 28px 80px rgba(0, 0, 0, .38); }
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: #0f141b; }
.brand-mark.small { width: 36px; height: 36px; border-radius: 8px; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.login-copy { margin: 22px 0; font-size: 14px; }

.stack { display: grid; gap: 15px; }
label { display: grid; gap: 7px; color: #cbd2db; font-size: 12px; font-weight: 650; }
input, select, textarea { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 7px; outline: none; color: var(--text); background: #0f141b; transition: border-color 150ms, background 150ms; }
textarea { min-height: 90px; padding-block: 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #667587; background: #111821; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input[type="file"] { height: auto; min-height: 42px; padding: 6px; }
input[type="file"]::file-selector-button { min-height: 30px; margin-right: 10px; padding: 5px 10px; border: 1px solid var(--border-strong); border-radius: 5px; color: var(--text); background: var(--surface-2); cursor: pointer; }
.checkbox-line { display: flex; align-items: center; gap: 10px; }
.checkbox-line input { width: 16px; height: 16px; margin: 0; padding: 0; }
.button { min-height: 39px; padding: 0 15px; border: 1px solid var(--border-strong); border-radius: 7px; cursor: pointer; background: var(--surface-2); font-size: 12px; font-weight: 750; white-space: nowrap; transition: background-color var(--duration-micro) var(--ease-out), border-color var(--duration-micro) var(--ease-out), transform var(--duration-micro) var(--ease-out); }
.button:hover { border-color: #556476; background: #222c38; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: .6; }
.button.primary { border-color: var(--accent); background: var(--accent); }
.button.primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.button.danger { color: #ffb0b0; border-color: #6d3437; background: #28191c; }
.button.small { min-height: 30px; padding: 0 9px; font-size: 10px; }
.wide { width: 100%; }
.text-button { padding: 0; border: 0; cursor: pointer; color: #b9c3ce; background: transparent; font-size: 11px; font-weight: 700; }
.text-button:hover { color: #fff; }
.form-error { min-height: 18px; margin: 10px 0 0; color: var(--danger); font-size: 12px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px 18px; border-right: 1px solid var(--border); background: #10151c; }
.sidebar-brand { padding: 0 8px 24px; }
.navigation { display: grid; gap: 4px; }
.nav-item { height: 38px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px; cursor: pointer; color: var(--muted); background: transparent; text-align: left; font-size: 12px; font-weight: 700; }
.nav-item:hover { color: var(--text); background: #171e27; }
.nav-item.active { color: var(--text); border-color: var(--border); background: var(--surface-2); }
.sidebar-footer { margin-top: auto; padding: 17px 8px 0; border-top: 1px solid var(--border); }
.developer-email { display: block; max-width: 180px; margin-bottom: 8px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.main { min-width: 0; padding: 32px clamp(20px, 4vw, 50px) 60px; }
.topbar { display: flex; align-items: center; margin-bottom: 30px; }
.topbar-title { display: flex; align-items: center; gap: 12px; }
.topbar-logo { display: none; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 8px; object-fit: cover; image-rendering: pixelated; }
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: 10px; font-weight: 700; }
.badge.active { color: #97d9b5; border-color: #315742; background: #14241c; }
.badge.disabled, .badge.revoked, .badge.expired { color: #f1a4a4; border-color: #633638; background: #251719; }
.badge.unbound { color: #e5bd79; border-color: #634f2f; background: #251f16; }
.view { display: none; }
.active-view { display: block; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 18px; }
.stat-card { min-height: 108px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.stat-card strong { display: block; margin-top: 10px; font-size: 27px; letter-spacing: -.04em; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 18px 19px 14px; border-bottom: 1px solid var(--border); }
.compact-list { min-height: 190px; }
.compact-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 57px; padding: 10px 19px; border-bottom: 1px solid #222b36; }
.compact-row:last-child { border-bottom: 0; }
.compact-primary { min-width: 0; }
.compact-primary strong, .compact-primary span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-primary strong { font-size: 12px; }
.compact-primary span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.empty-state { display: grid; min-height: 170px; place-items: center; color: var(--muted); font-size: 12px; }
.release-summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; padding: 18px 20px; }
.release-meta { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 11px; }
.release-version { color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 17px; font-weight: 800; }
.section-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-actions .muted { max-width: 700px; font-size: 12px; }
.table-panel { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { height: 54px; padding: 9px 15px; border-bottom: 1px solid #222b36; text-align: left; white-space: nowrap; }
th { height: 41px; color: var(--muted); background: #121820; font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
td { font-size: 11px; }
tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.table-actions { display: flex; justify-content: flex-end; gap: 6px; }
.release-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr); gap: 18px; }
.release-layout .panel { padding: 22px; }
.release-layout .muted { margin: 12px 0 0; font-size: 12px; }
.form-top { margin-top: 20px; }
.current-release-card { min-height: 270px; }
.current-release-card h4 { margin: 28px 0 8px; overflow-wrap: anywhere; font-size: 20px; }
.release-channel + .release-channel { margin-top: 30px; }
.release-detail { padding: 12px 0; border-bottom: 1px solid var(--border); }
.release-detail span { display: block; color: var(--muted); font-size: 10px; }
.release-detail strong { display: block; margin-top: 5px; overflow-wrap: anywhere; font-size: 12px; }
.product-status-summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; padding: 15px 18px; }
.product-status-summary.attention { border-color: var(--accent-border); background: var(--accent-soft); }
.product-summary-copy { display: flex; align-items: center; gap: 14px; min-width: 0; }
.product-summary-copy > div { min-width: 0; }
.product-summary-copy h3 { margin-bottom: 3px; }
.product-summary-copy p { font-size: 11px; }
.product-control-status { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(270px, .65fr); min-height: 152px; margin-bottom: 16px; overflow: hidden; }
.product-control-status.attention { border-color: var(--accent-border); }
.control-status-loading { grid-column: 1 / -1; display: grid; min-height: 150px; place-items: center; color: var(--muted); font-size: 12px; }
.control-status-copy { display: flex; min-width: 0; flex-direction: column; justify-content: center; padding: 24px 26px; }
.control-status-heading { display: flex; align-items: center; gap: 11px; }
.control-status-heading h3 { overflow-wrap: anywhere; font-size: 24px; letter-spacing: -.03em; }
.control-state-marker { width: 9px; height: 9px; flex: 0 0 auto; border: 2px solid var(--success); border-radius: 50%; background: var(--success-soft); }
.product-control-status.attention .control-state-marker { border-color: var(--accent); background: var(--accent); }
.control-status-detail { max-width: 62ch; margin-top: 9px; font-size: 12px; }
.control-meta { margin: 14px 0 0; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.control-metrics { display: grid; align-content: center; border-inline-start: 1px solid var(--border); background: var(--surface-inset); }
.control-metric { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 47px; padding: 8px 18px; border-bottom: 1px solid var(--border); }
.control-metric:last-child { border-bottom: 0; }
.control-metric-label { color: var(--muted); font-size: 11px; font-weight: 700; }
.product-workbench { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 16px; }
.control-secondary-stack { display: grid; gap: 16px; }
.control-card { display: flex; min-width: 0; flex-direction: column; padding: 22px; }
.control-card-primary { min-height: 316px; padding: 28px; background: var(--surface-raised); }
.control-card-compact { min-height: 150px; }
.control-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.control-card-heading h3 { overflow-wrap: anywhere; font-size: 17px; }
.control-scope { flex: 0 0 auto; color: var(--muted); font-size: 10px; font-weight: 750; }
.control-card .muted { max-width: 62ch; margin-top: 10px; font-size: 12px; }
.control-reason-field { margin-top: 28px; }
.control-reason-field input, .inline-control-form input { height: 44px; }
.control-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 22px; }
.control-actions .button, .time-credit-panel .button { min-height: 44px; }
.time-credit-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, .55fr); gap: 26px; align-items: end; margin-top: 16px; padding: 22px 24px; }
.time-credit-copy h3 { font-size: 17px; }
.time-credit-copy .muted { max-width: 62ch; margin-top: 8px; font-size: 12px; }
.inline-control-form { display: grid; grid-template-columns: minmax(110px, 1fr) auto; gap: 10px; align-items: end; }

.crypto-mfa-gate { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .7fr); gap: 24px; align-items: center; padding: 24px; border-color: var(--accent-border); }
.crypto-gate-copy .muted { max-width: 64ch; margin-top: 9px; font-size: 12px; }
.crypto-mfa-step { display: flex; gap: 16px; align-items: center; }
.crypto-mfa-setup { grid-column: 1 / -1; padding-top: 20px; border-top: 1px solid var(--border); }
.crypto-mfa-qr { width: 168px; height: 168px; padding: 8px; border-radius: 8px; background: #fff; }
.crypto-mfa-secret { display: block; max-width: 520px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; overflow-wrap: anywhere; color: var(--text); background: var(--surface-inset); font-size: 11px; }
.crypto-mfa-form { display: grid; grid-template-columns: minmax(150px, 1fr) auto; gap: 10px; align-items: end; }
.crypto-console { min-width: 0; }
.crypto-section-actions { align-items: end; }
.crypto-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.crypto-workbench { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.crypto-workbench > .panel { min-width: 0; padding: 22px; }
.crypto-workbench .muted { margin-top: 9px; font-size: 12px; }
.crypto-danger-panel { border-color: #533235; }
.crypto-custody-panel { border-color: #364b42; }
.crypto-panel-space { margin-top: 16px; }
.crypto-payouts { display: grid; }
.crypto-payout-row { display: grid; grid-template-columns: minmax(150px, .7fr) minmax(260px, 1.3fr) auto; gap: 18px; align-items: start; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.crypto-payout-row:last-child { border-bottom: 0; }
.crypto-payout-primary strong, .crypto-payout-primary span { display: block; }
.crypto-payout-primary span { margin-top: 5px; color: var(--muted); font-size: 10px; }
.crypto-payout-details { display: grid; gap: 6px; min-width: 0; }
.crypto-payout-details span { overflow-wrap: anywhere; color: var(--muted); font-size: 10px; }
.crypto-payout-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.crypto-broadcast-form { display: grid; grid-template-columns: minmax(180px, 1fr) auto; gap: 7px; width: min(100%, 420px); }
.crypto-broadcast-form input { height: 34px; }
.crypto-copy { max-width: 360px; padding: 0; border: 0; overflow: hidden; cursor: pointer; color: #cdd7e3; background: transparent; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.crypto-copy:hover { color: #fff; }
.crypto-delivery-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; min-height: 58px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.crypto-delivery-row:last-child { border-bottom: 0; }
.crypto-delivery-row strong, .crypto-delivery-row span { display: block; }
.crypto-delivery-row span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.crypto-delivery-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.crypto-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.crypto-customer-cell { display: grid; gap: 2px; }
.crypto-customer-cell .small-copy { color: var(--muted); font-size: 10px; }
#crypto-invoice-dialog { width: min(calc(100% - 32px), 560px); }
.crypto-invoice-dialog-body { display: grid; gap: 10px; max-height: min(70vh, 560px); overflow-y: auto; padding-right: 4px; }
.crypto-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 4px 18px; }
.crypto-detail-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.crypto-detail-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.crypto-detail-heading { margin: 12px 0 2px; font-size: 12px; }
.crypto-detail-card { display: grid; gap: 5px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.crypto-detail-card span { color: var(--muted); font-size: 10px; }
.crypto-balance-cell { display: grid; gap: 2px; }
.crypto-balance-cell strong { color: #fff; }
.crypto-balance-cell .small-copy { color: var(--muted); font-size: 10px; }
.crypto-balance-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.crypto-amount-hint { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.crypto-amount-hint.error { color: #f0a5ab; }

dialog { width: min(calc(100% - 32px), 430px); padding: 0; border: 1px solid var(--border-strong); border-radius: 12px; color: var(--text); background: var(--surface); box-shadow: 0 30px 100px rgba(0, 0, 0, .55); }
dialog::backdrop { background: rgba(3, 6, 10, .72); }
.dialog-card { display: grid; gap: 15px; padding: 23px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.icon-button { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; color: var(--muted); background: transparent; font-size: 20px; }
.created-key { display: block; padding: 16px; border: 1px solid var(--border); border-radius: 7px; overflow-wrap: anywhere; color: #fff; background: #0c1117; font-size: 13px; line-height: 1.7; text-align: center; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: min(360px, calc(100% - 44px)); padding: 12px 15px; border: 1px solid var(--border-strong); border-radius: 8px; opacity: 0; pointer-events: none; color: var(--text); background: #202936; font-size: 12px; transform: translateY(12px); transition: opacity 180ms, transform 180ms; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: #744044; background: #2a191c; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; padding-bottom: 68px; }
  .sidebar { position: fixed; inset: auto 0 0; z-index: 10; width: 100%; height: 66px; padding: 8px 10px; border-top: 1px solid var(--border); border-right: 0; }
  .sidebar-brand, .sidebar-footer { display: none; }
  .topbar-logo { display: block; }
  .navigation { grid-template-columns: repeat(6, 1fr); gap: 5px; }
  .nav-item { height: 48px; padding: 0 5px; text-align: center; font-size: 10px; }
  .main { padding: 24px 18px 35px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid, .release-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .product-control-status, .product-workbench, .time-credit-panel, .crypto-workbench, .crypto-mfa-gate { grid-template-columns: minmax(0, 1fr); }
  .control-metrics { border-top: 1px solid var(--border); border-inline-start: 0; }
  .control-card-primary { min-height: 290px; padding: 23px; }
  .time-credit-panel { align-items: stretch; }
}

@media (max-width: 560px) {
  .login-card { padding: 25px 21px; }
  .topbar { align-items: flex-start; }
  .stats-grid { gap: 9px; }
  .stat-card { min-height: 92px; padding: 14px; }
  .stat-card strong { font-size: 23px; }
  .release-summary, .section-actions { align-items: stretch; flex-direction: column; }
  .release-meta { align-items: flex-start; flex-direction: column; gap: 4px; }
  .section-actions .button { width: 100%; }
  .navigation .nav-item { font-size: 9px; }
  .product-status-summary, .product-summary-copy { align-items: flex-start; flex-direction: column; }
  .product-status-summary .button { width: 100%; }
  .control-status-copy { padding: 21px; }
  .control-card-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
  .control-actions { align-items: stretch; flex-direction: column; }
  .control-actions .button { width: 100%; }
  .inline-control-form { grid-template-columns: 1fr; }
  .inline-control-form .button { width: 100%; }
  .crypto-mfa-form, .crypto-broadcast-form, .crypto-payout-row { grid-template-columns: 1fr; }
  .crypto-mfa-step { align-items: stretch; flex-direction: column; }
  .crypto-mfa-qr { width: min(100%, 220px); height: auto; }
  .crypto-payout-actions { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 150ms !important; animation-iteration-count: 1 !important; transition-duration: 150ms !important; }
}
