:root {
  /* Exem Networks brand */
  --navy: #002366;
  --navy-dark: #001a4d;
  --navy-light: #003380;
  --accent: #e60012;
  --accent-dark: #c0000f;
  --accent-light: #ff1a2e;

  --sidebar-w: 260px;
  --topbar-h: 64px;
  --bg: #f8f9fa;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --border: #d0d5dd;
  --green: #2e7d32;
  --red: #e60012;
  --orange: #e65100;
  --blue: #002366;
  --shadow: 0 1px 4px rgba(0, 35, 102, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
.hidden { display: none !important; }

/* Logo */
.brand-logo {
  display: block;
  max-width: 100%;
  height: auto;
}
.brand-logo-sm { max-height: 36px; }
.brand-logo-md { max-height: 52px; }
.brand-logo-lg { max-height: 72px; margin: 0 auto; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--navy-dark) 0%, var(--navy) 55%, var(--navy-light) 100%);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--navy);
  border-radius: 6px;
  padding: 2.5rem;
  width: min(420px, 92vw);
  box-shadow: 0 12px 40px rgba(0, 26, 77, 0.25);
}
.login-brand {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.login-brand p {
  color: var(--muted);
  font-size: .85rem;
  margin-top: .75rem;
  letter-spacing: 0.04em;
}
.login-card label {
  display: block;
  font-size: .85rem;
  margin-bottom: .35rem;
  color: var(--navy);
  font-weight: 500;
}
.login-card input {
  width: 100%;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 1rem;
}
.login-card input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 2px rgba(0, 35, 102, 0.12);
}
.login-error { color: var(--accent); font-size: .85rem; margin-top: .75rem; text-align: center; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  transition: transform .25s;
  border-right: 1px solid var(--navy-dark);
}
.sidebar-brand {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-brand .brand-logo { max-height: 48px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem 0 1rem; }
.nav-label {
  font-size: .68rem;
  letter-spacing: .1em;
  opacity: .5;
  padding: 1rem 1.25rem .35rem;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.25rem;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: .95rem;
  border-left: 3px solid transparent;
  transition: background .15s, border-color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active {
  background: rgba(230, 0, 18, 0.15);
  border-left-color: var(--accent);
  color: #fff;
}
.nav-item .material-icons-outlined { font-size: 20px; opacity: .9; }
.nav-item.hidden { display: none; }
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .75rem;
  padding: .65rem 1rem;
  background: var(--accent);
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
}
.sidebar-logout:hover { background: var(--accent-dark); }
.sidebar-user {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .85rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: .85rem;
}
.sidebar-user .material-icons-outlined { font-size: 28px; opacity: .85; }
.sidebar-user small { display: block; opacity: .65; text-transform: capitalize; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; color: var(--navy); font-weight: 500; margin-bottom: .35rem; }
.form-group input {
  width: 100%;
  max-width: 360px;
  padding: .65rem .85rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.form-group textarea, .detail-field textarea {
  width: 100%;
  max-width: 100%;
  min-height: 120px;
  padding: .65rem .85rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  resize: vertical;
}
.form-group select, .detail-field select {
  width: 100%;
  max-width: 360px;
  padding: .65rem .85rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.hint { font-size: .8rem; color: var(--muted); margin-top: .35rem; }
.char-count { font-size: .8rem; color: var(--muted); text-align: right; margin-top: .25rem; }
.role-tag {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 3px;
  font-size: .75rem;
  text-transform: uppercase;
  font-weight: 500;
}
.role-admin { background: #e8eaf6; color: var(--navy); }
.role-technician { background: #fce4ec; color: var(--accent-dark); }
.role-finance { background: #f5f5f5; color: #333; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 2px solid var(--navy);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.search-wrap {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 .75rem;
}
.search-wrap .material-icons-outlined { color: var(--navy); }
.search-wrap input { flex: 1; border: none; background: transparent; padding: .6rem 0; outline: none; }
.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; }
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: .35rem;
  border-radius: 50%;
  color: var(--navy);
  display: inline-flex;
}
.icon-btn:hover { background: rgba(0, 35, 102, 0.08); color: var(--accent); }

.page-content { padding: 1.5rem; }
.page-title { font-size: 1.35rem; font-weight: 500; color: var(--navy); margin-bottom: 1.25rem; }
.page-title small { display: block; font-size: .85rem; color: var(--muted); font-weight: 400; margin-top: .25rem; }

/* Cards & stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.stat-card-link {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  width: 100%;
  text-align: left;
  font: inherit;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.stat-card-link:hover,
.stat-card-link:focus-visible {
  border-color: var(--navy-light);
  box-shadow: 0 4px 14px rgba(0, 35, 102, 0.12);
  transform: translateY(-1px);
  outline: none;
}
.bar-row-link {
  cursor: pointer;
  border-radius: 4px;
  padding: .35rem .5rem;
  margin: -.35rem -.5rem;
  transition: background .15s;
}
.bar-row-link:hover,
.bar-row-link:focus-visible {
  background: rgba(0, 35, 102, 0.06);
  outline: none;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon.navy { background: rgba(0, 35, 102, 0.1); color: var(--navy); }
.stat-icon.accent { background: rgba(230, 0, 18, 0.1); color: var(--accent); }
.stat-icon.green { background: rgba(46, 125, 50, 0.1); color: var(--green); }
.stat-icon.blue { background: rgba(0, 35, 102, 0.12); color: var(--navy-light); }
.stat-icon.orange { background: rgba(230, 81, 0, 0.1); color: var(--orange); }
.stat-icon.red { background: rgba(230, 0, 18, 0.12); color: var(--accent); }
/* legacy class names from JS */
.stat-icon.teal { background: rgba(0, 35, 102, 0.1); color: var(--navy); }
.stat-value { font-size: 1.75rem; font-weight: 500; line-height: 1.1; color: var(--navy); }
.stat-label { font-size: .85rem; color: var(--muted); margin-top: .25rem; }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 960px) { .panel-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 500;
  font-size: .95rem;
  color: var(--navy);
  background: #fafbfc;
}
.panel-head .material-icons-outlined { color: var(--accent); vertical-align: middle; margin-right: .35rem; }
.panel-body { padding: 0; overflow-x: auto; }
.panel-body.padded { padding: 1rem 1.25rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1rem;
}
.toolbar select, .toolbar input[type=search] {
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-block { width: 100%; justify-content: center; padding: .75rem; }
.btn-sm { padding: .35rem .65rem; font-size: .8rem; }

.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
  text-align: left;
  padding: .75rem 1rem;
  background: var(--navy);
  color: #fff;
  border-bottom: 2px solid var(--navy-dark);
  font-weight: 500;
  white-space: nowrap;
}
.data-table td { padding: .65rem 1rem; border-bottom: 1px solid #eee; vertical-align: middle; }
.data-table tr:hover td { background: #f5f7fa; }
.data-table .mono { font-family: ui-monospace, monospace; font-size: .8rem; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }

.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 3px;
  font-size: .75rem;
  font-weight: 500;
  white-space: nowrap;
}
.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-grey { background: #eceff1; color: #546e7a; }
.badge-red { background: #ffebee; color: var(--accent-dark); }
.badge-orange { background: #fff3e0; color: #e65100; }
.badge-teal { background: rgba(0, 35, 102, 0.08); color: var(--navy); }
.badge-blue { background: rgba(0, 35, 102, 0.1); color: var(--navy); }

.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-right: .35rem;
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.25);
}
.offline-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #bdbdbd;
  margin-right: .35rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: .85rem;
  color: var(--muted);
}
.pagination button {
  padding: .35rem .75rem;
  border: 1px solid var(--navy);
  background: var(--card);
  color: var(--navy);
  border-radius: 4px;
  cursor: pointer;
}
.pagination button:hover:not(:disabled) { background: var(--navy); color: #fff; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state .material-icons-outlined { font-size: 48px; opacity: .35; color: var(--navy); }

.bar-chart { padding: 1rem 1.25rem; }
.bar-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; font-size: .8rem; }
.bar-label { width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 8px; background: #eee; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--navy), var(--accent)); border-radius: 4px; }
.bar-val { width: 60px; text-align: right; color: var(--muted); }

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 26, 77, 0.5);
  z-index: 90;
}
.mobile-only { display: none; }

/* Subscriber detail */
.subscriber-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.subscriber-header h2 { margin-bottom: 0; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: var(--navy);
  text-decoration: none;
  font-size: .9rem;
  margin-bottom: .75rem;
}
.back-link:hover { color: var(--accent); }
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}
.tab-btn {
  padding: .75rem 1.25rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--navy); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 768px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-field { margin-bottom: 1rem; }
.detail-field label {
  display: block;
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: .25rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.detail-field input, .detail-field select {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .95rem;
}
.detail-field input:disabled { background: #f5f5f5; color: var(--muted); }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #f8fafc; }
.row-active { background: #eef6ff !important; }
.clickable-row:hover td { background: rgba(0, 35, 102, 0.06) !important; }
.link-user { color: var(--navy); text-decoration: none; font-weight: 500; }
.link-user:hover { color: var(--accent); text-decoration: underline; }
.info-row {
  display: flex;
  justify-content: space-between;
  padding: .5rem 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: .9rem;
}
.info-row:last-child { border-bottom: none; }
.msg-success { color: var(--green); font-size: .85rem; margin-top: .75rem; }
.msg-error { color: var(--accent); font-size: .85rem; margin-top: .75rem; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .mobile-only { display: inline-flex; }
  .search-wrap { max-width: none; }
}
