:root {
  color-scheme: light;
  --ink: #0f172a;
  --navy: #1e3a5f;
  --blue: #2f5d8a;
  --mid-blue: #5b8dbe;
  --soft-blue: #a7c4e0;
  --mist: #eaf2fa;
  --surface: #ffffff;
  --muted: #475569;
  --line: #cbd5e1;
  --line-strong: #5b8dbe;
  --success: #067647;
  --success-bg: #ecfdf3;
  --danger: #b42318;
  --danger-dark: #8f1c13;
  --danger-bg: #fff1f0;
  --warning-bg: #fff8e8;
  --warning: #7a4e00;
  --focus: #2f5d8a;
  --shadow-dialog: 0 24px 70px rgba(15, 23, 42, 0.22);
  --radius-small: 6px;
  --radius-medium: 10px;
  --radius-large: 16px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--mist);
}

body {
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

a[href],
button:not(:disabled),
select:not(:disabled),
input[type="file"]:not(:disabled),
label[for] {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

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

.app-header {
  display: flex;
  min-height: 88px;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 18px clamp(18px, 4vw, 56px);
  background: var(--ink);
  color: var(--surface);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  place-items: center;
  border: 1px solid var(--mid-blue);
  border-radius: 12px 12px 3px 12px;
  background: var(--navy);
  color: var(--surface);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.brand-copy strong {
  font-size: clamp(1.02rem, 2.8vw, 1.24rem);
  letter-spacing: 0.01em;
}

.brand-copy span {
  color: #c7d9ea;
  font-size: 0.84rem;
}

.header-meta {
  color: #d9e7f4;
  font-size: 0.9rem;
}

.primary-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 8px clamp(14px, 4vw, 52px);
  border-bottom: 1px solid var(--soft-blue);
  background: var(--surface);
}

.nav-item {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}

.nav-item:hover {
  background: var(--mist);
  color: var(--navy);
}

.nav-item:active {
  background: #d7e7f5;
}

.nav-item.is-active {
  background: var(--navy);
  color: var(--surface);
}

.nav-count {
  display: inline-grid;
  min-width: 22px;
  min-height: 22px;
  margin-left: 4px;
  place-items: center;
  border-radius: 50%;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.75rem;
  font-weight: 800;
}

.app-main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 52px) clamp(16px, 3.5vw, 48px) 64px;
}

.view[hidden],
[hidden] {
  display: none !important;
}

.page-heading {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 28px;
}

.page-heading h1 {
  margin: 3px 0 4px;
  color: var(--ink);
  font-size: clamp(1.8rem, 4vw, 2.55rem);
  line-height: 1.14;
  letter-spacing: -0.035em;
}

.page-heading p,
.section-heading-row p {
  margin: 0;
  color: var(--muted);
}

.context-label {
  margin: 0;
  color: var(--blue) !important;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  font-weight: 720;
  text-decoration: none;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button-primary {
  border-color: var(--blue);
  background: var(--blue);
  color: var(--surface);
}

.button-primary:hover:not(:disabled) {
  border-color: var(--navy);
  background: var(--navy);
}

.button-primary:active:not(:disabled) {
  background: var(--ink);
}

.button-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--navy);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--mist);
}

.button-text {
  background: transparent;
  color: var(--blue);
}

.button-text:hover:not(:disabled) {
  background: var(--mist);
  color: var(--navy);
}

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

.button-danger:hover:not(:disabled) {
  border-color: var(--danger-dark);
  background: var(--danger-dark);
}

.button-small {
  min-height: 40px;
  padding: 7px 11px;
  font-size: 0.88rem;
}

.summary-layout {
  display: grid;
  gap: 14px;
  margin-bottom: 26px;
}

.total-panel,
.server-summary-wrap,
.data-section,
.management-form,
.management-list {
  border: 1px solid var(--line);
  background: var(--surface);
}

.total-panel {
  display: flex;
  min-height: 210px;
  flex-direction: column;
  justify-content: center;
  padding: clamp(24px, 5vw, 38px);
  border-color: var(--navy);
  border-radius: var(--radius-medium);
  background: var(--navy);
  color: var(--surface);
}

.total-panel span {
  color: #d9e7f4;
  font-weight: 650;
}

.total-panel strong {
  margin: 4px 0 2px;
  font-size: clamp(3.5rem, 11vw, 5.4rem);
  line-height: 1;
  letter-spacing: -0.07em;
}

.total-panel small {
  color: #c7d9ea;
  font-size: 0.9rem;
}

.server-summary-wrap {
  min-width: 0;
  padding: 22px;
  border-radius: var(--radius-medium);
}

.section-heading-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.section-heading-row h2,
.management-form h2,
.management-list h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.08rem;
}

.section-heading-row > span {
  color: var(--muted);
  font-size: 0.86rem;
}

.server-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 9px;
}

.server-stat {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #c7d9ea;
  border-radius: var(--radius-small);
  background: var(--mist);
}

