:root {
  --black: #05070b;
  --navy: #071c3a;
  --royal: #0057d8;
  --royal-2: #0d6bff;
  --amber: #f8b31a;
  --line: #d7deea;
  --soft: #f5f7fb;
  --text: #152238;
  --muted: #63708a;
  --ok: #138a4b;
  --danger: #b42318;
}

* { 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;
  color: var(--text);
  background: var(--soft);
}

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

button {
  border: 0;
  cursor: pointer;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--black);
  border-bottom: 4px solid var(--amber);
}

.logo {
  width: 220px;
  max-width: 48vw;
}

.topbar__meta {
  color: white;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}

.login {
  min-height: calc(100vh - 76px);
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(120deg, rgba(7, 28, 58, .94), rgba(0, 87, 216, .78)),
    radial-gradient(circle at 80% 10%, rgba(248, 179, 26, .26), transparent 35%),
    var(--navy);
}

.login__panel {
  width: min(480px, 100%);
  background: white;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 8px;
  padding: 30px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .28);
}

h1, h2, h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 { font-size: 34px; }
h2 { font-size: 24px; }
h3 { font-size: 17px; }

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

.hint {
  font-size: 13px;
  margin-bottom: 0;
}

.role-toggle, .tabs, .segmented, .language-toggle {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.language-toggle {
  padding: 4px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 8px;
}

.role-toggle {
  margin: 24px 0 18px;
  padding: 5px;
  background: #e9eef7;
  border-radius: 8px;
}

.role-toggle button {
  flex: 1 1 0;
}

.role-toggle button, .tabs button, .segmented button, .language-toggle button {
  min-height: 38px;
  border-radius: 6px;
  color: var(--navy);
  background: transparent;
  padding: 0 14px;
  font-weight: 700;
}

.language-toggle button {
  min-height: 30px;
  padding: 0 10px;
  color: white;
}

.role-toggle button.active, .tabs button.active, .segmented button.active, .language-toggle button.active {
  background: var(--royal);
  color: white;
}

.form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
  font-size: 13px;
  color: var(--navy);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  background: white;
  color: var(--text);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.primary, .secondary, .ghost, .danger {
  min-height: 40px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 800;
}

.primary {
  background: var(--royal);
  color: white;
}

.secondary {
  background: var(--amber);
  color: var(--black);
}

.ghost {
  background: rgba(255, 255, 255, .12);
  color: white;
  border: 1px solid rgba(255, 255, 255, .28);
}

.danger {
  background: var(--danger);
  color: white;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

#dashboardView {
  padding: 24px;
}

.tabs {
  max-width: 1220px;
  margin: 0 auto 20px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px;
}

.tabs [data-tab="repInfo"] {
  margin-left: auto;
}

.shell {
  max-width: 1220px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.header-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
}

.header-actions label {
  min-width: 220px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat {
  background: var(--navy);
  color: white;
  padding: 18px;
  border-radius: 8px;
  min-height: 108px;
}

.stat strong {
  display: block;
  font-size: 30px;
  margin-top: 8px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.terminal-info-table table {
  table-layout: fixed;
  min-width: 1180px;
}

.terminal-info-table th,
.terminal-info-table td {
  text-align: center;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.terminal-info-table th:nth-child(1),
.terminal-info-table td:nth-child(1),
.terminal-info-table th:nth-child(2),
.terminal-info-table td:nth-child(2),
.terminal-info-table th:nth-child(3),
.terminal-info-table td:nth-child(3) {
  width: 12%;
}

.terminal-info-table th:last-child,
.terminal-info-table td:last-child {
  width: 96px;
}

th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: #eef3fb;
  color: var(--navy);
  font-size: 12px;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e9eef7;
  color: var(--navy);
  font-weight: 800;
  font-size: 12px;
}

.badge.available { background: #e7f7ee; color: var(--ok); }
.badge.issued { background: #e7f0ff; color: var(--royal); }
.badge.repair { background: #fff4d8; color: #875500; }
.badge.open { background: #fff4d8; color: #875500; }
.badge.priority-emergency { background: #ffe5e1; color: var(--danger); }
.badge.priority-high { background: #fff4d8; color: #875500; }
.badge.priority-normal { background: #e7f0ff; color: var(--royal); }
.badge.priority-return { background: #edf0f5; color: var(--muted); }

.request-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.request-timestamp {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.toolbar label {
  min-width: 180px;
  flex: 1;
}

.hidden {
  display: none !important;
}

.notice {
  border-left: 4px solid var(--amber);
  padding: 12px 14px;
  background: #fff9e8;
  color: #604000;
  border-radius: 6px;
}

.request-details {
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(320px, 1.2fr);
  gap: 16px;
  padding: 14px;
  margin-bottom: 16px;
  background: #f7f9fd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.request-details .muted {
  margin: 6px 0 0;
}

.request-details dl {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.request-details dt {
  color: var(--muted);
  font-weight: 800;
}

.request-details dd {
  margin: 0;
}

.sales-notes {
  padding: 12px 14px;
  margin: 0 0 16px;
  background: #eef3fb;
  border: 1px solid var(--line);
  border-left: 4px solid var(--royal);
  border-radius: 8px;
}

.sales-notes p {
  margin: 6px 0 0;
  color: var(--text);
}

.closed-summary {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.readonly-summary {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  background: #f7f9fd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.readonly-summary span {
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 11, .68);
}

.modal__panel {
  position: relative;
  width: min(980px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal__header .muted {
  margin: 6px 0 0;
}

.modal__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal__actions .ghost {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
}

.full-info-table table {
  min-width: 0;
}

.full-info-table th {
  width: 230px;
}

.substitute-tabs {
  margin-bottom: 14px;
}

.serial-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 800px) {
  .topbar {
    height: auto;
    min-height: 76px;
    padding: 18px;
    align-items: flex-start;
    gap: 14px;
    flex-direction: column;
  }

  #dashboardView {
    padding: 14px;
  }

  .grid.two, .grid.three, .grid.four {
    grid-template-columns: 1fr;
  }

  .panel__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .request-details {
    grid-template-columns: 1fr;
  }

  .request-details dl {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 10px;
  }

  .modal__header {
    flex-direction: column;
  }
}

@media print {
  body {
    background: white;
  }

  body > :not(.modal),
  .modal__backdrop,
  .no-print {
    display: none !important;
  }

  .modal {
    position: static;
    display: block;
    padding: 0;
  }

  .modal__panel {
    width: 100%;
    max-height: none;
    overflow: visible;
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .table-wrap {
    overflow: visible;
    border: 1px solid #999;
  }

  th, td {
    color: #000;
    border-bottom: 1px solid #ccc;
  }
}
