:root {
  color-scheme: dark;
  font: 14px/1.55 Inter, ui-sans-serif, system-ui, sans-serif;
  color: #e8eaf2;
  background: #0a0c12;
  font-synthesis: none;
  --bg: #0a0c12;
  --bg-elevated: #121622;
  --bg-card: #161b28;
  --bg-input: #0e121b;
  --line: #2a3144;
  --line-soft: #222838;
  --text: #e8eaf2;
  --text-soft: #b4bdd1;
  --muted: #8b96ad;
  --accent: #b6a0ff;
  --accent-strong: #cdbbff;
  --accent-bg: #2a2340;
  --success: #8ce0bd;
  --success-bg: #173d34;
  --danger: #ffb4b4;
  --danger-bg: #3d2228;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --sidebar-w: 212px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(1200px 600px at 0% -10%, rgba(182, 160, 255, 0.08), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(92, 120, 255, 0.06), transparent 50%),
    var(--bg);
}

button, input, select, textarea { font: inherit; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
a.text-link { font-weight: 600; font-size: 13px; }

/* —— Sidebar —— */
aside {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  padding: 16px 12px;
  background: rgba(17, 20, 29, 0.92);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f5f4ff;
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.4px;
  padding: 2px 4px;
}

.brand-icon {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #c7b6ff, #9a7fe8);
  color: #20143a;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

.aside-caption {
  color: var(--muted);
  font-size: 11px;
  margin: 8px 4px 14px;
  line-height: 1.4;
}

nav {
  display: grid;
  gap: 1px;
  align-content: start;
}

nav a {
  display: flex;
  gap: 7px;
  align-items: center;
  align-self: start;
  width: 100%;
  padding: 5px 8px;
  min-height: unset;
  height: auto;
  color: var(--text-soft);
  border-radius: 5px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.15;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

nav a span {
  font-size: 13px;
  width: 15px;
  line-height: 1;
  text-align: center;
  opacity: 0.85;
  flex-shrink: 0;
}
nav a:hover { background: #1a1f2e; color: #fff; border-color: var(--line-soft); }
nav a[aria-current="page"] {
  color: #e8deff;
  background: var(--accent-bg);
  border-color: #3f3560;
}
nav a.hidden { display: none !important; }

.aside-bottom {
  margin-top: auto;
  padding: 12px 4px 2px;
  color: #a8b0c4;
  font-size: 11px;
  line-height: 1.35;
}

.aside-bottom small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

/* —— Main layout —— */
main {
  max-width: 1120px;
  margin-left: var(--sidebar-w);
  padding: 36px 40px 48px;
  min-height: 100svh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--accent);
  letter-spacing: 0.14em;
  font-size: 10px;
  font-weight: 700;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(26px, 4vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
  font-weight: 650;
}

h2 {
  font-size: 17px;
  line-height: 1.35;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h3 {
  font-size: 15px;
  margin: 0 0 6px;
  font-weight: 600;
}

p { margin: 8px 0; }

.muted, .hint, small { color: var(--muted); }
.muted { font-size: 13px; }
.hint { font-size: 12px; line-height: 1.5; }

section {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin: 16px 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.section-head > div { min-width: 0; }
.section-head p { margin: 6px 0 0; }

.section-divider {
  height: 1px;
  background: var(--line);
  margin: 28px 0;
  border: 0;
}

.page-footnote {
  margin: 8px 4px 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

/* —— Controls —— */
button {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #20143a;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 650;
  font-size: 13px;
  min-height: 40px;
  transition: background 0.15s, transform 0.05s;
}

button:hover { background: var(--accent-strong); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

button.quiet {
  background: #242a3a;
  color: #d7dbea;
  border-color: #353c51;
}

button.quiet:hover { background: #343b50; }

button.primary {
  background: var(--accent);
  color: #20143a;
  border-color: transparent;
}

button.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #6b3a42;
}

button.danger:hover { background: #4a2830; }

input, select, textarea {
  color: #eef0fa;
  background: var(--bg-input);
  border: 1px solid #3c445b;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: #6f5fae;
  box-shadow: 0 0 0 3px rgba(182, 160, 255, 0.15);
  outline: none;
}

input::placeholder { color: #6f7a92; }

label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-soft);
}

form { display: grid; gap: 16px; }

select[multiple] {
  min-height: 96px;
  padding: 8px;
}

select[multiple] option {
  padding: 6px 8px;
  border-radius: 4px;
  margin: 2px 0;
}

/* —— Login —— */
.login-shell {
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

#login.login-pending .login-card {
  visibility: hidden;
}

.login-card {
  width: min(100%, 400px);
  padding: 28px 26px 26px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.login-card h2 {
  font-size: 20px;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.login-card .login-lead {
  margin: 0 0 20px;
  font-size: 13px;
}

#login-form { margin-top: 0; gap: 14px; }

#login-form > button {
  width: 100%;
  margin-top: 4px;
}

#login-caption { margin: 12px 0 0; text-align: center; }

/* —— Utilities —— */
.hidden { display: none !important; }

.notice {
  background: #302818;
  color: #f3d698;
  border: 1px solid #625130;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #222838;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
}

.title-with-chip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.title-with-chip .chip {
  position: relative;
  z-index: 1;
  font-weight: 600;
}

#employee-esim-ui #employee-library-form {
  margin-bottom: 4px;
}

#employee-esim-ui .employee-sims-head {
  margin-top: 22px;
  margin-bottom: 16px;
  align-items: center;
}

#employee-esim-ui .form-bottom button[type="submit"] {
  position: relative;
  z-index: 0;
}

.status-line {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #1a1f2c;
  border: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--text-soft);
}

.transport-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #343041;
  background: #1b1826;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 12px;
}

.transport-note p { margin: 4px 0 0; color: #b8adc9; }

.status-dot {
  height: 8px;
  width: 8px;
  border-radius: 50%;
  background: #c8a3ee;
  flex-shrink: 0;
  margin-top: 6px;
}

/* —— Devices —— */
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 4px;
}

.stats > div {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.stats span {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.stats p {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 0;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.device {
  background: var(--bg-card);
  border: 1px solid #30384b;
  border-radius: var(--radius-md);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 100%;
}

.badge {
  display: inline-block;
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.badge.offline {
  background: #2b2e3b;
  color: #b4bacb;
}

.device small { display: block; font-size: 11px; color: var(--muted); }
.device p { font-size: 12px; color: var(--text-soft); margin-top: 4px; }

.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 14px;
}

.device-actions button { flex: 1 1 auto; min-width: 120px; }

.help-strip {
  padding: 14px 6px 4px;
  color: #c7cede;
  font-size: 12px;
}

.help-strip p { color: var(--muted); margin-top: 4px; }

/* —— Lists & rows —— */
.list-panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: rgba(10, 12, 18, 0.35);
  overflow: hidden;
}

.list-panel .row {
  padding: 14px 16px;
  background: transparent;
}

.list-panel .empty {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}

.row > div:first-child { min-width: 0; flex: 1; }

.row p {
  font-size: 13px;
  overflow-wrap: anywhere;
  margin: 0 0 4px;
  color: var(--text);
  font-weight: 550;
}

.row small { font-size: 11px; line-height: 1.45; }

.row:last-child { border-bottom: 0; }

.sim-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  flex-shrink: 0;
  max-width: min(100%, 420px);
}

.sim-actions select {
  width: auto;
  min-width: 140px;
  max-width: 220px;
  flex: 1 1 140px;
}

.employee-sim-note {
  width: min(100%, 320px);
  margin-top: 8px;
  font-size: 12px;
}

.sim-row { align-items: flex-start; }

.event-content {
  white-space: pre-wrap;
  max-width: 100%;
  margin-top: 8px !important;
  font-weight: 400 !important;
  color: var(--text-soft) !important;
}

/* —— SIM page —— */
.device-picker { width: min(100%, 240px); }

.capacity {
  padding: 14px 16px;
  border: 1px solid #35314a;
  background: #1b1928;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.capacity p { margin: 4px 0; }

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin: 14px 0 8px;
}

.slot-card {
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 16px;
  background: #111827;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.slot-card.occupied { border-color: #427d73; background: #0f1f1c; }
.slot-card h3, .slot-card p { margin: 0; overflow-wrap: anywhere; }
.slot-card small { color: #a9b8ce; }
.slot-card .badge { align-self: flex-start; }
.slot-title { font-weight: 700; color: #b9cce8; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.slot-summary { font-weight: 600; font-size: 13px; margin-bottom: 4px !important; }

.sim-toolbar {
  display: flex;
  gap: 10px;
  margin: 16px 0;
  align-items: stretch;
}

.sim-toolbar input { flex: 1 1 200px; }
.sim-toolbar select { flex: 0 0 180px; width: auto; }

/* —— Forms —— */
.esim-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
  gap: 16px;
}

.wide { grid-column: 1 / -1; }

.file-label {
  padding: 16px;
  border: 1px dashed #55506d;
  border-radius: var(--radius-md);
  background: #1c1b2b;
}

.file-label input {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 12px;
  box-shadow: none;
}

input::file-selector-button {
  background: #343047;
  color: #e9e1ff;
  border: 0;
  border-radius: 6px;
  padding: 7px 12px;
  margin-right: 12px;
  cursor: pointer;
}

.form-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.library-destination { margin-bottom: 8px; }

#library-list .row { align-items: flex-start; }

/* —— Employees —— */
.employee-card {
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  margin-bottom: 10px;
}

.employee-card:last-child { margin-bottom: 0; }

.employee-domain {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.employee-domain input { min-width: 0; }

.employee-edit {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.employee-card .employee-edit .form-bottom { margin-top: 4px; }

.employee-dns {
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--text-strong, inherit);
}

#employee-list {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

#employee-list .empty { margin: 0; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.slot-picker {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

.slot-picker-head {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}

.slot-picker > .hint { margin: 0 0 6px; }

.slot-picker-list {
  display: grid;
  gap: 6px;
}

.slot-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: var(--bg-card);
  cursor: pointer;
}

.slot-option:has(input:disabled) {
  opacity: 0.62;
  cursor: not-allowed;
  background: #141820;
}

.slot-option input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: inherit;
}

.slot-option-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.slot-option-text strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.slot-option-text small {
  font-size: 11px;
  line-height: 1.35;
}

.slot-picker-device {
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.slot-picker-device:first-of-type {
  padding-top: 0;
  margin-top: 8px;
  border-top: 0;
}

.slot-option-muted {
  opacity: 0.45;
}

/* —— Pairing —— */
.pairing {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  padding: 18px;
  background: #1b2030;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-soft);
}

.pairing img {
  width: 180px;
  height: 180px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: #fff;
}

.pairing ol {
  padding-left: 18px;
  font-size: 13px;
  color: #b5bfd3;
  margin: 8px 0;
}

.pairing p { font-size: 12px; }
.pairing textarea { font-size: 11px; margin: 8px 0; min-height: 72px; }

.pairing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.toolbar-select { width: min(100%, 320px); }

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11px;
  color: #8691a8;
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #c8b5ff;
  outline-offset: 2px;
}

/* —— Signed-out layout —— */
body:has(#dashboard.hidden) > aside,
body:has(#dashboard.hidden) main > header {
  display: none;
}

body:has(#dashboard.hidden) main {
  margin: 0;
  max-width: none;
  min-height: 100svh;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

body:has(#dashboard.hidden) #notice {
  width: min(100%, 400px);
  order: -1;
}

body:has(#dashboard.hidden) #login {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* —— Responsive —— */
@media (max-width: 1050px) {
  :root { --sidebar-w: 200px; }
  aside { padding: 14px 10px; }
  main { padding: 28px 22px 40px; }
  .section-head { flex-wrap: wrap; }
}

@media (max-width: 760px) {
  aside {
    position: relative;
    width: 100%;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand { font-size: 20px; }
  .brand-icon { width: 32px; height: 32px; font-size: 17px; }
  .aside-caption, .aside-bottom { display: none; }

  nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
  }

  nav a {
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
    padding: 8px 6px;
    font-size: 11px;
  }

  nav a span { display: none; }

  main { margin: 0; padding: 20px 14px 32px; }
  header { margin-bottom: 18px; }
  section { padding: 16px; margin: 12px 0; }

  .section-head > button,
  .device-picker,
  .toolbar-select { width: 100%; }

  .esim-grid { grid-template-columns: 1fr; }
  .form-bottom { flex-direction: column; align-items: stretch; }

  .sim-toolbar { flex-direction: column; }
  .sim-toolbar select { flex: initial; width: 100%; }

  .row { flex-direction: column; gap: 12px; }
  .sim-actions { width: 100%; max-width: none; justify-content: flex-start; }
  .sim-actions select { max-width: 100%; }

  .employee-domain { grid-template-columns: 1fr; }
  .employee-domain button { width: 100%; }

  .pairing { flex-direction: column; align-items: center; text-align: left; }
  .device-actions button { width: 100%; }
  .stats { gap: 8px; }
}