.server-stat span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--navy);
  font-weight: 650;
}

.server-stat strong {
  display: grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.92rem;
}

.data-section {
  padding: clamp(18px, 3vw, 28px);
  border-radius: var(--radius-medium);
}

.list-heading {
  gap: 16px;
}

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

.filter-bar {
  display: grid;
  gap: 12px;
  margin: 22px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: #f8fbfe;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.field[hidden] {
  display: none;
}

.band-options {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.band-options legend {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}

.band-option {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.band-option input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--blue);
}

.field label {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}

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

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--ink);
}

.field input:hover,
.field textarea:hover,
.field select:hover {
  border-color: var(--blue);
}

.field input::placeholder {
  color: #64748b;
}

.searchable-select {
  position: relative;
}

.searchable-select::after {
  position: absolute;
  top: 15px;
  right: 14px;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  content: "";
  pointer-events: none;
  transform: rotate(45deg);
}

.searchable-select input {
  padding-right: 38px;
}

.searchable-options {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  background: var(--surface);
  box-shadow: 0 8px 20px rgb(15 23 42 / 14%);
}

.searchable-option {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  color: var(--ink);
  cursor: pointer;
}

.searchable-option + .searchable-option {
  border-top: 1px solid var(--line);
}

.searchable-option:hover,
.searchable-option.is-active {
  background: var(--mist);
}

.searchable-option small,
.searchable-empty {
  color: var(--muted);
}

.searchable-empty {
  padding: 12px;
}

.filter-submit {
  align-self: end;
}

.state-message {
  padding: 16px;
  border: 1px solid var(--soft-blue);
  border-radius: var(--radius-small);
  background: var(--mist);
  color: var(--navy);
}

.state-error {
  border-color: #f0a6a0;
  background: var(--danger-bg);
  color: var(--danger-dark);
}

.empty-state {
  padding: clamp(30px, 8vw, 58px) 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-medium);
  background: #f8fbfe;
  text-align: center;
}

.empty-state h2,
.empty-state h3 {
  margin: 0 0 6px;
}

.empty-state p {
  max-width: 520px;
  margin: 0 auto 18px;
  color: var(--muted);
}

.table-wrap {
  width: 100%;
}

table,
thead,
tbody,
tr,
th,
td {
  display: block;
}

thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

tbody {
  display: grid;
  gap: 12px;
}

tbody tr {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
}

tbody td {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #e2e8f0;
  overflow-wrap: anywhere;
}

tbody td::before {
  content: attr(data-label);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
}

tbody td:last-child {
  border-bottom: 0;
}

.serial-cell {
  color: var(--ink);
  font-weight: 760;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.row-actions .button {
  flex: 1 1 auto;
}

.pagination {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
  color: var(--muted);
}

.pagination > div {
  display: flex;
  gap: 8px;
}

.management-layout {
  display: grid;
  gap: 16px;
}

.reference-groups {
  display: grid;
  gap: 26px;
}

.reference-group + .reference-group {
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.reference-group > h2 {
  margin: 0 0 12px;
  color: var(--navy);
  font-size: 1.12rem;
}

.technician-ont-section {
  margin-top: 24px;
}

.technician-ont-form {
  margin-bottom: 18px;
  position: static;
}

.technician-ont-filter {
  max-width: 360px;
  margin: 0 0 14px auto;
}

.technician-ont-fields {
  display: grid;
  gap: 12px;
}

.technician-ont-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.technician-ont-form .technician-ont-actions .button {
  width: auto;
  margin-top: 0;
}

.technician-note-cell {
  white-space: pre-wrap;
}

.management-form,
.management-list {
  padding: clamp(20px, 4vw, 30px);
  border-radius: var(--radius-medium);
}

.management-form {
  align-self: start;
}

.management-form h2,
.management-list h2 {
  margin-bottom: 18px;
}

.management-form .button {
  width: 100%;
  margin-top: 16px;
}

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

.reference-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
}

.reference-copy {
  min-width: 0;
}

.reference-copy strong {
  display: block;
  overflow-wrap: anywhere;
}

.reference-copy span {
  color: var(--muted);
  font-size: 0.84rem;
}

.reference-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.trash-filter-bar {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  flex-direction: column;
  margin-bottom: 8px;
}

.trash-filter-bar > .field {
  width: 100%;
}

.trash-result-pill {
  display: flex;
  min-height: 44px;
  align-items: center;
  align-self: flex-end;
  margin-left: auto;
  margin: 0;
  padding: 9px 14px;
  border: 1px solid var(--navy);
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}

.dialog {
  width: min(560px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-large);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
  color: var(--ink);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.65);
}

.dialog > form {
  max-height: calc(100dvh - 28px);
  padding: clamp(20px, 5vw, 30px);
  overflow-y: auto;
}

