/* Veltronix Console. Colors are tokens on :root, redefined for dark mode. */

:root {
  --bg: #f4f8fd;
  --surface: #ffffff;
  --surface-2: #e0f2ff;
  --border: #c7dbf0;
  --text: #07183c;
  --muted: #6b7280;
  --accent: #1e56e8;
  --accent-text: #ffffff;
  --accent-soft: #e0f2ff;
  --accent-cyan: #06b6d4;
  --danger: #ef4444;
  --danger-soft: #feecec;
  --ok: #10b981;
  --ok-soft: #e5f8f2;
  --warn: #b76d00;
  --warn-soft: #fff3d7;
  --shadow: 0 6px 20px rgba(7, 24, 60, .08);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #050f26;
    --surface: #0b1d3d;
    --surface-2: #102a56;
    --border: #24456f;
    --text: #f5f9ff;
    --muted: #9db0c9;
    --accent: #60a5fa;
    --accent-text: #07183c;
    --accent-soft: #123b70;
    --danger: #ff7272;
    --danger-soft: #4b2029;
    --ok: #36d399;
    --ok-soft: #123f37;
    --warn: #ffb020;
    --warn-soft: #4d3711;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body { margin: 0; min-width: 0; width: 100%; max-width: 100%; overflow-x: hidden; }
.app { width: 100%; max-width: 100vw; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: .95rem; margin: 0 0 .4rem; }
p { margin: .4rem 0; }
code, .mono { font-family: var(--mono); font-size: .9em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.loading, .noscript { padding: 2rem; color: var(--muted); }
[hidden] { display: none !important; }

/* Shell */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem;
  padding: .6rem 16px;
  background: linear-gradient(110deg, #07183c 0%, #0d2b66 65%, #1e56e8 140%);
  border-bottom: 1px solid rgba(96, 165, 250, .3);
  box-shadow: 0 5px 18px rgba(7, 24, 60, .22);
}
.brand-logo { display: inline-flex; align-items: center; }
.brand-logo picture { display: contents; }
.brand-logo img { display: block; width: auto; object-fit: contain; }
.brand-logo.shell { margin-right: auto; }
.brand-logo.shell img { height: 32px; max-width: 190px; }
.brand-logo.login-brand { justify-content: center; margin: .1rem 0 .35rem; }
.brand-logo.login-brand img { width: min(100%, 245px); height: auto; }
.customer-picker { display: flex; align-items: center; gap: .4rem; }
.customer-picker select { max-width: 16rem; }
.topbar .btn { border-color: rgba(255, 255, 255, .35); }
.admin-identity { display: inline-flex; align-items: center; gap: .4rem; color: #fff; }
.admin-identity .badge { background: rgba(255, 255, 255, .15); color: #fff; }

.tabs {
  display: block; overflow-x: auto; overflow-y: hidden; width: 100%; min-width: 0; max-width: 100vw;
  contain: layout inline-size paint; overscroll-behavior-x: contain;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tabs-inner { display: flex; gap: .2rem; width: max-content; min-width: 100%; }
.tabs a {
  padding: .65rem .8rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .spacer { flex: 1; }

main { max-width: 1200px; margin: 0 auto; padding: 1.2rem 16px 4rem; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: 1rem; }
.page-head h1 { margin-right: auto; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; }

/* Controls */

.btn {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .4rem .8rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: linear-gradient(100deg, #1e56e8, #3b82f6 58%, #06b6d4 135%); border-color: #1e56e8; color: #fff; font-weight: 650; box-shadow: 0 3px 10px rgba(30, 86, 232, .18); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: .2rem .55rem; font-size: .85rem; }
.btn.link { border: none; background: none; color: var(--accent); padding: 0; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .4rem .55rem;
  min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .tabs a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[readonly] { background: var(--surface-2); }
input[type="checkbox"] { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent); }
textarea { width: 100%; resize: vertical; }
textarea.json { font-family: var(--mono); font-size: .85rem; line-height: 1.4; }

.field { display: flex; flex-direction: column; gap: .25rem; }
.field > span { font-weight: 550; font-size: .88rem; }
.field .hint { color: var(--muted); font-size: .8rem; }
.check { display: flex; align-items: center; gap: .5rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; margin: .4rem 0 -.3rem; font-size: .8rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.form-error { color: var(--danger); min-height: 1.2em; margin: .6rem 0 0; white-space: pre-wrap; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-bottom: .9rem; }
.segmented button { font: inherit; border: none; background: var(--surface); color: var(--muted); padding: .3rem .9rem; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); font-weight: 600; }

.profile-editor-tabs {
  display: flex;
  gap: .2rem;
  overflow-x: auto;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
}
.profile-editor-tab {
  flex: none;
  margin: 0;
  padding: .55rem .7rem;
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.profile-editor-tab:hover { color: var(--text); background: var(--surface-2); }
.profile-editor-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 650; }
.profile-editor-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.profile-editor-panel { min-height: clamp(16rem, 42vh, 23rem); align-content: start; }
.profile-editor-panel.advanced { display: block; }
.profile-editor-panel.advanced textarea.json { height: clamp(16rem, 42vh, 23rem); resize: none; }
.profile-subsection {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
}
.profile-subsection + .profile-subsection { margin-top: -.25rem; }
.profile-subsection > summary {
  padding: .65rem .75rem;
  color: var(--text);
  font-size: .88rem;
  font-weight: 650;
  cursor: pointer;
  user-select: none;
}
.profile-subsection > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.profile-subsection[open] > summary { border-bottom: 1px solid var(--border); }
.profile-subsection-body { padding: .8rem; background: var(--surface); border-radius: 0 0 7px 7px; }
.regex-editor { display: grid; gap: .65rem; }
.regex-editor-head { display: flex; align-items: end; justify-content: space-between; gap: .8rem; }
.regex-editor-head .hint { margin-top: .2rem; color: var(--muted); font-size: .8rem; }
.regex-rules { display: grid; gap: .55rem; }
.regex-rule {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: .55rem;
  align-items: end;
  padding: .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}
.regex-rule .btn { margin-bottom: .05rem; }

.structured-editor { display: grid; gap: .7rem; }
.structured-editor-head, .keyboard-row-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem;
}
.structured-editor-head .hint { margin-top: .2rem; color: var(--muted); font-size: .8rem; max-width: 42rem; }
.keyboard-rows, .hardware-keys, .asset-list { display: grid; gap: .65rem; }
.keyboard-row, .hardware-key, .asset-editor {
  border: 1px solid var(--border); border-radius: 7px; background: var(--surface);
}
.keyboard-row { padding: .65rem; display: grid; gap: .6rem; }
.keyboard-row-head { justify-content: flex-start; }
.keyboard-row-head strong { margin-right: auto; }
.keyboard-keys { display: grid; gap: .45rem; }
.keyboard-key, .hardware-key {
  display: grid; grid-template-columns: minmax(5rem, .8fr) minmax(7rem, 1fr) minmax(6rem, 1fr) 5rem auto auto;
  align-items: end; gap: .45rem; padding: .55rem; background: var(--surface-2); border-radius: 6px;
}
.hardware-key { grid-template-columns: 7rem 7rem minmax(7rem, 1fr) minmax(6rem, 1fr) auto auto; }
.asset-editor > summary { padding: .65rem .75rem; font-weight: 650; cursor: pointer; }
.asset-editor[open] > summary { border-bottom: 1px solid var(--border); }
.asset-editor-body { padding: .75rem; }
.code-source { font-family: var(--mono); font-size: .84rem; tab-size: 2; }
.capability-picker, .scope-picker { border: 1px solid var(--border); border-radius: 7px; padding: .65rem; }
.capability-picker legend, .scope-picker legend { padding: 0 .25rem; font-weight: 600; }
.capability-picker { display: flex; flex-wrap: wrap; gap: .65rem 1rem; }
.scope-picker { display: grid; gap: .45rem; }
.simulator { padding: .25rem 0; }
.simulation-result { grid-column: 1 / -1; min-width: 0; }
.simulation-output, .preview-list { overflow: auto; padding: .65rem; border-radius: 6px; background: var(--surface-2); font-family: var(--mono); }
.simulation-steps { margin-bottom: 0; padding-left: 1.4rem; color: var(--muted); }

/* Tables */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.actions-cell { text-align: right; white-space: nowrap; }
td.actions-cell .btn + .btn { margin-left: .3rem; }
td .sub { color: var(--muted); font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

/* Cards and stats */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .btn { margin-top: .8rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .7rem; }
.stat .value { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .label { color: var(--muted); font-size: .85rem; }

.seat-row { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr auto; gap: 1rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.seat-row:last-child { border-bottom: none; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 99px; }
.bar.full > div { background: var(--warn); }

.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.steps li { display: flex; align-items: center; gap: .6rem; }
.steps .dot { width: 1.3rem; height: 1.3rem; border-radius: 50%; display: inline-grid; place-items: center; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); flex: none; }
.steps .done .dot { background: var(--ok-soft); color: var(--ok); }
.steps .done .text { color: var(--muted); }

.enroll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 1rem; }
.enroll-card { display: grid; grid-template-columns: 128px 1fr; gap: 1rem; }
.enroll-card .qr { width: 128px; height: 128px; background: #fff; border-radius: 6px; border: 1px solid var(--border); image-rendering: pixelated; }
.enroll-card .details { min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.enroll-card .url { display: flex; gap: .3rem; align-items: center; }
.enroll-card .url code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.enroll-card .card-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem; border-top: 1px solid var(--border); padding-top: .7rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; align-items: baseline; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.copy-box { display: flex; gap: .4rem; align-items: stretch; }
.copy-box input, .copy-box textarea { flex: 1; font-family: var(--mono); font-size: .85rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .8rem; }
.toolbar input[type="search"] { flex: 1; max-width: 22rem; }
.security-admin { margin-top: 1.2rem; }
.security-admin .section-head { margin-top: 1.3rem; margin-bottom: .6rem; }
.security-admin h2 { margin-top: 1.3rem; }
.fleet-section + .fleet-section { margin-top: 1.25rem; }
.license-health { margin-bottom: 1rem; }
.license-health h2 { margin-top: 0; }
.warning-stat { border-color: var(--warn); }
.diagnostics-json { min-height: 25rem; font-family: var(--mono); }
.entitlement-installation { margin-bottom: 1rem; }
.entitlement-role-note { margin: -.4rem 0 1rem; }
.badge-list { display: flex; flex-wrap: wrap; gap: .35rem; }
.page-head > div:first-child > p { max-width: 58rem; }
.section-head-inline {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: .7rem 1rem;
  margin-top: 1.5rem;
}
.section-head-inline h2 { margin: 0 0 .2rem; }
.section-head-inline .check { flex: none; padding-bottom: .15rem; }
.notice { margin: .65rem 0; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 6px; }
.notice.warn { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.notice.danger { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.grant-fingerprint { max-width: 22rem; overflow-wrap: anywhere; }

/* Immutable releases and controlled rollout */

.deployment-workspace { display: grid; gap: .25rem; }
.deployment-loading { color: var(--muted); text-align: center; padding: 2rem 1rem; }
.deployment-error { border-color: var(--danger); }
.deployment-error h2 { color: var(--danger); margin-top: 0; }
.deployment-section + .deployment-section { margin-top: .35rem; }
.rollout-list { display: grid; gap: .75rem; }
.rollout-card { display: grid; gap: .8rem; }
.rollout-card-head { display: flex; align-items: start; justify-content: space-between; gap: .75rem; }
.rollout-card-head h3 { margin: 0; }
.rollout-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin: 0; }
.rollout-summary > div { min-width: 0; padding: .55rem .65rem; border-radius: 6px; background: var(--surface-2); }
.rollout-summary dt { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.rollout-summary dd { margin: .2rem 0 0; overflow-wrap: anywhere; }
.deployment-counts { display: flex; flex-wrap: wrap; gap: .4rem; }
.deployment-count { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .35rem; border: 1px solid var(--border); border-radius: 999px; }
.deployment-count .badge { padding-block: 0; }
.rollout-actions { display: flex; flex-wrap: wrap; gap: .4rem; padding-top: .15rem; border-top: 1px solid var(--border); }
.rollout-devices { min-width: 0; }
.rollout-devices > h3 { margin-top: .25rem; }
.rollout-policy { padding: .45rem .6rem; background: var(--surface-2); border-radius: 6px; }
.preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin-bottom: .8rem; }

/* Login */

.login { max-width: 24rem; margin: 12vh auto; padding: 0 16px; }
.login .card { display: flex; flex-direction: column; gap: .8rem; padding: 1.5rem; }
.login .card { border-top: 3px solid #1e56e8; }
.login h1 { text-align: center; }

/* Dialogs */

dialog.modal {
  width: min(32rem, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 1.2rem 1.3rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
dialog.modal.wide { width: min(52rem, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(10, 14, 20, .45); }
dialog.modal h2 { margin: 0 0 1rem; font-size: 1.15rem; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

/* Toasts */

.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .4rem; z-index: 50; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--bg); padding: .55rem .9rem; border-radius: 6px; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); color: #fff; }

/* Printing an enrollment sheet */

.print-area { display: none; }
@media print {
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block; text-align: center; color: #000; padding-top: 2cm; font-size: 14pt; }
  .print-area img { width: 9cm; height: 9cm; image-rendering: pixelated; }
  .print-area .print-url { font-family: var(--mono); font-size: 10pt; word-break: break-all; }
  .print-area ol { display: inline-block; text-align: left; margin-top: 1cm; }
}

@media (max-width: 640px) {
  .tabs .spacer { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .regex-editor-head { align-items: start; flex-direction: column; }
  .regex-rule { grid-template-columns: 1fr; }
  .regex-rule .btn { justify-self: start; }
  .seat-row { grid-template-columns: 1fr auto; }
  .seat-row .bar { grid-column: 1 / -1; grid-row: 2; }
  .enroll-card { grid-template-columns: 96px 1fr; }
  .enroll-card .qr { width: 96px; height: 96px; }
  .brand { width: 100%; }
  .entitlement-installation .kv { grid-template-columns: 1fr; gap: .2rem; }
  .entitlement-installation .kv dd + dt { margin-top: .55rem; }
  .section-head-inline { align-items: start; flex-direction: column; }
  .rollout-summary { grid-template-columns: 1fr; }
  .rollout-card-head { align-items: start; }
  .rollout-actions .btn { flex: 1 1 auto; justify-content: center; }
  .keyboard-key, .hardware-key { grid-template-columns: 1fr; }
  .preview-grid { grid-template-columns: 1fr; }
}
