:root {
  color-scheme: dark;
  --primary: #7720fc;
  --primary-hover: #8b46ff;
  --primary-soft: rgba(119, 32, 252, 0.18);
  --primary-border: rgba(119, 32, 252, 0.48);
  --ink: #f5f3ff;
  --muted: #a8a1bb;
  --line: rgba(255, 255, 255, 0.1);
  --surface: #17141f;
  --surface-2: #201b2b;
  --surface-3: #272132;
  --page: #0e0c13;
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.13);
  --red: #fb7185;
  --red-soft: rgba(251, 113, 133, 0.14);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.13);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(119, 32, 252, 0.12), transparent 300px),
    var(--page);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    color 140ms ease,
    opacity 140ms ease,
    transform 140ms ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--line);
  padding: 16px;
  background: #09070f;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: #05040a;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  text-decoration: none;
  text-align: left;
}

.nav-item span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: #fff;
  background: var(--primary);
  font-size: 0.8rem;
}

.nav-item.active,
.nav-item:hover {
  border-color: var(--primary-border);
  color: #fff;
  background: var(--primary-soft);
}

.workspace {
  min-width: 0;
  padding: 18px;
}

.topbar,
.panel-heading,
.toolbar,
.dialog-heading,
.dialog-actions,
.auth-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  font-size: clamp(1.35rem, 1.7vw, 1.8rem);
}

h2 {
  font-size: 0.98rem;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.primary-button,
.secondary-button,
.icon-button,
.danger-button,
.warning-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  color: #fff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-hover);
}

.secondary-button,
.icon-button.ghost {
  color: var(--ink);
  background: var(--surface-2);
  border-color: var(--line);
}

.secondary-button:hover,
.icon-button.ghost:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
}

.icon-button {
  width: 36px;
  padding: 0;
}

.small-button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 0.78rem;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.page-view {
  display: grid;
  gap: 12px;
}

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

.metrics article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 20, 31, 0.94);
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 12px;
}

.metrics span,
.activation-result span,
.meta-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 1.45rem;
}

.panel {
  overflow: hidden;
}

.panel-heading {
  justify-content: space-between;
  gap: 10px;
  min-height: 56px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.customers-table {
  min-width: 1040px;
}

th,
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

tbody tr {
  height: 50px;
}

tbody tr:hover,
.clickable-row:focus {
  background: rgba(119, 32, 252, 0.08);
}

.clickable-row {
  cursor: pointer;
  outline: none;
}

.clickable-row:focus {
  box-shadow: inset 3px 0 0 var(--primary);
}

.cell-button {
  all: unset;
  display: block;
  width: 100%;
  cursor: pointer;
}

.cell-button:focus-visible {
  color: #fff;
}

.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.table-actions button {
  flex: 0 0 auto;
}

.name-cell strong,
.name-cell small {
  display: block;
}

.name-cell small {
  max-width: 260px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
}

.customer-detail-view {
  gap: 12px;
}

.customer-info-card,
.activation-code-card,
.agent-printer-card {
  overflow: hidden;
}

.customer-info-heading {
  align-items: center;
}

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

.customer-info-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.2fr) minmax(240px, 1fr) minmax(240px, 1fr);
}

.info-block {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px;
  border-right: 1px solid var(--line);
}

.info-block:last-child {
  border-right: 0;
}

.info-block > span,
.detail-line span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.primary-info strong {
  font-size: 1.18rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.primary-info small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.detail-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.detail-line:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.detail-line strong {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.group-heading {
  min-height: 56px;
}

.group-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.muted {
  color: var(--muted);
}

.section-divider {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.section-divider h3 {
  margin: 0;
  font-size: 1rem;
}

.agent-printer-summary {
  border-bottom: 1px solid var(--line);
}

.agent-printer-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  min-width: 0;
}

.agent-printer-body table {
  min-width: 760px;
}

.agent-inline-details {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: rgba(32, 27, 43, 0.58);
}

.inline-heading {
  min-height: 56px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.inline-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.activation-list {
  display: grid;
  gap: 8px;
}

.activation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--surface-2);
}

.activation-item-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.activation-item-actions,
.activation-result-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 6px;
}

.activation-item span,
.activation-item small {
  color: var(--muted);
}

code {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  border-radius: 4px;
  padding: 1px 5px;
  color: #ddd6fe;
  background: rgba(255, 255, 255, 0.06);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.empty-state {
  padding: 14px;
}

.compact-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.compact-metrics article {
  min-height: 68px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}

.compact-metrics article:last-child {
  border-right: 0;
}

.compact-metrics span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.compact-metrics strong {
  display: block;
  margin-top: 5px;
  font-size: 1.45rem;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 0.74rem;
  font-weight: 800;
}

.status.active,
.status.online {
  color: var(--green);
  background: var(--green-soft);
}

.status.offline {
  color: var(--amber);
  background: var(--amber-soft);
}

.status.disabled,
.status.revoked {
  color: var(--red);
  background: var(--red-soft);
}

.details-empty,
.details-body {
  padding: 14px;
}

.details-empty {
  color: var(--muted);
}

.details-body {
  display: grid;
  gap: 10px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.detail-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.detail-row strong {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.danger-button {
  border-color: rgba(251, 113, 133, 0.52);
  color: var(--red);
  background: rgba(251, 113, 133, 0.08);
}

.danger-button:hover {
  background: var(--red-soft);
}

.warning-button {
  border-color: rgba(251, 191, 36, 0.44);
  color: var(--amber);
  background: rgba(251, 191, 36, 0.08);
}

.warning-button:hover {
  background: var(--amber-soft);
}

.hidden {
  display: none !important;
}

.auth-panel {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 3, 8, 0.72);
  backdrop-filter: blur(10px);
}

.auth-box,
.dialog-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-box img {
  width: 68px;
  height: 68px;
  object-fit: contain;
}

.auth-box h2 {
  margin: 8px 0 14px;
  font-size: 1.25rem;
}

.auth-actions,
.dialog-actions {
  justify-content: flex-end;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
}

dialog {
  width: min(500px, calc(100% - 28px));
  border: 0;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(4, 3, 8, 0.68);
  backdrop-filter: blur(8px);
}

.dialog-card {
  display: grid;
  gap: 12px;
}

.dialog-heading {
  justify-content: space-between;
  gap: 12px;
}

.confirm-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.context-summary {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--surface-2);
}

.context-summary span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.context-summary strong {
  overflow-wrap: anywhere;
}

.activation-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 10px;
  align-items: center;
  border: 1px solid var(--primary-border);
  border-radius: 6px;
  padding: 12px;
  background: var(--primary-soft);
}

