/* ============================================================
   Skylimit Telecalling — Light theme design system
   Adapted from DESIGN.md (Linear) tokens, inverted to light.
   Fonts: Inter (Linear substitute) + JetBrains Mono.
   ============================================================ */

:root {
  /* Brand & accent */
  --primary: #5e6ad2;
  --primary-hover: #4f5cc8;
  --primary-focus: #e3e6fb;
  --on-primary: #ffffff;
  --brand-secure: #7a7fad;

  /* Text */
  --ink: #191a1b;
  --ink-muted: #4c4f56;
  --ink-subtle: #8a8f98;
  --ink-tertiary: #a8abb3;

  /* Surfaces (light ladder) */
  --canvas: #ffffff;
  --surface-1: #f7f8f8;
  --surface-2: #f1f2f4;
  --surface-3: #ebedef;
  --surface-4: #e8eaec;
  --hairline: #e6e8eb;
  --hairline-strong: #d9dbe0;
  --hairline-tertiary: #c9cbd2;

  /* Semantic */
  --semantic-success: #27a644;
  --semantic-success-bg: #e7f6ec;
  --semantic-warning: #b45309;
  --semantic-warning-bg: #fdf2e3;
  --semantic-danger: #d33b3b;
  --semantic-danger-bg: #fcebeb;
  --semantic-info-bg: #e3e6fb;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(16, 17, 18, 0.04), 0 1px 3px rgba(16, 17, 18, 0.05);
  --shadow-2: 0 4px 12px rgba(16, 17, 18, 0.08);
  --shadow-3: 0 12px 32px rgba(16, 17, 18, 0.12);

  /* Surfaces (alias for missing --surface) */
  --surface: #ffffff;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-xxl: 24px;
  --r-pill: 9999px;
  --radius: 8px;
  --radius-lg: 12px;

  /* Spacing */
  --sp-xxs: 4px;
  --sp-xs: 8px;
  --sp-sm: 12px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-xxl: 48px;

  /* Typography */
  --font-display: "Inter", "SF Pro Display", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-text: "Inter", "SF Pro Text", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --text-display-xl: 64px;
  --text-display-lg: 44px;
  --text-display-md: 32px;
  --text-headline: 26px;
  --text-card-title: 20px;
  --text-subhead: 18px;
  --text-body-lg: 17px;
  --text-body: 15px;
  --text-body-sm: 14px;
  --text-caption: 12px;
  --text-button: 14px;
  --text-eyebrow: 13px;
  --text-mono: 13px;

  /* Layout */
  --nav-height: 56px;
  --content-max: 1280px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-text);
  font-size: var(--text-body);
  line-height: 1.5;
  letter-spacing: -0.05px;
  color: var(--ink);
  background: var(--canvas);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--ink);
  letter-spacing: -0.02em;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

/* ---------- Top navigation ---------- */

.top-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(1.8) blur(12px);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: var(--sp-lg);
  padding: 0 var(--sp-xl);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  font-family: var(--font-display);
  font-size: var(--text-card-title);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
}

.nav-brand .brand-logo {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  object-fit: contain;
}

.nav-brand:hover {
  color: var(--ink);
}

.nav-links {
  display: flex;
  gap: var(--sp-xs);
  flex: 1;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: 6px 12px;
  border-radius: var(--r-md);
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--ink-subtle);
  border: 1px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-link:hover {
  color: var(--ink);
  background: var(--surface-1);
}

.nav-link.active {
  color: var(--ink);
  background: var(--surface-1);
  border-color: var(--hairline);
}

.nav-spacer {
  flex: 1;
}

.nav-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  font-family: var(--font-text);
  font-size: var(--text-button);
  font-weight: 500;
  line-height: 1.2;
  padding: 8px 14px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
  min-height: 36px;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: var(--on-primary);
}

.btn-secondary {
  background: var(--surface-1);
  color: var(--ink);
  border-color: var(--hairline);
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--hairline-strong);
}

.btn-tertiary {
  background: transparent;
  color: var(--ink);
}

