body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #f5f7fa;
  color: #1f2937;
}

.nav-toggle {
  display: none;
}

.sidebar-overlay {
  display: none;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 64px;
  height: 100%;
  background: #0f172a;
  color: #cbd5e1;
  z-index: 1001;
  transition: width 0.2s ease;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.22);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.sidebar-toggle {
  color: #e2e8f0;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.sidebar-brand {
  color: #fff;
  font-weight: 700;
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #cbd5e1;
  text-decoration: none;
  padding: 10px;
  border-radius: 6px;
}

.nav-item:hover {
  background: rgba(148, 163, 184, 0.2);
}

.nav-icon {
  display: inline-flex;
  width: 20px;
  justify-content: center;
  font-size: 1.05rem;
}

.nav-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #0f172a;
  color: #fff;
  padding: 12px 20px;
  margin-left: 64px;
  transition: margin-left 0.2s ease;
}

.topbar nav a {
  color: #cbd5e1;
  margin-left: 14px;
  text-decoration: none;
}

/* Desktop: use sidebar as the single navigation surface. */
.top-nav {
  display: none;
}

.hamburger {
  display: none;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  color: #e2e8f0;
  margin-right: 10px;
}

.title {
  font-weight: 700;
}

.container {
  padding: 20px;
  margin-left: 64px;
  transition: margin-left 0.2s ease;
}

.cards {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.07);
  padding: 18px;
}

.graph-card {
  margin-top: 16px;
}

.pie-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
}

.pie-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pie-chart {
  width: 260px;
  height: 260px;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
}

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

.pie-table {
  width: 100%;
  border-collapse: collapse;
}

.pie-table th,
.pie-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 8px;
  white-space: nowrap;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 8px;
  vertical-align: middle;
}

.metric {
  font-size: 1.5rem;
  font-weight: 700;
}