.dialog > div {
  max-height: calc(100dvh - 28px);
  padding: clamp(20px, 5vw, 30px);
  overflow-y: auto;
}

.ont-detail-list {
  display: grid;
  grid-template-columns: minmax(100px, 0.4fr) 1fr;
  gap: 12px 18px;
  margin: 0;
}

.ont-detail-list dt {
  color: var(--muted);
}

.ont-detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.dialog-wide {
  width: min(720px, calc(100% - 28px));
}

.dialog-confirm {
  width: min(460px, calc(100% - 28px));
}

.dialog-confirm h2 {
  margin: 0 0 8px;
}

.dialog-confirm p {
  margin: 0;
  color: var(--muted);
}

.dialog-confirm .field:not([hidden]) {
  margin-top: 16px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.dialog-heading h2 {
  margin: 3px 0 0;
  font-size: 1.45rem;
}

.dialog-description {
  margin: -8px 0 20px;
  color: var(--muted);
}

.dialog code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--mist);
  color: var(--navy);
  font-size: 0.92em;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--blue);
  background: var(--mist);
}

.dialog .field + .field {
  margin-top: 16px;
}

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

.import-result {
  margin-top: 18px;
}

.import-report {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: #f8fbfe;
}

.import-report.is-error {
  border-color: #f0a6a0;
  background: var(--danger-bg);
}

.import-report.is-success {
  border-color: #75c7a1;
  background: var(--success-bg);
}

.import-report h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.import-report p {
  margin: 0;
}

.import-errors {
  max-height: 220px;
  margin: 12px 0 0;
  padding-left: 22px;
  overflow-y: auto;
  color: var(--danger-dark);
}

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

.toast {
  padding: 14px 16px;
  border: 1px solid var(--navy);
  border-radius: var(--radius-small);
  background: var(--ink);
  color: var(--surface);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.2);
}

.toast.is-error {
  border-color: #f0a6a0;
  background: var(--danger-dark);
}

@media (min-width: 620px) {
  .app-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .primary-nav {
    display: flex;
  }

  .nav-item {
    min-width: 108px;
    padding-inline: 18px;
  }

  .page-heading {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }

  .page-heading .button-primary {
    flex: 0 0 auto;
  }

  .section-heading-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .filter-bar {
    grid-template-columns: minmax(220px, 1.5fr) minmax(150px, 1fr) minmax(150px, 1fr);
  }

  .filter-submit,
  #reset-filter {
    justify-self: start;
  }

  .pagination {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .reference-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

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

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

  .technician-note-field {
    grid-column: span 2;
  }
}

@media (min-width: 620px) {
  .trash-filter-bar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
  }

  .trash-filter-bar > .field:first-child {
    flex: 1.5 1 220px;
  }

  .trash-filter-bar > .field:nth-child(2) {
    flex: 1 1 180px;
  }

  .trash-result-pill {
    flex: 0 0 auto;
    align-self: flex-end;
  }
}

@media (min-width: 780px) {
  .trash-filter-bar {
    flex-direction: row;
    align-items: flex-end;
    gap: 16px;
  }

  .trash-filter-bar > .field:first-child {
    flex: 1.5 1 220px;
  }

  .trash-filter-bar > .field:nth-child(2) {
    flex: 1 1 180px;
  }

  .trash-result-pill {
    flex: 0 0 auto;
    align-self: flex-end;
  }

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

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

  thead {
    position: static;
    display: table-header-group;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    clip-path: none;
    white-space: normal;
  }

  tbody {
    display: table-row-group;
  }

  tr {
    display: table-row;
  }

  th,
  td {
    display: table-cell;
  }

  th {
    padding: 12px 14px;
    border-bottom: 2px solid var(--navy);
    color: var(--navy);
    font-size: 0.77rem;
    font-weight: 800;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.045em;
  }

  tbody tr {
    display: table-row;
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  tbody tr:hover {
    background: #f6faff;
  }

  tbody td {
    display: table-cell;
    padding: 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
  }

  tbody td::before {
    content: none;
  }

  .actions-heading {
    text-align: right;
  }

  .row-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

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

@media (min-width: 1020px) {
  .technician-ont-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1020px) {
  .trash-filter-bar {
    flex-direction: row;
    align-items: flex-end;
  }

  .summary-layout {
    grid-template-columns: minmax(245px, 0.68fr) minmax(0, 2.32fr);
  }

  .filter-bar {
    grid-template-columns: minmax(200px, 1.5fr) repeat(3, minmax(130px, 1fr)) auto auto;
    align-items: end;
  }

  .management-layout {
    grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.7fr);
    align-items: start;
  }

  .management-form {
    position: sticky;
    top: 18px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .button,
  .nav-item,
  .icon-button,
  .skip-link {
    transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease, color 120ms ease;
  }
}

@media (forced-colors: active) {
  .nav-item.is-active,
  .button,
  .total-panel {
    border: 1px solid ButtonText;
  }
}
