:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #172033;
  --muted: #617087;
  --border: #d9e0e8;
  --primary: #154e9b;
  --primary-strong: #0f3b77;
  --primary-soft: #eaf2ff;
  --success: #16734a;
  --success-soft: #e9f7f0;
  --warning: #a15c08;
  --warning-soft: #fff5df;
  --danger: #b4232f;
  --danger-soft: #fff0f1;
  --neutral-soft: #eef1f4;
  --shadow: 0 12px 30px rgba(23, 32, 51, 0.09);
  --sidebar-width: 248px;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

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

a {
  color: var(--primary);
}

:focus-visible {
  outline: 3px solid rgba(21, 78, 155, 0.28);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  transform: translateY(-160%);
  border-radius: 4px;
  color: #fff;
  background: var(--primary-strong);
}

.skip-link:focus {
  transform: translateY(0);
}

.boot-screen {
  display: grid;
  min-height: 100vh;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
}

.brand-mark {
  display: flex;
  width: 52px;
  height: 52px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #fff;
  background: #13213a;
  font-weight: 800;
}

.brand-mark--small {
  width: 38px;
  height: 38px;
  font-size: 0.85rem;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  background: var(--surface);
}

.auth-panel {
  width: min(100%, 480px);
  margin: auto;
  padding: 28px 24px 40px;
}

.auth-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand {
  margin-bottom: 42px;
}

.auth-brand > div > strong,
.auth-brand > div > span,
.sidebar-brand strong,
.sidebar-brand small {
  display: block;
}

.auth-brand strong {
  font-size: 1.1rem;
}

.auth-brand > div > span,
.sidebar-brand small {
  color: var(--muted);
  font-size: 0.82rem;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 1.65rem;
  line-height: 1.2;
}

.auth-card > p {
  margin: 0 0 28px;
  color: var(--muted);
}