.btn-tertiary:hover {
  background: var(--surface-1);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
  min-height: 30px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  min-height: 32px;
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--ink-subtle);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--surface-1);
  color: var(--ink);
}

.btn .spinner {
  display: none;
}

.btn.loading .spinner {
  display: inline-block;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ---------- Layout ---------- */

.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-xl) var(--sp-xl) var(--sp-xxl);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-lg);
  margin-bottom: var(--sp-xl);
  flex-wrap: wrap;
}

.eyebrow {
  font-family: var(--font-text);
  font-size: var(--text-eyebrow);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-subtle);
  margin-bottom: var(--sp-xs);
}

.page-title {
  font-size: var(--text-display-md);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: var(--sp-xs);
}

.page-desc {
  font-size: var(--text-subhead);
  color: var(--ink-muted);
  max-width: 640px;
}

.page-actions {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
  flex-wrap: wrap;
}

/* ---------- Cards ---------- */

.card {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  box-shadow: var(--shadow-1);
  margin-bottom: var(--sp-lg);
}

.card:last-child {
  margin-bottom: 0;
}

.card-surface {
  background: var(--surface-1);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-lg);
}

.card-title {
  font-size: var(--text-card-title);
  font-weight: 500;
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: var(--text-caption);
  color: var(--ink-subtle);
  font-weight: 400;
}

.card-actions {
  display: flex;
  gap: var(--sp-xs);
  align-items: center;
}

/* ---------- Stat cards ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-md);
  margin-bottom: var(--sp-xl);
}

.stat-card {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}

.stat-card .stat-label {
  font-size: var(--text-caption);
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-subtle);
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: var(--text-display-lg);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-top: var(--sp-xs);
  white-space: nowrap;
}

.stat-card .stat-value.mono {
  font-family: var(--font-mono);
  font-size: var(--text-display-md);
  letter-spacing: -0.02em;
}

.stat-card .stat-delta {
  margin-top: var(--sp-xs);
  font-size: var(--text-caption);
  color: var(--ink-subtle);
}

.stat-card .stat-delta .up { color: var(--semantic-success); }
.stat-card .stat-delta .down { color: var(--semantic-danger); }

/* ---------- Grid ---------- */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-lg);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-lg);
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--canvas);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body-sm);
}

.data-table thead th {
  text-align: left;
  padding: var(--sp-sm) var(--sp-md);
  font-size: var(--text-caption);
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-subtle);
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-1);
  white-space: nowrap;
}

.data-table tbody td {
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-muted);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--surface-1);
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table .strong {
  font-weight: 600;
  color: var(--ink);
}

.data-table .cell-title {
  font-weight: 500;
  color: var(--ink);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xxs);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--text-caption);
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.badge-neutral {
  background: var(--surface-2);
  color: var(--ink-muted);
}

.badge-primary {
  background: var(--semantic-info-bg);
  color: var(--primary);
}

.badge-success {
  background: var(--semantic-success-bg);
  color: var(--semantic-success);
}

.badge-warning {
  background: var(--semantic-warning-bg);
  color: var(--semantic-warning);
}

.badge-danger {
  background: var(--semantic-danger-bg);
  color: var(--semantic-danger);
}

/* ---------- Empty / loading / error states ---------- */

.state {
  padding: var(--sp-xxl);
  text-align: center;
  color: var(--ink-subtle);
}

.state-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-lg);
  background: var(--surface-1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--ink-subtle);
  margin-bottom: var(--sp-md);
}

.state h3 {
  font-size: var(--text-card-title);
  font-weight: 500;
  color: var(--ink);
  margin-bottom: var(--sp-xs);
}

.state p {
  font-size: var(--text-body-sm);
  color: var(--ink-subtle);
  max-width: 460px;
  margin: 0 auto var(--sp-md);
}

.skeleton {
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-1) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* ---------- Forms & filters ---------- */

.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex-wrap: wrap;
  margin-bottom: var(--sp-lg);
}

.input, .select {
  font-family: var(--font-text);
  font-size: var(--text-body-sm);
  color: var(--ink);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 8px 12px;
  min-height: 36px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.input:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-focus);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--ink-subtle);
  pointer-events: none;
}

