:root {
  color-scheme: light;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  --ink: #172728;
  --muted: #677778;
  --muted-strong: #4c6263;
  --line: #dce7e7;
  --line-soft: #eaf0f0;
  --canvas: #f3f7f7;
  --surface: #ffffff;
  --surface-soft: #f8fbfb;
  --teal: #0b696a;
  --teal-dark: #075456;
  --teal-soft: #e3f5f4;
  --cyan: #4cd1d1;
  --green: #138a64;
  --green-soft: #e3f7ee;
  --amber: #9a6500;
  --amber-soft: #fff3d6;
  --red: #b33a3a;
  --red-soft: #ffebeb;
  --shadow: 0 16px 42px rgba(25, 70, 71, .07);
  --radius: 16px;
  --bg: var(--canvas);
  --surface-subtle: var(--surface-soft);
  --line-strong: #bfd0d0;
  --text: var(--ink);
  --accent: var(--teal);
  --accent-hover: var(--teal-dark);
  --danger: var(--red);
  --success: var(--green);
  --warning: var(--amber);
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }

.topbar, .windows-titlebar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 clamp(20px, 4vw, 56px);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 8px 30px rgba(25, 70, 71, .04);
  backdrop-filter: blur(20px);
}

.brand { display: flex; gap: 13px; align-items: center; color: var(--ink); text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid #d8eeee;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 9px 22px rgba(11, 105, 106, .11);
}
.brand-mark img { width: 76px; max-width: none; height: 62px; object-fit: contain; }
.brand-copy, .brand strong, .brand small { display: block; }
.brand .eyebrow { margin: 0 0 1px; font-size: 9px; }
.brand-name { color: var(--ink); font-size: 21px; font-weight: 720; letter-spacing: -.035em; line-height: 1.05; }
.brand-edition { margin-top: 3px; color: var(--muted); font-size: 11px; }
.service-state, .status-text { color: var(--muted); font-size: 13px; }
.service-state { display: flex; gap: 9px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.dot.ready { background: var(--success); }
.dot.error { background: var(--danger); }

main:not(.device-shell) { width: min(1440px, calc(100% - 44px)); margin: 0 auto; padding: 52px 0; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 360px); gap: 28px; align-items: end; margin-bottom: 32px; }
.eyebrow { margin: 0 0 8px; color: var(--teal); font-size: 11px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; max-width: 760px; color: var(--ink); font-size: clamp(38px, 5.5vw, 70px); line-height: 1; letter-spacing: -.04em; font-weight: 720; }
.lede { max-width: 680px; margin: 20px 0 0; color: var(--muted); font-size: 17px; line-height: 1.55; }
.identity-card, .metrics article, .panel, .windows-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.identity-card { display: flex; flex-direction: column; gap: 7px; padding: 22px; border-radius: var(--radius); }
.identity-card span { color: var(--muted); font-size: 12px; }
.identity-card strong { font-size: 22px; font-weight: 600; }
.identity-card code { overflow: hidden; color: var(--accent); text-overflow: ellipsis; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.metrics article { position: relative; display: flex; flex-direction: column; gap: 6px; overflow: hidden; padding: 21px; border-radius: var(--radius); }
.metrics article::before { position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--cyan); content: ""; }
.metrics span, .metrics small { color: var(--muted); }
.metrics strong { font-size: 25px; font-weight: 600; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; }
.panel { border-radius: var(--radius); padding: 26px; }
.users-panel, .software-panel { margin-bottom: 12px; }
.license-workspace { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.users-panel .card-description { max-width: 760px; margin-top: 12px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; }
h2 { margin: 0 0 22px; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.panel-heading h2 { margin: 0; }

.ghost, .secondary, .primary, .table-action {
  min-height: 34px;
  border-radius: 10px;
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: var(--surface-soft);
  font-weight: 650;
  transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}
.primary { width: 100%; border-color: var(--teal); color: #fff; background: var(--teal); box-shadow: 0 8px 18px rgba(11, 105, 106, .15); }
.primary.compact-button { width: auto; }
.primary:hover { border-color: var(--teal-dark); background: var(--teal-dark); transform: translateY(-1px); }
.ghost:hover, .secondary:hover, .table-action:hover { border-color: #9ebcbc; color: var(--teal-dark); background: var(--teal-soft); }
label { display: grid; gap: 7px; margin-bottom: 16px; color: var(--text); font-size: 13px; }
input, select, textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 9px 11px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}
textarea { resize: vertical; line-height: 1.45; }
label small { color: var(--muted); font-weight: 400; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(76, 209, 209, .18); }
input:disabled, select:disabled { cursor: not-allowed; color: var(--muted); background: var(--line-soft); }
hr { margin: 26px 0; border: 0; border-top: 1px solid var(--line); }
.empty-state { display: grid; place-items: center; min-height: 260px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--text); font-size: 17px; font-weight: 600; }
.table-wrap { margin-top: 26px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--muted); }
.badge { display: inline-block; padding: 4px 9px; border-radius: 999px; font-size: 12px; background: var(--green-soft); color: var(--green); }
.badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.revoked { background: var(--red-soft); color: var(--red); }
.badge.neutral { background: var(--line-soft); color: var(--muted-strong); }
.credential { margin-top: 20px; padding: 15px; border: 1px solid #eed89b; border-radius: 10px; background: var(--amber-soft); }
.credential strong, .credential code { display: block; margin-bottom: 9px; }
.credential code { max-height: 100px; overflow: auto; color: #6d4b00; overflow-wrap: anywhere; }
.message { min-height: 20px; margin: 15px 0 0; color: var(--success); font-size: 13px; }
.message.error { color: var(--danger); }

dialog {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(23, 39, 40, .2);
}
dialog::backdrop { background: rgba(23, 39, 40, .38); backdrop-filter: blur(3px); }
#device-connections { width: min(1180px, calc(100vw - 32px)); }
#device-connections td:nth-child(2) { min-width: 330px; overflow-wrap: anywhere; }
.user-editor-form { padding: 28px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 8px; }
.dialog-heading h2 { margin: 0; }
.dialog-close {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted-strong);
  background: var(--surface-soft);
  font-size: 24px;
  line-height: 1;
}
.dialog-close:hover { color: var(--teal-dark); background: var(--teal-soft); }
.field-help { min-height: 18px; margin: -8px 0 15px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.toggle-field { display: flex; align-items: center; gap: 10px; padding: 12px 0; }
.toggle-field input { width: 18px; height: 18px; min-height: 18px; flex: 0 0 auto; margin: 0; accent-color: var(--teal); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.dialog-actions .primary { width: auto; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.action-group { display: flex; gap: 7px; }

.device-page { display: flex; flex-direction: column; }
.device-shell { width: min(920px, calc(100% - 40px)); margin: 0 auto; padding: clamp(48px, 8vw, 92px) 0 38px; }
.welcome-copy { max-width: 660px; margin-bottom: 32px; }
.welcome-copy h1 { font-size: clamp(36px, 6vw, 58px); }
.welcome-copy > p:last-child { margin: 18px 0 0; color: var(--muted); font-size: 17px; line-height: 1.55; }
.windows-card { width: min(560px, 100%); border-radius: var(--radius); padding: clamp(24px, 5vw, 36px); }
.windows-card h2 { margin-bottom: 8px; }
.card-description { margin: 0 0 26px; color: var(--muted); }
.device-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.device-heading h2 { margin: 0; }
.device-details { margin: 28px 0; }
.device-details div { display: grid; grid-template-columns: 120px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.device-details dt { color: var(--muted); }
.device-details dd { margin: 0; overflow-wrap: anywhere; }
.device-details code { color: var(--text); }
.device-footer { margin-top: auto; padding: 24px 40px; color: var(--muted); font-size: 13px; }
.device-footer a { color: var(--muted); }
.portal-account { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }

.login-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 480px); gap: clamp(36px, 8vw, 100px); align-items: center; min-height: calc(100vh - 160px); }
.login-intro h1 { font-size: clamp(44px, 7vw, 76px); }
.login-intro > p:last-child { max-width: 570px; margin: 22px 0 0; color: var(--muted); font-size: 18px; line-height: 1.6; }
.login-card { position: relative; width: 100%; overflow: hidden; }
.login-card::before { position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, var(--teal), var(--cyan)); content: ""; }
.login-card form > button + button, .login-card > button + button { margin-top: 10px; }
.login-card .secondary { width: 100%; margin-top: 10px; text-align: center; }
.setup-details { margin: 20px 0; }
.setup-details div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.setup-details dt { color: var(--muted); font-size: 12px; }
.setup-details dd { margin: 5px 0 0; overflow-wrap: anywhere; }
.setup-link { display: block; margin-bottom: 20px; text-decoration: none; }
.recovery-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; padding: 15px 15px 15px 35px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); font-family: Consolas, monospace; }
.device-list-card { width: 100%; }
.empty-state.compact { min-height: 160px; }
.user-devices { display: grid; gap: 10px; margin-top: 24px; }
.user-device { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(170px, auto); gap: 18px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.user-device strong, .user-device small { display: block; }
.user-device small { margin-top: 4px; color: var(--muted); }
.device-license-choice { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(160px, 1fr) minmax(280px, 2fr); gap: 16px; align-items: end; padding-top: 14px; border-top: 1px solid var(--line); }
.device-license-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.device-license-controls select { min-width: 0; }

@media (max-width: 980px) {
  .license-workspace, .workspace, .hero, .login-shell { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .metrics, .field-grid { grid-template-columns: 1fr; }
  main:not(.device-shell) { width: min(100% - 24px, 1440px); padding-top: 28px; }
  .panel { padding: 20px; }
}

@media (max-width: 900px) {
  .hero, .workspace, .login-shell { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  main:not(.device-shell) { width: min(100% - 24px, 1440px); padding-top: 34px; }
  .topbar, .windows-titlebar { padding: 0 14px; }
  .service-state span:last-child { display: none; }
  .panel { padding: 20px; }
  .device-shell { width: min(100% - 24px, 920px); padding-top: 40px; }
  .windows-card { padding: 22px; }
  .device-details div { grid-template-columns: 1fr; gap: 4px; }
  .device-footer { padding: 20px 14px; }
  .portal-account > span { display: none; }
  .recovery-codes { grid-template-columns: 1fr; }
  .user-device { grid-template-columns: 1fr auto; }
  .user-device > small:last-child { grid-column: 1 / -1; }
  .device-license-choice, .device-license-controls { grid-template-columns: 1fr; }
}
