:root {
  color-scheme: dark;
  --bg: #081018;
  --panel: #101b26;
  --panel-2: #152536;
  --line: rgba(178, 199, 219, .16);
  --text: #edf5fb;
  --muted: #94a8ba;
  --accent: #58d6c9;
  --accent-2: #f1c76a;
  --danger: #ff8073;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #050a10, #0d1721 54%, #101a24);
  color: var(--text);
}
a { color: inherit; }
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(7, 15, 22, .82);
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; margin-bottom: 30px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 12px; background: linear-gradient(135deg, var(--accent), #70a7ff);
  color: #031016; font-weight: 950;
}
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: 2px; }
.nav { display: grid; gap: 8px; }
.nav a, .logout-form button, .button, button.primary {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.045);
  color: var(--text);
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.logout-form { margin-top: 18px; }
.logout-form button { width: 100%; }
.primary, button.primary { border: 0; background: linear-gradient(135deg, var(--accent), #7db7ff); color: #021018; }
.main { padding: 34px; width: min(1180px, 100%); }
.topbar, .auth-panel { display: flex; justify-content: space-between; gap: 28px; align-items: flex-start; margin-bottom: 24px; }
.auth-panel { min-height: calc(100vh - 68px); align-items: center; }
.eyebrow { color: var(--accent); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; font-weight: 900; }
h1 { margin: 8px 0; font-size: clamp(34px, 5vw, 66px); line-height: .95; letter-spacing: 0; }
h2 { margin: 0 0 16px; font-size: 22px; }
.muted { color: var(--muted); line-height: 1.55; max-width: 680px; }
.form-card, .panel, .table-card, .empty-state, .form-grid {
  border: 1px solid var(--line);
  background: rgba(16, 27, 38, .86);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0,0,0,.18);
}
.form-card { width: min(440px, 100%); padding: 22px; display: grid; gap: 14px; }
label { display: grid; gap: 8px; color: var(--accent-2); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; font-weight: 900; }
input, select, textarea {
  width: 100%;
  border: 1px solid rgba(178,199,219,.2);
  border-radius: 10px;
  background: rgba(3, 9, 14, .74);
  color: var(--text);
  font: inherit;
  padding: 12px 13px;
}
textarea { resize: vertical; }
.alert { padding: 12px; border: 1px solid rgba(255,128,115,.35); border-radius: 10px; color: #ffd8d4; background: rgba(255,128,115,.08); }
.text-link { color: var(--accent); font-weight: 850; text-decoration: none; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.metrics div { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.04); }
.metrics span { display: block; font-size: 34px; font-weight: 950; color: var(--accent); }
.metrics small { color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.table-card, .empty-state, .panel, .form-grid { padding: 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--accent-2); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
td small { display: block; color: var(--muted); margin-top: 4px; }
.pill { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; color: var(--accent); font-weight: 850; }
.empty-state { text-align: center; padding: 56px 20px; }
.empty-state p { color: var(--muted); max-width: 560px; margin: 0 auto 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.wide, .actions { grid-column: 1 / -1; }
.actions { display: flex; gap: 10px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; margin-bottom: 18px; }
dl { display: grid; grid-template-columns: 160px 1fr; gap: 12px; margin: 0; }
dt { color: var(--accent-2); font-weight: 900; }
dd { margin: 0; color: var(--text); }
.compact-form { display: grid; gap: 12px; }
.timeline { display: grid; gap: 12px; }
.timeline article { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.035); }
.timeline time { display: block; color: var(--accent); font-weight: 900; margin-bottom: 6px; }
.timeline p { margin: 7px 0; color: var(--muted); }
.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.module-card {
  min-height: 150px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(16, 27, 38, .86);
  text-decoration: none;
  display: grid;
  align-content: start;
  gap: 10px;
}
.module-card strong { font-size: 22px; }
.module-card span { color: var(--muted); line-height: 1.45; }
.module-card:hover { border-color: rgba(88, 214, 201, .55); background: rgba(21, 37, 54, .9); }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}
.section-title {
  font-size: 24px;
  font-weight: 900;
}
.small-muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.button.secondary, button.secondary {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  color: var(--text);
}
.hero-button-inline, .spares-filter-submit { width: auto; min-width: 110px; }
.filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.spares-filterbar { margin: 12px 0; }
.spares-filterbar input[type="search"] { flex: 1.5 1 280px; }
.spares-filterbar select { flex: 1 1 180px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--text);
  background: rgba(255,255,255,.04);
  font-size: 12px;
  font-weight: 800;
}
.spares-toolbar,
.spares-toolbar-main,
.spares-modal-actions,
.spares-modal-chip-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.spares-toolbar {
  justify-content: space-between;
  margin-top: 12px;
}
.table-wrap { overflow-x: auto; }
.spares-table-wrap table td,
.spares-table-wrap table th { white-space: nowrap; }
.spares-table-wrap table td:nth-child(2),
.spares-table-wrap table td:nth-child(7) { white-space: normal; }
.spares-table-wrap table td:nth-child(2) { min-width: 280px; }
.low-stock td { background: rgba(241, 199, 106, .045); }
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid var(--line);
}
.status-badge.ok { background: rgba(34,197,94,.14); color: #bbf7d0; border-color: rgba(34,197,94,.24); }
.status-badge.warn { background: rgba(241,199,106,.14); color: #ffe8a3; border-color: rgba(241,199,106,.28); }
.status-badge.neutral { background: rgba(148,163,184,.12); color: #dbe8f4; border-color: rgba(148,163,184,.22); }
.spares-state-cell { display: grid; gap: 10px; }
.spares-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.spares-row-action-button {
  width: auto;
  min-height: 34px;
  padding: 7px 12px;
  font-size: 12px;
  white-space: nowrap;
}
.inventory-row-retired td { opacity: .72; }
.inventory-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
}
.inventory-modal.is-open { display: block; }
.inventory-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 12, 18, .72);
  backdrop-filter: blur(6px);
}
.inventory-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  margin: 16px auto;
  border: 1px solid rgba(178,199,219,.2);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(16,27,38,.98), rgba(8,16,24,.98));
  box-shadow: 0 24px 80px rgba(0,0,0,.36);
}
.inventory-modal-dialog-wide { width: min(960px, calc(100vw - 32px)); }
body.modal-open { overflow: hidden; }
.guided-service-form {
  padding: 18px;
  color: var(--text);
}
.wizard-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.wizard-title { margin: 0 0 6px; font-size: 24px; }
.form-stack { display: grid; gap: 14px; }
.form-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-split.three, .spares-modal-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 20px; }
  .topbar, .auth-panel, .detail-grid { display: grid; }
  .form-grid, .metrics, .module-grid { grid-template-columns: 1fr; }
  .section-head, .wizard-header { display: grid; }
  .form-split, .form-split.three, .spares-modal-three { grid-template-columns: 1fr; }
  .spares-toolbar, .spares-toolbar-main, .spares-modal-actions, .spares-modal-chip-row, .spares-row-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-button-inline, .spares-row-action-button, .spares-filter-submit { width: 100%; }
}