.search-box .input {
  padding-left: 32px;
  width: 240px;
}

/* ---------- Charts ---------- */

.chart-wrap {
  position: relative;
  width: 100%;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: #1c1d20;
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  border-radius: var(--r-sm);
  padding: 8px 10px;
  box-shadow: var(--shadow-3);
  z-index: 20;
  opacity: 0;
  transition: opacity 0.1s ease;
  white-space: nowrap;
}

/* ---------- Legend ---------- */

.legend {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  flex-wrap: wrap;
  margin-top: var(--sp-sm);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  font-size: var(--text-caption);
  color: var(--ink-muted);
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--primary);
  flex: 0 0 auto;
}

/* ---------- Hub page ---------- */

.hub-hero {
  padding: var(--sp-xxl) 0 var(--sp-xl);
}

.hub-title {
  font-size: var(--text-display-xl);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin-bottom: var(--sp-md);
}

.hub-sub {
  font-size: var(--text-subhead);
  color: var(--ink-muted);
  max-width: 560px;
  margin-bottom: var(--sp-xl);
}

.hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-lg);
}

.hub-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: var(--sp-xl);
  box-shadow: var(--shadow-1);
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.hub-card:hover {
  border-color: var(--hairline-strong);
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

.hub-card .hub-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
}

.hub-card h2 {
  font-size: var(--text-headline);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.hub-card p {
  color: var(--ink-muted);
  font-size: var(--text-body);
  flex: 1;
}

.hub-card .status-tag {
  align-self: flex-start;
}

/* ---------- Status banner ---------- */

.source-badge {
  margin-bottom: var(--sp-lg);
}

.status-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-sm);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--primary);
  background: var(--surface-1);
  border-radius: var(--r-md);
  padding: var(--sp-md);
  margin-bottom: var(--sp-lg);
  font-size: var(--text-body-sm);
  color: var(--ink-muted);
}

.status-banner.warning {
  border-left-color: var(--semantic-warning);
}

.status-banner strong {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Table toolbar (search + sort) ---------- */

.table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-1);
  flex-wrap: wrap;
}

.sort-btns {
  display: flex;
  gap: var(--sp-xxs);
  flex-wrap: wrap;
}

.reset-filters-btn {
  border-style: dashed;
  color: var(--ink-subtle);
}

.reset-filters-btn:hover {
  border-color: var(--semantic-danger);
  color: var(--semantic-danger);
}

/* ---------- Customer table ---------- */

.customer-table .customer-main {
  cursor: pointer;
  transition: background 0.1s ease;
}

.customer-table .customer-main:hover {
  background: var(--surface-1);
}

.cell-chevron {
  width: 32px;
  text-align: center;
}

.chevron {
  display: inline-block;
  font-size: 10px;
  color: var(--ink-subtle);
  transition: transform 0.2s ease;
}

.chevron.open {
  transform: rotate(90deg);
}

.cell-phone {
  font-size: var(--text-caption);
  color: var(--ink-tertiary);
  font-family: var(--font-mono);
}

.customer-detail {
  display: none;
}

.customer-detail.open {
  display: table-row;
}

.customer-detail td {
  padding: 0 !important;
  border-bottom: 2px solid var(--hairline) !important;
}

/* ---------- Bill detail sub-table ---------- */

.bill-detail-wrap {
  padding: var(--sp-sm) var(--sp-lg) var(--sp-sm) var(--sp-xxl);
}

.bill-detail-header {
  display: grid;
  grid-template-columns: 140px 100px 100px 1fr 1fr 1fr 120px 100px 1fr;
  gap: var(--sp-xs);
  padding: var(--sp-xxs) 0;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: var(--sp-xxs);
}

.bill-detail-row {
  display: grid;
  grid-template-columns: 140px 100px 100px 1fr 1fr 1fr 120px 100px 1fr;
  gap: var(--sp-xs);
  padding: var(--sp-xxs) 0;
  border-bottom: 1px solid var(--surface-2);
  align-items: center;
  font-size: var(--text-caption);
  color: var(--ink-muted);
}

