/* ═══════════════════════════════════════════════════════════════
   CDN CRM — Professional ISP Operations UI
   Design: Clean ops-grade dashboard. Dark sidebar, crisp whites,
   precise data density. Typography-led, no decorative noise.
═══════════════════════════════════════════════════════════════ */

/* ── Tokens ────────────────────────────────────────────────── */
:root{
  /* Brand */
  --brand:        #2563eb;
  --brand-dark:   #1d4ed8;
  --brand-light:  #eff6ff;
  --success:      #16a34a;
  --success-lt:   #f0fdf4;
  --warning:      #d97706;
  --warning-lt:   #fffbeb;
  --danger:       #dc2626;
  --danger-lt:    #fef2f2;
  --info:         #0891b2;
  --info-lt:      #ecfeff;

  /* Surfaces */
  --bg:           #f1f4f8;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e2e8f0;
  --border-strong:#cbd5e1;

  /* Sidebar */
  --s-bg:         #0f1929;
  --s-border:     rgba(255,255,255,.06);
  --s-hover:      rgba(255,255,255,.055);
  --s-active-bg:  rgba(37,99,235,.18);
  --s-active:     #60a5fa;
  --s-text:       #8ba3c0;
  --s-text-hi:    #e2eaf4;
  --s-label:      rgba(139,163,192,.38);
  --sidebar-w:    240px;

  /* Typography */
  --ink:          #0f172a;
  --ink-2:        #334155;
  --muted:        #64748b;

  /* Radius */
  --r-sm:   6px;
  --r-md:   8px;
  --r-lg:   12px;

  /* Shadow */
  --sh-card:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sh-float: 0 4px 16px rgba(0,0,0,.10);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ────────────────────────────────────────────────── */
.app-wrap { display: flex; min-height: 100vh; }
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.content { padding: 1.25rem 1.5rem; flex: 1; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--s-bg);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--s-border);
  box-shadow: 2px 0 12px rgba(0,0,0,.25);
}

/* Brand */
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-shrink: 0;
  padding: .85rem .9rem .8rem;
  border-bottom: 1px solid var(--s-border);
}
.sidebar-logo {
  height: 26px;
  width: auto;
  max-width: 130px;
  filter: brightness(0) invert(1);
  object-fit: contain;
}
.brand-badge {
  margin-left: auto;
  background: rgba(37,99,235,.2);
  color: #60a5fa;
  font-size: .55rem;
  font-weight: 700;
  letter-spacing: .1em;
  padding: .14rem .45rem;
  border-radius: 99px;
  border: 1px solid rgba(37,99,235,.3);
  text-transform: uppercase;
}

/* Nav scroll */
.nav-menu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .5rem 0 2rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
.nav-menu::-webkit-scrollbar { width: 3px; }
.nav-menu::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.1);
  border-radius: 3px;
}

/* Section label */
.nav-label {
  font-size: .58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--s-label);
  padding: .95rem .9rem .22rem;
  user-select: none;
}

/* Nav link */
.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .475rem .8rem;
  margin: 1px .45rem;
  border-radius: var(--r-md);
  color: var(--s-text);
  text-decoration: none;
  font-size: .8rem;
  font-weight: 500;
  transition: background .1s, color .1s;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item i {
  width: 16px;
  text-align: center;
  font-size: .9rem;
  flex-shrink: 0;
  opacity: .7;
  transition: opacity .1s;
}
.nav-item:hover {
  background: var(--s-hover);
  color: var(--s-text-hi);
}
.nav-item:hover i { opacity: 1; }
.nav-item.active {
  background: var(--s-active-bg);
  color: var(--s-active);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 2.5px;
  border-radius: 0 2px 2px 0;
  background: var(--s-active);
}
.nav-item.active i { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .55rem;
  font-weight: 700;
  padding: .1rem .38rem;
  border-radius: 99px;
  min-width: 17px;
  text-align: center;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--surface);
  padding: .6rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 1px 0 var(--border);
}
.page-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: .55rem;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  line-height: 1.2;
  padding: .22rem .4rem;
  border-radius: var(--r-md);
  transition: background .1s;
  flex-shrink: 0;
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-card);
  background: var(--surface);
}
.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0 !important;
  font-weight: 600;
  font-size: .85rem;
  padding: .7rem 1rem;
  color: var(--ink-2);
}

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-card {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: 1rem 1.1rem;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: transform .15s, box-shadow .15s;
  height: 100%;
}
.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-float);
  color: inherit;
}
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
}
.stat-label {
  color: var(--muted);
  font-size: .78rem;
  margin-top: .18rem;
}