.activation-result span {
  grid-column: 1 / -1;
}

.activation-result strong {
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}

.detail-activation-code {
  margin: 0;
}

.detail-activation-code small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: #fff;
  background: #201b2b;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
  }

  .nav {
    width: auto;
  }

  .workspace {
    padding: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: stretch;
  }

  .sync-state {
    margin-left: auto;
  }

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

  .customer-info-grid,
  .agent-printer-body {
    grid-template-columns: 1fr;
  }

  .info-block {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .info-block:last-child {
    border-bottom: 0;
  }

  .agent-inline-details {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .agent-printer-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .agent-printer-summary article {
    border-bottom: 1px solid var(--line);
  }

  .agent-printer-summary article:nth-child(2n) {
    border-right: 0;
  }

  .agent-printer-summary article:nth-last-child(-n + 2) {
    border-bottom: 0;
  }
}

@media (max-width: 680px) {
  .activation-item {
    align-items: stretch;
    flex-direction: column;
  }

  .activation-item-actions,
  .activation-result-actions {
    flex-wrap: wrap;
  }

  .activation-result {
    grid-template-columns: 1fr;
  }

  .agent-printer-summary {
    grid-template-columns: 1fr;
  }

  .agent-printer-summary article {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .agent-printer-summary article:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 560px) {
  .metrics {
    grid-template-columns: 1fr;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .toolbar .primary-button,
  .toolbar .secondary-button {
    grid-column: 1 / -1;
  }

  .sync-state {
    justify-self: end;
    margin-left: 0;
  }

  .brand img {
    width: 40px;
    height: 40px;
  }
}

/* Compact customer overview and device cards. */
.customer-detail-view { gap: 12px; }
.customer-detail-view .panel-heading { min-height: 52px; padding: 12px 16px; }
.customer-detail-view h2 { font-size: 1rem; }
.small-note { font-size: .75rem; }
.overview-grid { display: grid; grid-template-columns: minmax(220px, 1.8fr) 1.2fr .65fr 1fr; gap: 18px; padding: 16px; align-items: start; }
.contact-summary, .overview-stat { display: grid; gap: 5px; min-width: 0; }
.contact-summary span, .contact-summary small, .overview-stat > span { color: var(--muted); font-size: .75rem; overflow-wrap: anywhere; }
.overview-stat strong { font-size: .83rem; }
.agent-cards { display: grid; gap: 12px; padding: 12px; }
.fleet-agent { border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); overflow: hidden; }
.fleet-heading, .fleet-title, .card-controls { display: flex; align-items: center; gap: 10px; }
.fleet-heading { justify-content: space-between; padding: 12px; flex-wrap: wrap; }
.fleet-title { min-width: 0; }
.fleet-title h3 { margin: 0 0 4px; font-size: .94rem; overflow-wrap: anywhere; }
.fleet-title small, .agent-meta { color: var(--muted); font-size: .72rem; }
.device-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--primary-border); border-radius: 8px; background: var(--primary-soft); font-size: .7rem; font-weight: 800; flex-shrink: 0; }
.card-controls { flex-wrap: wrap; gap: 6px; }
.agent-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0 12px 12px; }
.agent-meta code { margin-left: auto; font-size: .68rem; overflow-wrap: anywhere; }
.printer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; padding: 12px; border-top: 1px solid var(--line); background: rgba(0,0,0,.12); }
.printer-card { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); min-width: 0; }
.printer-card-heading, .printer-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.printer-card-heading strong { font-size: .86rem; overflow-wrap: anywhere; }
.printer-target { margin: 0; font-size: .8rem; overflow-wrap: anywhere; }
.printer-footer small, .printer-empty { color: var(--muted); font-size: .73rem; }
.printer-empty { margin: 2px 0; }
.customer-detail-view .activation-item { padding: 10px 12px; }
.customer-detail-view .activation-item-main { gap: 3px; }
.customer-detail-view .activation-item-main strong { font-size: .83rem; }
.customer-detail-view .activation-item-main span, .customer-detail-view .activation-item-main small { font-size: .73rem; }
.customer-detail-view .activation-item-main code { font-size: .67rem; }
.customer-detail-view .activation-item-actions { flex-wrap: wrap; }
#editDialog .dialog-card { width: 100%; }
#editDialog h2 { margin: 0; font-size: 1.1rem; }
#editDialog p { margin: 0; }
.form-error { color: var(--red); font-size: .8rem; }
select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (max-width: 1100px) { .overview-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) {
  .overview-grid { grid-template-columns: 1fr; gap: 12px; }
  .printer-grid { grid-template-columns: 1fr; }
  .fleet-heading { align-items: flex-start; }
  .card-controls { width: 100%; }
  .agent-meta code { margin-left: 0; }
  .customer-detail-view .panel-heading { align-items: flex-start; gap: 10px; flex-wrap: wrap; }
}