.bill-detail-row:last-child {
  border-bottom: none;
}

.bill-detail-cell {
  padding: 2px 0;
  white-space: nowrap;
}

.bill-detail-header .bill-detail-cell {
  font-size: var(--text-caption);
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-subtle);
}

/* ---------- Urgency row highlights ---------- */

.row-critical {
  background: rgba(211, 59, 59, 0.04) !important;
}

.row-high {
  background: rgba(224, 124, 0, 0.03) !important;
}

.row-medium {
  background: rgba(180, 83, 9, 0.02) !important;
}

/* ---------- Aging Analysis ---------- */

.aging-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-md);
  padding: 0 var(--sp-lg) var(--sp-md);
}

.aging-summary-stat {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xxs);
}

.aging-summary-label {
  font-size: var(--text-caption);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-subtle);
}

.aging-summary-value {
  font-family: var(--font-display);
  font-size: var(--text-headline);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.aging-summary-value.danger {
  color: var(--semantic-danger);
}

.aging-stacked-bar {
  display: flex;
  height: 8px;
  margin: 0 var(--sp-lg) var(--sp-md);
  border-radius: var(--r-pill);
  overflow: hidden;
  background: var(--surface-2);
}

.aging-stacked-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.aging-stacked-seg:first-child {
  border-radius: var(--r-pill) 0 0 var(--r-pill);
}

.aging-stacked-seg:last-child {
  border-radius: 0 var(--r-pill) var(--r-pill) 0;
}

.aging-table {
  margin: 0;
}

.aging-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: var(--sp-xs);
  vertical-align: middle;
}

.aging-bar-cell {
  width: 140px;
}

.aging-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.aging-bar-fill {
  height: 100%;
  border-radius: var(--r-pill);
  transition: width 0.3s ease;
}

/* ---------- Heatmap ---------- */

.heatmap-table .heatmap-cell {
  padding: var(--sp-xs) !important;
}

.heatmap-value {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--r-xs);
  font-size: var(--text-caption);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Collection Priority ---------- */

.priority-score {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-bottom: 2px;
}

.priority-score-fill {
  height: 100%;
  border-radius: var(--r-pill);
  transition: width 0.3s ease;
}

.priority-score-fill.urgent {
  background: var(--semantic-danger);
}

.priority-score-fill.high {
  background: var(--semantic-warning);
}

.priority-score-fill.normal {
  background: var(--primary);
}

.priority-score-label {
  font-size: var(--text-caption);
  color: var(--ink-subtle);
  font-variant-numeric: tabular-nums;
}

.rank-urgent {
  color: var(--semantic-danger) !important;
  font-weight: 700 !important;
}

.rank-high {
  color: var(--semantic-warning) !important;
  font-weight: 600 !important;
}

/* ---------- Telecaller Guide ---------- */

.telecaller-guide {
  margin-bottom: var(--sp-lg);
}

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--hairline);
  border-bottom: none;
  transition: background 0.15s ease;
}

.guide-header:hover {
  background: var(--surface-3);
}

.guide-title {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  font-weight: 600;
  font-size: var(--text-body);
  color: var(--ink);
}

.guide-title svg {
  color: var(--primary);
}

.guide-chevron {
  color: var(--ink-subtle);
  transition: transform 0.2s ease;
}

.guide-chevron.open {
  transform: rotate(180deg);
}

.guide-body {
  display: none;
  padding: 16px 20px 20px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.guide-body.open {
  display: block;
}

.guide-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-md);
}

.guide-step {
  display: flex;
  gap: var(--sp-sm);
  align-items: flex-start;
}

.guide-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-caption);
  font-weight: 700;
}

.guide-step-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.guide-step-content strong {
  font-size: var(--text-caption);
  color: var(--ink);
}

.guide-step-content span {
  font-size: 12px;
  color: var(--ink-subtle);
  line-height: 1.4;
}

/* ---------- Filter Bar ---------- */

.filter-bar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  width: 100%;
}

/* --- Date Filter --- */