.auth-recovery {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.auth-recovery summary {
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.auth-recovery[open] summary {
  margin-bottom: 18px;
}

.auth-context {
  display: none;
  padding: 56px;
  color: #fff;
  background: #123a73;
}

.auth-context > div {
  max-width: 480px;
  margin: auto;
}

.auth-context span {
  display: block;
  margin-bottom: 16px;
  color: #b9d3f6;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-context strong {
  display: block;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.08;
}

.auth-context p {
  max-width: 40ch;
  margin-top: 24px;
  color: #d8e6f8;
  font-size: 1.05rem;
}

.form-stack,
.form-grid {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label,
.field-label {
  color: #263449;
  font-size: 0.88rem;
  font-weight: 700;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #bfc9d6;
  border-radius: 6px;
  background: var(--surface);
}

.textarea {
  min-height: 92px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 78, 155, 0.12);
  outline: 0;
}

.input--code {
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: 0;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
}

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

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

.button--secondary {
  border-color: #b9c9df;
  color: var(--primary-strong);
  background: var(--surface);
}

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

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

.button--danger-secondary {
  border-color: #e3aab0;
  color: var(--danger);
  background: var(--surface);
}

.button--ghost {
  color: inherit;
  background: transparent;
}

.button--ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.button--full {
  width: 100%;
}

.text-button {
  padding: 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  font-weight: 700;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
  font-size: 1.25rem;
}

.form-error,
.inline-message {
  padding: 10px 12px;
  border: 1px solid #edb0b7;
  border-radius: 6px;
  color: #8f1d28;
  background: var(--danger-soft);
  font-size: 0.88rem;
}

.form-error:empty {
  display: none;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  display: flex;
  width: min(84vw, var(--sidebar-width));
  flex-direction: column;
  padding: 20px 14px;
  transform: translateX(-105%);
  transition: transform 180ms ease;
  color: #fff;
  background: #172238;
}

.app-shell.menu-open .sidebar {
  transform: translateX(0);
}

.sidebar-brand {
  padding: 2px 6px 26px;
}

.sidebar-brand small {
  color: #aebbd0;
}

.sidebar-nav {
  display: grid;
  gap: 5px;
}

.nav-link {
  padding: 10px 12px;
  border-radius: 6px;
  color: #dce5f2;
  font-weight: 650;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.is-active {
  color: #fff;
  background: #294264;
}

.sidebar-user {
  display: grid;
  gap: 2px;
  margin-top: auto;
  padding: 16px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-user small {
  overflow: hidden;
  margin-bottom: 10px;
  color: #aebbd0;
  text-overflow: ellipsis;
}

.sidebar-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: none;
  border: 0;
  background: rgba(12, 21, 36, 0.52);
}

.app-shell.menu-open .sidebar-backdrop {
  display: block;
}

.page-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 68px;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
}

.topbar-heading {
  min-width: 0;
  flex: 1;
}

.topbar-heading h1 {
  overflow: hidden;
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-heading p {
  display: none;
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.topbar-user {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 700;
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--primary-strong);
}

.page-content {
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 20px 14px 48px;
}

.page-toolbar,
.section-heading,
.card-heading,
.detail-heading,
.dialog-heading,
.installation-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.page-toolbar {
  margin-bottom: 18px;
}

.page-toolbar h2,
.section-heading h2,
.card-heading h2,
.dialog-heading h2 {
  margin: 0;
  font-size: 1.05rem;
}

.page-toolbar p,
.section-heading p,
.card-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.summary-card,
.content-card,
.customer-card,
.detail-hero,
.installation-card,
.timeline-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.summary-card {
  min-height: 112px;
  padding: 15px;
}

.summary-card--danger {
  border-top: 3px solid var(--danger);
}

.summary-card--warning {
  border-top: 3px solid #d88b1f;
}

.summary-card--success {
  border-top: 3px solid var(--success);
}

.summary-card--info {
  border-top: 3px solid var(--primary);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  margin-top: 7px;
  font-size: 1.8rem;
  line-height: 1;
}

.summary-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
}

.dashboard-grid,
.detail-grid {
  display: grid;
  gap: 16px;
}

.content-card {
  padding: 16px;
}

.compact-list,
.timeline,
.installation-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.compact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}

.compact-row:first-child {
  border-top: 0;
}

.compact-row strong,
.customer-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.compact-row small,
.customer-card small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.filters {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.search-field {
  position: relative;
}

.search-field .input {
  padding-right: 42px;
}

.search-field .icon-button {
  position: absolute;
  top: 1px;
  right: 1px;
  border: 0;
  background: transparent;
}

.customer-list {
  display: grid;
  gap: 10px;
}

.customer-card {
  display: grid;
  gap: 13px;
  padding: 15px;
  color: inherit;
  text-decoration: none;
}

.customer-card:hover {
  border-color: #a9bad0;
  box-shadow: 0 5px 16px rgba(23, 32, 51, 0.07);
}

.customer-card__main,
.customer-card__meta {
  min-width: 0;
}

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

.meta-label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-badge {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
}

.status-badge--success {
  color: var(--success);
  background: var(--success-soft);
}

.status-badge--warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-badge--danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-badge--neutral {
  color: #526070;
  background: var(--neutral-soft);
}

.detail-hero {
  margin-bottom: 16px;
  padding: 18px;
}

.detail-heading {
  flex-direction: column;
}

.detail-heading h2 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.detail-heading p {
  margin: 5px 0 0;
  color: var(--muted);
}

.detail-actions {
  display: grid;
  width: 100%;
  gap: 8px;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.detail-fact strong {
  display: block;
  overflow-wrap: anywhere;
}

.installation-card {
  padding: 14px;
}

.installation-heading {
  align-items: center;
}

.installation-code,
.activation-code {
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.installation-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.installation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.timeline-item {
  position: relative;
  padding: 14px;
}

.timeline-item strong,
.timeline-item time,
.timeline-item span {
  display: block;
}

.timeline-item time,
.timeline-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.state-panel {
  display: grid;
  min-height: 260px;
  place-content: center;
  justify-items: center;
  padding: 28px;
  text-align: center;
}

.state-panel h2,
.state-panel p {
  margin: 7px 0 0;
}

.state-panel p {
  max-width: 46ch;
  color: var(--muted);
}

.state-panel .button {
  margin-top: 16px;
}

.state-symbol {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  background: var(--neutral-soft);
  font-size: 1.2rem;
  font-weight: 800;
}

.state-panel--error .state-symbol {
  color: var(--danger);
  background: var(--danger-soft);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #cfdae7;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.dialog {
  width: min(calc(100% - 24px), 560px);
  max-height: calc(100vh - 24px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(12, 21, 36, 0.62);
}

.dialog-heading {
  position: sticky;
  z-index: 2;
  top: 0;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.dialog-body {
  padding: 18px;
}

.dialog-summary {
  margin: 0 0 18px;
  padding: 12px;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  font-size: 0.88rem;
}

.dialog-summary--danger {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.dialog-actions {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  margin-top: 22px;
}

.activation-result {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
  padding: 16px;
  border: 1px solid #9ec3af;
  border-radius: 6px;
  background: var(--success-soft);
}

.activation-code {
  padding: 12px;
  border: 1px solid #b7c8bd;
  border-radius: 4px;
  background: var(--surface);
  text-align: center;
}

.check-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  font-size: 0.88rem;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 12px;
  bottom: 12px;
  display: grid;
  width: min(calc(100% - 24px), 390px);
  gap: 8px;
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 650;
}

.toast--success {
  border-left: 4px solid var(--success);
}

.toast--error {
  border-left: 4px solid var(--danger);
}

.session-expired {
  max-width: 42ch;
  margin-bottom: 20px;
  padding: 11px 12px;
  border: 1px solid #e6c178;
  border-radius: 6px;
  color: #7c4a08;
  background: var(--warning-soft);
  font-size: 0.86rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 640px) {
  .page-content {
    padding: 26px 24px 56px;
  }

  .topbar {
    padding-inline: 24px;
  }

  .topbar-heading p,
  .topbar-user {
    display: flex;
  }

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

  .filters {
    grid-template-columns: minmax(260px, 1fr) 190px auto;
    align-items: end;
  }

  .customer-card {
    grid-template-columns: minmax(220px, 1.4fr) minmax(280px, 1fr) auto;
    align-items: center;
  }

  .customer-card__meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .detail-heading {
    flex-direction: row;
  }

  .detail-actions {
    display: flex;
    width: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .detail-facts {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dialog-actions {
    flex-direction: row;
    justify-content: flex-end;
  }
}

@media (min-width: 900px) {
  .auth-page {
    grid-template-columns: minmax(420px, 42%) 1fr;
  }

  .auth-context {
    display: flex;
  }

  .sidebar {
    transform: none;
  }

  .page-shell {
    margin-left: var(--sidebar-width);
  }

  .menu-button,
  .sidebar-backdrop {
    display: none !important;
  }

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

  .detail-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
    align-items: start;
  }
}

@media (min-width: 1200px) {
  .summary-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

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