.sub {
  color: #64748b;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.filters input,
.filters select,
.filters button,
.btn {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
}

.filters button,
.btn {
  background: #0f766e;
  color: #fff;
  border: none;
  text-decoration: none;
  cursor: pointer;
}

.btn-secondary {
  background: #475569;
}

.users-actions {
  margin: 8px 0 14px;
}

.users-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.olt-row-actions {
  flex-wrap: wrap;
}

.olt-row-actions .btn {
  white-space: nowrap;
}

.users-delete-form {
  margin: 0;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.9rem;
}

.btn-danger {
  background: #b91c1c;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-size: 0.95rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 14px;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.25);
  padding: 14px;
}


.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.modal-head h3 {
  margin: 0;
}

.modal-close {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  background: #fff;
  color: #334155;
  cursor: pointer;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-form input,
.modal-form select,
.modal-form button {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
}

.modal-form button {
  background: #0f766e;
  border: none;
  color: #fff;
  cursor: pointer;
}

.modal-form .btn-secondary {
  background: #475569;
}

.router-checklist {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px;
  background: #f8fafc;
}

.router-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: #334155;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.meta {
  color: #475569;
}

.hardware-meta {
  margin-bottom: 10px;
  font-weight: 500;
}

.hw-section-title {
  margin: 8px 0 6px;
  font-weight: 700;
  color: #0f172a;
}

.hw-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.hw-card table th {
  background: #f8fafc;
  color: #334155;
}

.hw-status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.hw-status-pill.status-up,
.hw-status-pill.status-online {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.hw-status-pill.status-down,
.hw-status-pill.status-offline {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.hw-status-pill.status-unknown {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}

.onu-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0 10px;
}

.onu-legend-title {
  font-weight: 700;
  color: #1e293b;
}

.onu-legend-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.82rem;
  white-space: nowrap;
}

.onu-legend-critical {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #991b1b;
}

.onu-legend-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.onu-legend-normal {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.onu-legend-offline {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #64748b;
}

/* ── ONU / PON severity row highlighting ── */
tr.sev-critical {
  background: #fff1f2;
}
tr.sev-critical td {
  color: #991b1b;
  font-weight: 600;
}
tr.sev-warning {
  background: #fffbeb;
}
tr.sev-warning td {
  color: #92400e;
}
tr.sev-normal {
  background: #f0fdf4;
}
tr.sev-normal td {
  color: #166534;
}
tr.sev-offline {
  background: #f8fafc;
}
tr.sev-offline td {
  color: #94a3b8;
}

/* Severity badge cells */
td.sev-badge-critical {
  color: #991b1b;
  font-weight: 700;
}
td.sev-badge-warning {
  color: #b45309;
  font-weight: 600;
}
td.sev-badge-normal {
  color: #15803d;
}
td.sev-badge-unknown,
td.sev-badge-offline {
  color: #94a3b8;
}

/* Status pill */
td.status-online  { color: #15803d; font-weight: 600; }
td.status-offline { color: #94a3b8; }
td.status-up      { color: #15803d; font-weight: 600; }
td.status-down    { color: #b91c1c; }

/* ── ONU name + custom description cell ── */
.onu-name-cell {
  white-space: normal;
  min-width: 140px;
}

.onu-name {
  display: block;
  font-weight: 500;
}

.onu-custom-desc {
  display: block;
  font-size: 0.8rem;
  color: #0369a1;
  font-style: italic;
  margin-top: 2px;
}

.onu-edit-btn {
  padding: 3px 7px;
  font-size: 0.85rem;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
}

.onu-edit-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.onu-action-cell {
  white-space: nowrap;
}

.onu-action-cell .btn {
  margin-right: 6px;
}

.onu-action-cell .btn:last-child {
  margin-right: 0;
}

.onu-config-props {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f3f4f2;
  padding: 0;
  overflow: hidden;
}

.onu-config-desc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.onu-config-desc-row label {
  min-width: 84px;
  color: #0f172a;
}

.onu-config-desc-row input {
  flex: 1 1 240px;
}

.onu-config-table {
  width: 100%;
  border-collapse: collapse;
}

.onu-config-table th,
.onu-config-table td {
  padding: 4px 8px;
  border: 1px solid #4b5563;
  white-space: normal;
  font-size: 0.84rem;
  vertical-align: top;
  background: #f3f4f2;
}

.onu-config-table th {
  width: 22%;
  color: #0f172a;
  font-weight: 700;
  background: #a7d4ef;
}

.onu-config-table .onu-config-sec th {
  background: #8ec8e8;
  color: #0b1620;
  font-size: 0.92rem;
  text-align: left;
}

/* ── PON port tabs ── */
.pon-tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0;
  padding: 10px 10px 0;
  background: #fff;
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid #e2e8f0;
}

.pon-tab {
  padding: 8px 16px;
  border: 1px solid #cbd5e1;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
  bottom: -2px;
  transition: background 0.15s ease, color 0.15s ease;
}

.pon-tab:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.pon-tab-active {
  background: #fff;
  color: #0f172a;
  border-color: #e2e8f0;
  border-bottom-color: #fff;
  font-weight: 600;
}

.pon-tab-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 6px;
  margin-left: 4px;
}

.pon-tab-online {
  background: #dcfce7;
  color: #15803d;
}

.pon-tab-total {
  color: #64748b;
  background: none;
  padding-left: 2px;
}

.pon-panel {
  border-radius: 0 0 8px 8px;
  border-top: none;
}

.pon-panel-meta {
  padding: 8px 10px 4px;
  margin: 0;
  font-size: 0.88rem;
}

.banner {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.banner-warning {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.table-wrap {
  overflow-x: auto;
  background: #fff;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

/* Allow long access lists to wrap in User Access table columns. */
.users-col-wrap {
  white-space: normal;
  word-break: break-word;
  min-width: 220px;
}

.router-edit-input,
.router-edit-select {
  width: 100%;
  min-width: 170px;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #b8c4d3;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
}

.router-edit-input:focus,
.router-edit-select:focus {
  outline: none;
  border-color: #0f766e;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.15);
}

.router-enabled-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #334155;
}

.router-row-btn {
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  background: #0f766e;
  color: #fff;
  cursor: pointer;
}

.router-delete-form {
  margin: 0;
}

.pager {
  margin-top: 12px;
}

.pager a {
  margin-right: 12px;
  color: #0369a1;
  text-decoration: none;
}

.login-shell {
  min-height: calc(100vh - 100px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
  padding: 20px;
}

.login-card h2 {
  margin: 0 0 12px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-form input,
.login-form button {
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
}

.login-form button {
  background: #0f766e;
  color: #fff;
  border: none;
  cursor: pointer;
}

.nav-toggle:checked ~ .sidebar {
  width: 240px;
}

.nav-toggle:checked ~ .sidebar .sidebar-brand,
.nav-toggle:checked ~ .sidebar .nav-label {
  opacity: 1;
  width: auto;
}

.nav-toggle:checked ~ .topbar,
.nav-toggle:checked ~ .topbar + .container {
  margin-left: 240px;
}

@media (max-width: 900px) {
  .hamburger {
    display: inline-block;
  }

  .top-nav {
    display: none;
  }

  .sidebar {
    left: -280px;
    width: 260px;
    transition: left 0.2s ease;
  }

  .sidebar-head {
    justify-content: flex-start;
  }

  .sidebar-brand,
  .nav-label {
    opacity: 1;
    width: auto;
  }

  .nav-item {
    padding: 10px 12px;
  }

  .topbar {
    justify-content: flex-start;
    margin-left: 0;
  }

  .container {
    padding: 14px;
    margin-left: 0;
  }

  .pie-layout {
    grid-template-columns: 1fr;
  }

  .pie-chart {
    width: 220px;
    height: 220px;
  }

  .login-shell {
    min-height: calc(100vh - 84px);
  }

  .nav-toggle:checked ~ .sidebar {
    left: 0;
  }

  .nav-toggle:checked ~ .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(2, 6, 23, 0.45);
  }

  .nav-toggle:checked ~ .topbar,
  .nav-toggle:checked ~ .topbar + .container {
    margin-left: 0;
  }
}