.date-filter {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

.date-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
}

.date-chip {
  position: relative;
}

.date-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.date-chip.active:hover {
  background: var(--ink);
  opacity: 0.9;
}

.date-custom-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
}

.date-custom-row .input[type="date"] {
  max-width: 160px;
}

.date-custom-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-subtle);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink-subtle);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: var(--font-body);
}

.filter-chip:hover {
  border-color: var(--primary);
  color: var(--ink);
  background: var(--surface-2);
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.filter-chip.active .filter-chip-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.filter-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-chip-count {
  background: var(--surface-3);
  color: var(--ink-subtle);
  padding: 1px 6px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
}

.export-btn {
  margin-left: auto;
  white-space: nowrap;
}

/* ---------- Today's Call List ---------- */

.today-call-card {
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
}

.today-call-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-sm);
}

.today-progress {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.today-progress-bar {
  width: 120px;
  height: 8px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.today-progress-fill {
  height: 100%;
  background: var(--semantic-success);
  border-radius: var(--r-pill);
  transition: width 0.3s ease;
}

.today-progress-label {
  font-size: var(--text-caption);
  font-weight: 700;
  color: var(--semantic-success);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
}

.today-call-list {
  padding: 0 var(--sp-lg) var(--sp-md);
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

.today-call-empty {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: var(--sp-lg);
  color: var(--semantic-success);
  font-weight: 600;
}

.today-call-empty .guide-step-num {
  background: var(--semantic-success);
}

.today-call-table-wrap {
  border: none;
  border-radius: 0;
  margin: 0 var(--sp-lg) var(--sp-md);
}

.today-call-table {
  width: 100%;
}

.today-call-table .today-call-rank-cell {
  width: 40px;
  text-align: center;
  font-weight: 700;
  color: var(--ink-subtle);
}

.today-call-table .urgency-critical .today-call-rank-cell {
  color: var(--semantic-danger);
}

.today-call-table .urgency-high .today-call-rank-cell {
  color: var(--semantic-warning);
}

.today-call-table .urgency-medium .today-call-rank-cell {
  color: var(--primary);
}

.today-call-table .today-call-actions-cell {
  display: flex;
  gap: var(--sp-xxs);
  white-space: nowrap;
}

.today-call-table .status-select {
  font-size: 12px;
  min-height: 30px;
  padding: 4px 8px;
}

.today-call-table .today-call-item {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--hairline);
  transition: all 0.15s ease;
}

.today-call-table .today-call-item:hover {
  background: var(--surface-2);
  border-color: var(--primary);
}

/* ---------- Call & WhatsApp Buttons ---------- */

.btn-call {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-call:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #25d366;
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-whatsapp:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ---------- Call Status Badge ---------- */

.call-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--semantic-success);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  margin-left: var(--sp-xs);
  white-space: nowrap;
}

.call-status-time {
  opacity: 0.8;
  font-weight: 400;
}

/* ---------- Detail Actions ---------- */

.detail-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 12px 16px;
  border-top: 1px solid var(--hairline);
  background: var(--surface-2);
}

.detail-select-wrap {
  flex-shrink: 0;
}

/* ---------- Daily Summary ---------- */

.daily-summary-card {
  border: 1px solid var(--hairline);
}

.daily-summary-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--sp-md);
  padding: 0 var(--sp-lg) var(--sp-md);
}

.daily-summary-stat {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.daily-stat-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.daily-stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.daily-stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-subtle);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.daily-stat-value {
  font-family: var(--font-display);
  font-size: var(--text-body);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------- Modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-md);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--hairline);
}

.modal-title {
  font-weight: 700;
  font-size: var(--text-headline);
  color: var(--ink);
}

.modal-subtitle {
  font-size: var(--text-caption);
  color: var(--ink-subtle);
  margin-top: 2px;
}

.modal-body {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

.modal-footer {
  padding: 12px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-sm);
  border-top: 1px solid var(--hairline);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xxs);
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-subtle);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---------- Detail Panel ---------- */

.detail-content {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
}

