:root {
  --bg0: #0f172a;
  --bg1: #1e293b;
  --bg2: #334155;
  --line: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-dim: rgba(59, 130, 246, 0.12);
  --online: #10b981;
  --offline: #ef4444;
  --warn: #f59e0b;
  --bad: #ef4444;
  --good: #10b981;
  --unknown: #64748b;
  --font-display: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 3rem;
}

.nav-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: var(--bg1);
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.88rem;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  background: var(--bg2);
  color: var(--text);
}

.nav-tab.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #60a5fa;
  font-weight: 600;
}

.badge-disabled {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-offline {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.badge-online {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.comment-text {
  color: var(--muted);
  font-size: 0.82rem;
  display: block;
  margin-top: 0.2rem;
}

.shell {
  max-width: 1320px;
  margin: 0 auto;
}

.hero {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}

.brand span {
  color: #60a5fa;
  font-weight: 600;
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 45rem;
  font-size: 1rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.meta-row strong {
  color: var(--text);
  font-weight: 600;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.4rem;
  align-items: center;
}

.olt-dropdown {
  min-width: 16rem;
  background: var(--bg2);
  border-color: var(--line);
  font-weight: 500;
}

button, .btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  padding: 0.55rem 1rem;
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

button.primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

button.btn-danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
  font-weight: 600;
}

button.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

button:disabled {
  opacity: 0.75;
  cursor: wait;
}

.spinner-icon {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid rgba(96, 165, 250, 0.3);
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: app-spin 0.65s linear infinite;
  vertical-align: -0.15em;
  margin-right: 0.4rem;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  border: 1px solid var(--line);
  padding: 1rem 1.1rem;
  min-height: 5.5rem;
  border-radius: 6px;
}

.stat .label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat .value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  margin-top: 0.35rem;
  letter-spacing: -0.02em;
}

.stat.online .value { color: var(--online); }
.stat.offline .value { color: var(--offline); }

.toolbar {
  display: grid;
  grid-template-columns: 2fr repeat(2, minmax(10rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

input, select {
  width: 100%;
  background: var(--bg1);
  border: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  padding: 0.7rem 0.9rem;
  border-radius: 4px;
}

input:focus, select:focus {
  outline: 2px solid var(--accent-dim);
  border-color: var(--accent);
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: auto;
  background: rgba(18, 32, 40, 0.75);
  backdrop-filter: blur(6px);
}

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

th, td {
  padding: 0.75rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #152833;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  z-index: 1;
}

td.name {
  white-space: normal;
  min-width: 15rem;
  font-weight: 500;
}

td.mono, th.mono {
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.olt-badge {
  display: inline-block;
  background: rgba(46, 196, 182, 0.12);
  color: var(--accent);
  border: 1px solid rgba(46, 196, 182, 0.3);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

.badge.online { color: var(--online); }
.badge.offline { color: var(--offline); }

mark {
  background: rgba(233, 196, 106, 0.35);
  color: #fff;
  border-radius: 2px;
  padding: 0 0.2rem;
}

.sig {
  font-family: var(--font-mono);
  font-weight: 600;
}

.sig.good { color: var(--good); }
.sig.warn { color: var(--warn); }
.sig.bad { color: var(--bad); }
.sig.unknown, .sig.offline { color: var(--unknown); }

.status-line {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.25rem;
}

.status-line.error { color: var(--bad); }

.empty {
  padding: 2.5rem;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 900px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  body { padding: 1rem; }
  .stat .value { font-size: 1.6rem; }
}

@media (max-width: 700px) {
  .table-wrap {
    border: 0;
    overflow: visible;
    background: transparent;
    backdrop-filter: none;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table { min-width: 0; }
  thead { display: none; }

  tbody tr {
    margin-bottom: 0.8rem;
    padding: 0.45rem 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: linear-gradient(160deg, var(--bg1), var(--bg2));
  }

  tbody td {
    display: grid;
    grid-template-columns: minmax(6.5rem, 34%) minmax(0, 1fr);
    gap: 0.65rem;
    align-items: start;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid rgba(140, 180, 200, 0.1);
    white-space: normal;
    overflow-wrap: anywhere;
  }

  tbody td::before {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  tbody td:nth-child(1),
  tbody td:last-child {
    display: none;
  }

  tbody td:nth-child(2)::before { content: "User"; }
  tbody td:nth-child(3)::before { content: "Profile"; }
  tbody td:nth-child(4)::before { content: "Status"; }
  tbody td:nth-child(5)::before { content: "IP Address"; }
  tbody td:nth-child(6)::before { content: "Uptime"; }
  tbody td:nth-child(7)::before { content: "Caller ID / MAC"; }
  tbody td:nth-child(8)::before { content: "Last Logged Out"; }

  tbody td:last-of-type { border-bottom: 0; }
  tbody td.empty {
    display: block;
    padding: 2rem 1rem;
  }
  tbody td.empty::before { display: none; }
}

/* Small Action Button in Table Rows */
.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 4px;
  background: var(--bg2);
  border: 1px solid var(--accent);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.btn-sm:hover {
  background: var(--accent);
  color: #062c28;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(46, 196, 182, 0.25);
}

/* Modal Backdrop & Card */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(8, 14, 18, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease-out;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-card {
  width: 100%;
  max-width: 580px;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(46, 196, 182, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  padding: 1.1rem 1.4rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-title-box h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.modal-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  border-radius: 4px;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  transform: none;
}

.modal-body {
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--unknown);
}

.status-dot.online {
  background: var(--online);
  box-shadow: 0 0 8px var(--online);
}

.status-dot.offline {
  background: var(--offline);
  box-shadow: 0 0 8px var(--offline);
}

.status-dot.loading {
  background: var(--warn);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

.status-time {
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.modal-stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  padding: 0.85rem 1rem;
  border-radius: 8px;
}

.modal-stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.modal-stat-card .stat-val {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.modal-stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.modal-info-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.85rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.info-label {
  color: var(--muted);
}

.info-value {
  color: var(--text);
  font-weight: 500;
}

.modal-log-msg {
  font-size: 0.82rem;
  color: var(--accent);
  min-height: 1rem;
}

.modal-footer {
  padding: 1rem 1.4rem;
  background: var(--bg2);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

button.secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
  color: var(--text);
}

button.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