/* Colour helpers */
.bg-soft-blue   { background: #dbeafe; color: #1d4ed8; }
.bg-soft-green  { background: #dcfce7; color: #15803d; }
.bg-soft-amber  { background: #fef3c7; color: #b45309; }
.bg-soft-red    { background: #fee2e2; color: #b91c1c; }
.bg-soft-grey   { background: #e2e8f0; color: #475569; }
.bg-soft-purple { background: #ede9fe; color: #6d28d9; }
.bg-soft-cyan   { background: #cffafe; color: #0e7490; }

/* ── Tables ─────────────────────────────────────────────────── */
.table { margin: 0; font-size: .82rem; }
.table thead th {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 1px solid var(--border) !important;
  padding: .55rem .75rem;
  background: var(--surface-2);
}
.table tbody td {
  vertical-align: middle;
  padding: .5rem .75rem;
  border-color: var(--border);
}
.table-hover tbody tr:hover { background: #f8fafd; }
.table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border) !important;
  background: var(--surface-2);
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-label {
  font-weight: 600;
  font-size: .8rem;
  margin-bottom: .28rem;
  color: var(--ink-2);
}
.form-control, .form-select {
  border-color: var(--border-strong);
  border-radius: var(--r-md);
  font-size: .85rem;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  outline: none;
}
.form-control-sm, .form-select-sm { font-size: .8rem; }
.form-text { font-size: .74rem; color: var(--muted); margin-top: .25rem; }
.input-group-text {
  background: var(--surface-2);
  border-color: var(--border-strong);
  font-size: .85rem;
  color: var(--muted);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  font-weight: 600;
  border-radius: var(--r-md);
  font-size: .82rem;
  transition: all .12s;
  letter-spacing: .01em;
}
.btn-sm { font-size: .78rem; padding: .3rem .65rem; }
.btn-lg { font-size: .9rem; padding: .55rem 1.1rem; }
.btn-brand, .btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-brand:hover, .btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}
.btn-xs {
  padding: .18rem .45rem;
  font-size: .72rem;
  line-height: 1.45;
  border-radius: var(--r-sm);
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  font-size: .67rem;
  font-weight: 600;
  letter-spacing: .02em;
  padding: .25em .55em;
  border-radius: 5px;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  border-radius: var(--r-lg);
  border: 1px solid transparent;
  font-size: .84rem;
}

/* ── Day book filter bar — compact, clean ─────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: .6rem .85rem;
  margin-bottom: 1rem;
  box-shadow: var(--sh-card);
}
.filter-bar .filter-group {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.filter-bar label.filter-lbl {
  font-size: .74rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  margin: 0;
}
.filter-bar .form-control,
.filter-bar .form-select {
  height: 32px;
  padding: .25rem .55rem;
  font-size: .8rem;
}
.filter-bar .btn { height: 32px; padding: .25rem .7rem; }
.filter-bar .divider {
  width: 1px;
  height: 20px;
  background: var(--border-strong);
  margin: 0 .25rem;
}
.filter-shortcuts { display: flex; gap: .25rem; }
.filter-shortcuts .btn {
  font-size: .72rem;
  padding: .18rem .5rem;
  border-radius: var(--r-sm);
}

/* ── KPI row — horizontal summary bar ──────────────────── */
.kpi-row {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-card);
  overflow: hidden;
}
.kpi-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.1rem;
  min-width: 0;
}
.kpi-card.kpi-highlight {
  background: var(--surface-2);
}
.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.kpi-body { min-width: 0; }
.kpi-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  white-space: nowrap;
  margin-bottom: .2rem;
}
.kpi-value {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1;
  white-space: nowrap;
}
.kpi-divider {
  width: 1px;
  background: var(--border);
  flex-shrink: 0;
  margin: .6rem 0;
}

/* ── Metric strip — used elsewhere ─────────────────────── */
.metric-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}
.metric-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: .9rem 1rem;
  box-shadow: var(--sh-card);
}
.metric-tile .m-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .25rem;
}
.metric-tile .m-value {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1;
}
.metric-tile .m-sub {
  font-size: .7rem;
  color: var(--muted);
  margin-top: .2rem;
}

/* ── Section divider / page header ──────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: .5rem;
}
.page-header h5 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}
.page-header .sub {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .1rem;
}

/* ── Status badges ───────────────────────────────────────── */
.status-active       { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.status-expiring     { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.status-inactive     { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.status-disconnected { background: #1e293b; color: #e2e8f0; border: 1px solid #334155; }

/* ── Login ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #0f1929 0%, #1e3a5f 50%, #0f1929 100%);
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
}
.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-logo {
  max-width: 200px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto .65rem;
}
.login-tagline {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--brand);
  margin: .35rem 0 .15rem;
}

/* ── Utility ─────────────────────────────────────────────── */
.font-monospace { font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace; }
.text-ink  { color: var(--ink); }
.text-muted-sm { font-size: .75rem; color: var(--muted); }
.fw-700 { font-weight: 700; }
.no-uc { text-transform: none !important; }
.sticky-top { top: 0; }

/* ── Print ───────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print, .btn, .filter-bar .btn { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); width: 240px; }
  .main { margin-left: 0; }
  .content { padding: .85rem; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .filter-bar { gap: .35rem; }
  .kpi-row { flex-direction: column; }
  .kpi-divider { width: auto; height: 1px; margin: 0 .6rem; }
  .kpi-card { padding: .75rem .9rem; }
  .kpi-value { font-size: 1.1rem; }
}