.detail-panel {
  border-left: 1px solid var(--hairline);
  padding: 0;
  max-height: 500px;
  overflow-y: auto;
}

.detail-panel-header {
  padding: 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline);
}

.detail-panel-name {
  font-weight: 700;
  font-size: var(--text-body);
  color: var(--ink);
}

.detail-panel-phone {
  font-size: var(--text-caption);
  color: var(--ink-subtle);
  margin-top: 2px;
}

.detail-panel-balance {
  font-family: var(--font-display);
  font-size: var(--text-headline);
  font-weight: 700;
  margin-top: 8px;
}

.detail-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-subtle);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: block;
}

.detail-panel-actions {
  display: flex;
  gap: var(--sp-xs);
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  flex-wrap: wrap;
}

.detail-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
}

.detail-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

/* ---------- Promise Items ---------- */

.promise-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 6px 0;
  gap: var(--sp-sm);
}

.promise-info {
  font-size: 12px;
  color: var(--ink);
  line-height: 1.4;
}

.promise-date {
  font-size: 11px;
  color: var(--ink-subtle);
  white-space: nowrap;
  flex-shrink: 0;
}

.promise-overdue {
  background: rgba(211, 59, 59, 0.05);
  margin: 0 -16px;
  padding: 6px 16px;
  border-left: 3px solid var(--semantic-danger);
}

.promise-active {
  background: rgba(39, 166, 68, 0.05);
  margin: 0 -16px;
  padding: 6px 16px;
  border-left: 3px solid var(--semantic-success);
}

/* ---------- Call Timeline ---------- */

.call-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: var(--sp-sm);
  padding: 6px 0;
  position: relative;
}

.timeline-item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 24px;
  bottom: -2px;
  width: 1px;
  background: var(--hairline);
}

.timeline-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: var(--surface-2);
  border-radius: 50%;
  z-index: 1;
}

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-label {
  font-size: 12px;
  color: var(--ink);
  line-height: 1.4;
}

.timeline-time {
  font-size: 11px;
  color: var(--ink-subtle);
}

/* ---------- Remarks ---------- */

.note-input-wrap {
  display: flex;
  gap: var(--sp-xs);
  align-items: flex-start;
  margin-bottom: 8px;
}

.note-textarea {
  flex: 1;
  resize: vertical;
  min-height: 36px;
  font-size: 12px;
}

.note-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.note-item {
  position: relative;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding-right: 24px;
}

.note-text {
  font-size: 12px;
  color: var(--ink);
  line-height: 1.4;
}

.note-meta {
  font-size: 10px;
  color: var(--ink-subtle);
  margin-top: 2px;
}

.note-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  border: none;
  background: none;
  color: var(--ink-subtle);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.note-delete:hover {
  background: var(--semantic-danger);
  color: #fff;
}

/* ---------- Bulk Actions / Row Select ---------- */

.cell-checkbox {
  width: 36px;
  text-align: center;
  padding: 0 !important;
}

.row-select {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 8px 12px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  margin: 0 var(--sp-sm) var(--sp-sm);
}

.bulk-count {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.bulk-actions {
  display: flex;
  gap: var(--sp-xs);
  align-items: center;
}

.bulk-actions .input {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.bulk-actions .input option {
  background: var(--surface);
  color: var(--ink);
}

/* ---------- Back to Top ---------- */

.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-2);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.15s ease;
  z-index: 90;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-3);
}

.back-to-top:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Calling Status KPIs ---------- */

.calling-status-grid {
  grid-template-columns: repeat(4, 1fr);
}

.calling-status-card .stat-label {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.calling-status-card .stat-label svg {
  width: 12px;
  height: 12px;
}

.calling-status-card .stat-value {
  font-size: var(--text-display-md);
}

/* ---------- Paid Customers Table ---------- */

.paid-table-card {
  border: 2px solid var(--semantic-success);
  border-radius: var(--r-lg);
}

.paid-table-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
}

.paid-table-card .card-title {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}

/* ---------- Purge Button ---------- */

.purge-wrap {
  display: flex;
  justify-content: flex-end;
  padding: 0 0 var(--sp-lg);
}

.btn-danger {
  background: var(--semantic-danger);
  color: #fff;
  border-color: var(--semantic-danger);
}

.btn-danger:hover {
  background: #b92e2e;
  border-color: #b92e2e;
  color: #fff;
}

/* ---------- Footer ---------- */

.site-footer {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-xl) var(--sp-xl) var(--sp-lg);
  border-top: 1px solid var(--hairline);
  text-align: center;
  font-size: var(--text-caption);
  color: var(--ink-subtle);
}

.site-footer a {
  color: var(--primary);
  font-weight: 500;
}

.site-footer a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .calling-status-grid { grid-template-columns: repeat(4, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .bill-detail-header, .bill-detail-row {
    grid-template-columns: 120px 80px 80px 1fr 1fr 1fr 100px 80px 1fr;
  }
  .aging-summary-row { grid-template-columns: repeat(2, 1fr); }
  .guide-steps { grid-template-columns: repeat(2, 1fr); }
  .today-call-item { flex-wrap: wrap; }
  .today-call-actions { width: 100%; justify-content: flex-start; }
  .today-call-table-wrap { margin: 0 var(--sp-md) var(--sp-md); }
  .daily-summary-grid { grid-template-columns: repeat(3, 1fr); }
  .detail-content { grid-template-columns: 1fr; }
  .detail-panel { border-left: none; border-top: 1px solid var(--hairline); max-height: none; }
}

@media (max-width: 768px) {
  .calling-status-grid { grid-template-columns: repeat(2, 1fr); }
  .top-nav { padding: 0 var(--sp-md); }
  .nav-meta .nav-extra { display: none; }
  .page { padding: var(--sp-lg) var(--sp-md) var(--sp-xxl); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .hub-grid { grid-template-columns: 1fr; }
  .hub-title { font-size: var(--text-display-lg); }
  .search-box .input { width: 100%; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .bill-detail-header { display: none; }
  .bill-detail-row {
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-xxs);
    padding: var(--sp-xs) 0;
  }
  .bill-detail-row .bill-detail-cell:nth-child(1) { font-weight: 600; color: var(--ink); grid-column: 1 / -1; }
  .bill-detail-row .bill-detail-cell:nth-child(2)::before { content: "Issued: "; color: var(--ink-subtle); }
  .bill-detail-row .bill-detail-cell:nth-child(3)::before { content: "Due: "; color: var(--ink-subtle); }
  .bill-detail-row .bill-detail-cell:nth-child(4)::before { content: "Value: "; color: var(--ink-subtle); }
  .bill-detail-row .bill-detail-cell:nth-child(5)::before { content: "Paid: "; color: var(--ink-subtle); }
  .bill-detail-row .bill-detail-cell:nth-child(6)::before { content: "Balance: "; font-weight: 600; color: var(--ink); }
  .aging-summary-row { grid-template-columns: 1fr 1fr; }
  .heatmap-table, .priority-table { font-size: var(--text-caption); }
  .guide-steps { grid-template-columns: 1fr; }
  .today-call-card .card-header { flex-direction: column; align-items: flex-start; }
  .today-call-item { flex-direction: column; align-items: flex-start; }
  .today-call-actions { flex-wrap: wrap; }
  .today-call-table-wrap { overflow-x: auto; }
  .today-call-table { font-size: var(--text-caption); }
  .detail-actions { flex-wrap: wrap; }
  .filter-chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: var(--sp-xs); }
  .date-chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: var(--sp-xs); }
  .date-custom-row { flex-wrap: wrap; }
  .date-custom-row .input[type="date"] { max-width: 100%; flex: 1; }
  .daily-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .bulk-bar { flex-wrap: wrap; }
  .bulk-actions { flex-wrap: wrap; width: 100%; }
  .modal { margin: var(--sp-md); }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .stat-card .stat-value { font-size: var(--text-display-md); }
  .today-call-rank { width: 24px; height: 24px; font-size: 11px; }
  .daily-summary-grid { grid-template-columns: 1fr; }
}
