/* ================================================================
   ATWS Manager — Design System v2
   Warm neutral base · Pastel accent system · Editorial type
   ================================================================ */

/* ---- Tokens: Light (default) ---- */
:root {
  /* Backgrounds */
  --bg-app:        #FBF9F6;
  --bg-surface:    #FFFFFF;
  --bg-surface-bd: #E8E4DD;
  --bg-struct:     #F7F8FA;
  --bg-struct-bd:  #E3E5E9;
  --bg-sidebar:    #F0EDE7;
  --bg-sidebar-bd: #E0DCD5;

  /* Text */
  --text-1: #2B2924;
  --text-2: #7A766D;

  /* Dividers */
  --divider: #ECE8E1;

  /* Accents — tint (bg) + label (text/icon) */
  --sage:       #D6E5D2;
  --sage-fg:    #5C7256;
  --blue:       #D2E0EB;
  --blue-fg:    #4D6A82;
  --clay:       #EDD5C0;
  --clay-fg:    #8C5A3D;
  --rose:       #EDD4D2;
  --rose-fg:    #8C4F47;
  --ochre:      #EDE0BE;
  --ochre-fg:   #8C6D2E;

  /* Primary CTA — high-contrast neutral */
  --cta:        #2B2924;
  --cta-fg:     #FFFFFF;
  --cta-hover:  #1A1815;

  /* Danger */
  --danger:     #C94040;
  --danger-bg:  #F9EDED;

  /* Shadows */
  --sh-card:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sh-raise: 0 4px 20px rgba(0,0,0,.10);
  --sh-modal: 0 24px 64px rgba(0,0,0,.18), 0 4px 20px rgba(0,0,0,.08);

  /* Typography */
  --ff-display: "SF Pro Rounded", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --ff-body:    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 48px;

  /* Radius */
  --r-xs:   6px;
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-full: 9999px;

  /* Sidebar */
  --sidebar-w: 220px;

  /* Transitions */
  --t-fast: 150ms ease;
  --t-mid:  220ms ease;
  --t-slow: 350ms ease;
}

/* ---- Tokens: Dark mode ---- */
[data-theme="dark"] {
  --bg-app:        #1C1B19;
  --bg-surface:    #252320;
  --bg-surface-bd: #34322D;
  --bg-struct:     #1D1F23;
  --bg-struct-bd:  #2C2E33;
  --bg-sidebar:    #211F1D;
  --bg-sidebar-bd: #34322D;

  --text-1: #F2EFE9;
  --text-2: #9A958A;
  --divider: #34322D;

  --sage:       rgba(92, 114, 86, .22);
  --sage-fg:    #8FBF86;
  --blue:       rgba(77, 106, 130, .22);
  --blue-fg:    #7AADC9;
  --clay:       rgba(140, 90, 61, .22);
  --clay-fg:    #D4956E;
  --rose:       rgba(140, 79, 71, .22);
  --rose-fg:    #D48880;
  --ochre:      rgba(140, 109, 46, .22);
  --ochre-fg:   #D4B46E;

  --cta:       #F2EFE9;
  --cta-fg:    #1C1B19;
  --cta-hover: #E8E4DC;

  --danger:    #E06060;
  --danger-bg: rgba(192, 64, 64, .15);

  --sh-card:  0 1px 3px rgba(0,0,0,.3);
  --sh-raise: 0 4px 20px rgba(0,0,0,.35);
  --sh-modal: 0 24px 64px rgba(0,0,0,.55);
}

/* ================================================================
   Reset + base
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--ff-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; }

a { color: inherit; text-decoration: none; }

/* ================================================================
   HOME SCREEN
   ================================================================ */

#home-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  z-index: 200;
  overflow: hidden;
  transition: opacity var(--t-slow);
}

#home-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Animated logo element (absolutely positioned at final brand location) */
.home-logo-anim {
  position: absolute;
  top: 40px;
  left: 44px;
  width: 44px;
  height: 44px;
  z-index: 210;
  pointer-events: none;
  will-change: transform, opacity;
}

.home-logo-anim .atws-icon {
  width: 44px;
  height: 44px;
}

/* Home layout — brand + cards */
#home-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease;
}

#home-content.visible {
  opacity: 1;
  pointer-events: auto;
}

.home-brand {
  position: absolute;
  top: 40px;
  left: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* invisible spacer — keeps wordmark aligned with where logo settles */
.home-brand-spacer {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  opacity: 0;
}

.home-brand-wordmark {
  font-family: var(--ff-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: 0.01em;
}

/* Center container for primary + feature cards */
.home-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -54%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-6);
  width: max-content;
}

/* Primary cards row (Dashboard + Settings) */
.home-primary-row {
  display: flex;
  gap: var(--sp-4);
}

.home-primary-card {
  width: 160px;
  padding: var(--sp-7) var(--sp-4) var(--sp-5);
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  transition: box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
}

.home-primary-card:hover {
  box-shadow: var(--sh-raise);
  transform: translateY(-2px);
  border-color: var(--divider);
}

.home-primary-card:active {
  transform: translateY(0);
  box-shadow: var(--sh-card);
}

.home-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--bg-struct);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}

.home-card-icon svg { width: 20px; height: 20px; }

.home-card-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
}

/* Feature grid (3×2) — fixed column widths so max-content parent doesn't collapse to 1fr */
.home-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 140px);
  gap: var(--sp-3);
}

.home-feature-card {
  width: 140px;
  padding: var(--sp-6) var(--sp-3) var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  transition: box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
}

.home-feature-card:hover {
  box-shadow: var(--sh-raise);
  transform: translateY(-2px);
  border-color: var(--divider);
}

.home-feature-card:active {
  transform: translateY(0);
  box-shadow: var(--sh-card);
}

.home-feature-card .home-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
}

.home-feature-card .home-card-icon svg { width: 18px; height: 18px; }

.home-feature-card .home-card-label {
  font-size: 13px;
  font-weight: 500;
}

/* Unimplemented feature dim */
.home-feature-card.coming-soon {
  opacity: 0.55;
  cursor: default;
}

.home-feature-card.coming-soon:hover {
  transform: none;
  box-shadow: var(--sh-card);
}

/* Dark mode toggle on home screen */
.home-theme-toggle {
  position: absolute;
  bottom: 32px;
  right: 40px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
}

.home-theme-toggle:hover { color: var(--text-1); }

.home-theme-toggle svg { width: 15px; height: 15px; }

/* ================================================================
   FEATURE SHELL
   ================================================================ */

#feature-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  opacity: 1;
  transition: opacity var(--t-mid);
}

#feature-shell.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ================================================================
   SIDEBAR
   ================================================================ */

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--bg-sidebar-bd);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: background var(--t-mid), border-color var(--t-mid);
}

/* Brand/home button at top */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--bg-sidebar-bd);
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  width: 100%;
  text-align: left;
  transition: background var(--t-fast);
  flex-shrink: 0;
}

.sidebar-brand:hover {
  background: rgba(0,0,0,.03);
}

[data-theme="dark"] .sidebar-brand:hover {
  background: rgba(255,255,255,.03);
}

.sidebar-brand .atws-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.sidebar-brand-wordmark {
  font-family: var(--ff-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: 0.01em;
}

/* Scrollable nav area */
.sidebar-nav-wrap {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--sp-3) var(--sp-2);
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: color var(--t-fast), background var(--t-fast);
}

.sidebar-nav-item:hover {
  color: var(--text-1);
  background: rgba(0,0,0,.04);
}

[data-theme="dark"] .sidebar-nav-item:hover {
  background: rgba(255,255,255,.05);
}

.sidebar-nav-item.active {
  color: var(--text-1);
  background: var(--bg-surface);
  font-weight: 600;
  box-shadow: var(--sh-card);
}

.sidebar-nav-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-nav-icon svg { width: 100%; height: 100%; }

/* Footer: persistent Dashboard + Settings */
.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--bg-sidebar-bd);
  padding: var(--sp-2);
}

.sidebar-footer-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  width: 100%;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: color var(--t-fast), background var(--t-fast);
}

.sidebar-footer-btn:hover {
  color: var(--text-1);
  background: rgba(0,0,0,.04);
}

[data-theme="dark"] .sidebar-footer-btn:hover {
  background: rgba(255,255,255,.05);
}

.sidebar-footer-btn.active {
  color: var(--text-1);
  font-weight: 600;
}

.sidebar-footer-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-footer-icon svg { width: 100%; height: 100%; }

/* ================================================================
   MAIN + TOPBAR
   ================================================================ */

.main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-app);
}

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-6);
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--divider);
  background: var(--bg-app);
}

.topbar-title {
  font-family: var(--ff-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
  letter-spacing: -0.01em;
}

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

.content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--sp-6) 28px 48px;
}

/* ================================================================
   BUTTONS
   ================================================================ */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), opacity var(--t-fast), box-shadow var(--t-fast);
  line-height: 1.3;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--cta);
  color: var(--cta-fg);
  border-color: var(--cta);
}
.btn-primary:hover { background: var(--cta-hover); border-color: var(--cta-hover); }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-1);
  border-color: var(--bg-surface-bd);
}
.btn-secondary:hover { background: var(--bg-struct); }

.btn-sage {
  background: var(--sage);
  color: var(--sage-fg);
  border-color: transparent;
}
.btn-sage:hover { opacity: .88; }

.btn-danger {
  background: var(--bg-surface);
  color: var(--danger);
  border-color: rgba(201, 64, 64, .25);
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text-1); background: rgba(0,0,0,.04); }
[data-theme="dark"] .btn-ghost:hover { background: rgba(255,255,255,.06); }

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: var(--r-xs);
}

/* ================================================================
   ATWS ICON (default logo)
   ================================================================ */

.atws-icon {
  display: block;
  border-radius: 10px;
  overflow: hidden;
}

/* ================================================================
   CARDS
   ================================================================ */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-md);
  box-shadow: var(--sh-card);
  padding: var(--sp-6);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0 0 var(--sp-4);
  font-family: var(--ff-display);
}

/* ================================================================
   KPI STAT CARDS
   ================================================================ */

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

.kpi-card {
  background: var(--bg-struct);
  border: 1px solid var(--bg-struct-bd);
  border-radius: var(--r-md);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-card.kpi-alert .kpi-value { color: var(--rose-fg); }
.kpi-card.kpi-success .kpi-value { color: var(--sage-fg); }

/* ================================================================
   DASHBOARD WIDGET GRID
   ================================================================ */

.dashboard-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.widget-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-md);
  box-shadow: var(--sh-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.widget-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--divider);
}

.widget-title {
  font-family: var(--ff-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}

.widget-subtitle {
  font-size: 12px;
  color: var(--text-2);
}

.widget-body {
  flex: 1 1 auto;
  padding: var(--sp-3) var(--sp-5) var(--sp-4);
}

.widget-hero-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  padding: var(--sp-5);
}

.widget-hero-label {
  font-size: 12px;
  color: var(--text-2);
  padding: 0 var(--sp-5) var(--sp-4);
}

/* Widget section sub-label (e.g. "Overdue") */
.widget-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--rose-fg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--sp-3) var(--sp-5) var(--sp-1);
  border-top: 1px solid var(--divider);
}

/* Widget empty state */
.widget-empty {
  padding: var(--sp-6) 0;
  font-size: 13.5px;
  color: var(--text-2);
  text-align: center;
}

/* Tasks widget */
.widget-count-link {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: color var(--t-fast);
  text-decoration: none;
}
.widget-count-link:hover { color: var(--text-2); }

.widget-task-row,
.widget-reminder-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--divider);
  font-size: 13.5px;
  color: var(--text-1);
}

.widget-task-row:last-child,
.widget-reminder-row:last-child {
  border-bottom: none;
}

.widget-priority-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.widget-priority-dot.high { background: var(--rose-fg); }
.widget-priority-dot.medium { background: var(--clay-fg); }
.widget-priority-dot.low { background: var(--text-2); }

/* Overdue banner */
.overdue-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--rose);
  border: 1px solid rgba(140, 79, 71, .2);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
  font-size: 14px;
  color: var(--rose-fg);
}

.overdue-banner strong { font-weight: 700; }

/* ================================================================
   LIST ROWS (generic)
   ================================================================ */

.list-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-md);
  box-shadow: var(--sh-card);
  margin-bottom: var(--sp-4);
  overflow: hidden;
}

.list-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--divider);
}

.list-card-title {
  font-family: var(--ff-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 13px var(--sp-5);
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background var(--t-fast);
}

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

.row:hover { background: rgba(0,0,0,.02); }

[data-theme="dark"] .row:hover { background: rgba(255,255,255,.03); }

.row-main {
  flex: 1 1 auto;
  min-width: 0;
}

.row-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-subtitle {
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 2px;
}

.row-amount {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-meta {
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  text-align: right;
}

.row-actions {
  display: flex;
  gap: var(--sp-1);
  flex-shrink: 0;
}

/* ================================================================
   STATUS BADGES
   ================================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.5;
}

/* Invoice statuses */
.badge-draft       { background: var(--bg-struct); color: var(--text-2); }
.badge-sent        { background: var(--blue); color: var(--blue-fg); }
.badge-pending-payment { background: var(--ochre); color: var(--ochre-fg); }
.badge-paid        { background: var(--sage); color: var(--sage-fg); }
.badge-overdue     { background: var(--rose); color: var(--rose-fg); }
.badge-cancelled   { background: var(--bg-struct); color: var(--text-2); text-decoration: line-through; }

/* Client statuses */
.badge-lead    { background: var(--blue); color: var(--blue-fg); }
.badge-active  { background: var(--sage); color: var(--sage-fg); }
.badge-inactive { background: var(--ochre); color: var(--ochre-fg); }
.badge-former  { background: var(--bg-struct); color: var(--text-2); }

/* ================================================================
   TABLES
   ================================================================ */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 11px var(--sp-5);
  border-bottom: 1px solid var(--divider);
  white-space: nowrap;
}

.table td {
  padding: 13px var(--sp-5);
  border-bottom: 1px solid var(--divider);
  color: var(--text-1);
  vertical-align: middle;
}

.table tbody tr {
  cursor: pointer;
  transition: background var(--t-fast);
}

.table tbody tr:hover { background: rgba(0,0,0,.02); }
[data-theme="dark"] .table tbody tr:hover { background: rgba(255,255,255,.03); }
.table tbody tr:last-child td { border-bottom: none; }

.table .cell-name    { font-weight: 600; }
.table .cell-mist    { color: var(--text-2); }
.table .cell-amount  { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ================================================================
   STATUS BOARD (kanban columns)
   ================================================================ */

.status-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--sp-3);
  align-items: start;
}

.status-column {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-md);
  box-shadow: var(--sh-card);
  overflow: hidden;
}

.status-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px var(--sp-4);
  border-bottom: 1px solid var(--divider);
}

.status-column-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
}

.status-column-count {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--bg-struct);
  border-radius: var(--r-full);
  padding: 2px 8px;
}

.status-column-body {
  display: flex;
  flex-direction: column;
  max-height: 520px;
  overflow-y: auto;
}

.status-card {
  padding: 11px var(--sp-4);
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background var(--t-fast);
}
.status-card:last-child { border-bottom: none; }
.status-card:hover { background: rgba(0,0,0,.02); }
[data-theme="dark"] .status-card:hover { background: rgba(255,255,255,.03); }

.status-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 3px;
}

.status-card-sub {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
}

.status-card-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.status-column-empty {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}

/* ================================================================
   CONTACT GRID
   ================================================================ */

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-3);
}

.contact-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-md);
  box-shadow: var(--sh-card);
  padding: var(--sp-5);
  cursor: pointer;
  transition: box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
}

.contact-card:hover {
  box-shadow: var(--sh-raise);
  transform: translateY(-2px);
  border-color: var(--divider);
}

.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--cta);
  color: var(--cta-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: var(--sp-3);
}

.contact-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 2px;
}

.contact-role {
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: var(--sp-3);
}

.contact-meta {
  font-size: 13px;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  word-break: break-all;
}

.contact-meta + .contact-meta { margin-top: 3px; }

/* ================================================================
   DETAIL PANELS
   ================================================================ */

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-7);
  margin-bottom: var(--sp-6);
}

.detail-hero-label {
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: var(--sp-1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.detail-hero {
  font-size: 44px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  font-family: var(--ff-display);
}

.detail-hero.money { font-size: 52px; }

.detail-actions {
  display: flex;
  gap: var(--sp-2);
  flex-shrink: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.detail-field-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-1);
}

.detail-field-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
}

.detail-notes {
  font-size: 14px;
  color: var(--text-1);
  line-height: 1.6;
  white-space: pre-wrap;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-bottom: var(--sp-4);
  transition: color var(--t-fast);
}

.back-link:hover { color: var(--text-1); }

.section-header {
  font-family: var(--ff-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  margin: var(--sp-6) 0 var(--sp-4);
}

.section-header:first-child { margin-top: 0; }

/* ================================================================
   EMPTY STATES
   ================================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-8) var(--sp-6);
  color: var(--text-2);
}

.empty-state-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-struct);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-4);
  color: var(--text-2);
}

.empty-state-icon svg { width: 20px; height: 20px; }

.empty-state-text {
  font-size: 14.5px;
  margin-bottom: var(--sp-5);
  line-height: 1.5;
}

/* ================================================================
   FORMS
   ================================================================ */

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

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

.form-field.span-2 { grid-column: 1 / -1; }

.form-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}

.form-field input,
.form-field select,
.form-field textarea {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  font-size: 14px;
  color: var(--text-1);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -webkit-appearance: none;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: var(--text-2);
  opacity: 0.7;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--cta);
  box-shadow: 0 0 0 3px rgba(43, 41, 36, .12);
}

[data-theme="dark"] .form-field input:focus,
[data-theme="dark"] .form-field select:focus,
[data-theme="dark"] .form-field textarea:focus {
  box-shadow: 0 0 0 3px rgba(242, 239, 233, .12);
}

.form-field textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  line-height: 1.5;
}

.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea {
  border-color: var(--danger);
}

.form-field.has-error input:focus,
.form-field.has-error select:focus,
.form-field.has-error textarea:focus {
  box-shadow: 0 0 0 3px rgba(201, 64, 64, .14);
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  display: none;
}

.form-field.has-error .form-error { display: block; }

.form-hint {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.4;
}

.autocomplete-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: 8px;
  box-shadow: var(--sh-raise);
  margin-top: 2px;
}

.autocomplete-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-1);
  cursor: pointer;
}

.autocomplete-item:hover { background: var(--bg-struct); }

.autocomplete-item.disabled {
  color: var(--text-2);
  cursor: default;
  font-style: italic;
}

.autocomplete-item.disabled:hover { background: transparent; }

/* ---- Chat bubbles (iMessages) ---- */
.chat-history {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 400px;
  overflow-y: auto;
  padding: 4px 0;
}

.chat-bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
}

.chat-sent {
  align-self: flex-end;
  background: var(--blue);
  color: var(--blue-fg);
  border-bottom-right-radius: 4px;
}

.chat-received {
  align-self: flex-start;
  background: var(--bg-struct);
  color: var(--text-1);
  border-bottom-left-radius: 4px;
}

.chat-time {
  font-size: 10px;
  color: var(--text-2);
  margin-top: 2px;
  opacity: .7;
}

.chat-sent .chat-time { text-align: right; }

.form-field-group {
  margin-bottom: var(--sp-5);
}

/* file attach widget */
.file-attached {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-struct);
  border: 1px solid var(--bg-struct-bd);
  border-radius: var(--r-sm);
  padding: 8px 10px;
}

.file-attached-name {
  flex: 1 1 auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-upload-spinner {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13px;
  color: var(--text-2);
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--divider);
  border-top-color: var(--cta);
  animation: spin 700ms linear infinite;
}

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

/* ================================================================
   MODAL
   ================================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.38);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-modal);
  width: 560px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: scale(0.97) translateY(8px);
  transition: opacity 160ms ease, transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.open .modal {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6) var(--sp-4);
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--ff-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  background: var(--bg-struct);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  font-size: 16px;
  line-height: 1;
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}

.modal-close:hover { background: var(--divider); color: var(--text-1); }

.modal-body {
  padding: var(--sp-6);
  overflow-y: auto;
  flex: 1 1 auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-6) var(--sp-5);
  border-top: 1px solid var(--divider);
  flex-shrink: 0;
}

/* Mark-as-paid popover */
.pay-popover {
  position: absolute;
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-md);
  box-shadow: var(--sh-modal);
  padding: var(--sp-4);
  width: 240px;
  z-index: 1100;
  opacity: 0;
  transform: scale(0.96) translateY(-4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
}

.pay-popover.open {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.pay-popover-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: var(--sp-3);
}

.pay-popover select {
  width: 100%;
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-xs);
  padding: 8px 10px;
  font-size: 13.5px;
  margin-bottom: var(--sp-3);
  color: var(--text-1);
  background: var(--bg-struct);
}

.pay-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
}

/* ================================================================
   SKELETON LOADERS
   ================================================================ */

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

.skeleton {
  border-radius: var(--r-xs);
  background: linear-gradient(
    90deg,
    var(--bg-struct)     25%,
    var(--divider)       50%,
    var(--bg-struct)     75%
  );
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}

.skeleton-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-md);
  box-shadow: var(--sh-card);
  padding: var(--sp-5);
}

.skeleton-line {
  height: 14px;
  margin-bottom: var(--sp-2);
  border-radius: var(--r-xs);
}

.skeleton-line:last-child { margin-bottom: 0; }

/* ================================================================
   TOAST
   ================================================================ */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 12px);
  background: var(--text-1);
  color: var(--bg-surface);
  font-size: 13.5px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: var(--r-md);
  box-shadow: var(--sh-raise);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
  z-index: 1200;
  max-width: calc(100vw - 48px);
  display: flex;
  align-items: center;
  gap: 4px;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.toast.toast-error { background: var(--danger); }

/* ================================================================
   PDF GENERATOR
   ================================================================ */

.generator-subtitle {
  font-size: 14px;
  color: var(--text-2);
  margin: -4px 0 var(--sp-6);
}

.generator-page {
  display: flex;
  gap: var(--sp-6);
  align-items: flex-start;
}

.generator-form {
  flex: 0 0 420px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.generator-preview-panel {
  flex: 1 1 auto;
  min-width: 0;
  position: sticky;
  top: 0;
}

.generator-preview-label {
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: var(--sp-4);
}

.generator-actions {
  display: flex;
  gap: var(--sp-2);
}

.generator-actions .btn { flex: 1 1 auto; }

/* Line items */
.li-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-2);
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  border-radius: var(--r-xs);
  transition: background var(--t-fast);
}
.li-row:hover { background: var(--bg-struct); }
.li-row-main { flex: 1 1 auto; min-width: 0; }
.li-row-title { font-size: 14px; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-row-placeholder { color: var(--text-2); font-weight: 400; font-style: italic; }
.li-row-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.li-row-amount { flex-shrink: 0; font-size: 14px; font-weight: 700; color: var(--text-1); font-variant-numeric: tabular-nums; }
.li-remove { flex-shrink: 0; width: 24px; height: 24px; border: none; background: none; color: var(--text-2); font-size: 18px; line-height: 1; cursor: pointer; border-radius: var(--r-xs); display: flex; align-items: center; justify-content: center; transition: color var(--t-fast), background var(--t-fast); }
.li-remove:hover { color: var(--danger); background: var(--danger-bg); }
.li-empty { padding: var(--sp-5) 0; text-align: center; font-size: 13px; color: var(--text-2); }
.li-modal-amount { border: 1px solid var(--bg-surface-bd); border-radius: var(--r-sm); padding: 9px 11px; font-size: 18px; font-weight: 700; color: var(--text-1); background: var(--bg-struct); font-variant-numeric: tabular-nums; }

.generator-totals {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--divider);
}

.generator-totals-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 13px;
  color: var(--text-2);
}

.generator-totals-row span:last-child {
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  font-weight: 600;
}

.generator-tax-row input {
  width: 70px;
  border: 1px solid var(--bg-surface-bd);
  border-radius: var(--r-xs);
  padding: 5px 8px;
  font-size: 13px;
  text-align: right;
  background: var(--bg-surface);
  color: var(--text-1);
}

.generator-total-row {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  border-top: 1px solid var(--divider);
  margin-top: 4px;
  padding-top: var(--sp-3);
}

.generator-total-row span:last-child { font-size: 18px; }

/* PDF preview mock */
.pdf-preview-page {
  background: #FFFFFF;
  box-shadow: 0 8px 32px rgba(0,0,0,.16);
  border-radius: 4px;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 210 / 297;
  margin: 0 auto;
  overflow: hidden;
  font-size: 11px;
  color: #2B2924;
  display: flex;
  flex-direction: column;
}

.pdf-preview-header {
  background: #2B2924;
  color: #FFFFFF;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.pdf-preview-brand { font-size: 15px; font-weight: 700; }
.pdf-preview-domain { font-size: 9px; color: #D6E5D2; margin-top: 3px; }
.pdf-preview-header-right { text-align: right; }
.pdf-preview-invoice-label { font-size: 17px; font-weight: 700; }
.pdf-preview-invoice-number { font-size: 9px; color: #D6E5D2; margin-top: 3px; }

.pdf-preview-info {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.pdf-preview-label { font-size: 7px; font-weight: 700; color: #7A766D; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.pdf-preview-client-name { font-size: 11px; font-weight: 700; margin-bottom: 2px; }
.pdf-preview-contact { font-size: 9px; margin-bottom: 1px; }
.pdf-preview-email { font-size: 9px; color: #7A766D; }
.pdf-preview-meta { text-align: right; font-size: 9px; line-height: 1.7; white-space: nowrap; }
.pdf-preview-mist { color: #7A766D; }
.pdf-preview-divider { height: 0; border-top: 1px solid #E8E4DD; margin: 0 16px; }

.pdf-preview-table { margin: 10px 16px 0; }
.pdf-preview-row { display: flex; align-items: center; gap: 6px; padding: 5px 6px; }
.pdf-preview-row-head { background: #F7F8FA; color: #5C7256; font-size: 8px; font-weight: 700; text-transform: uppercase; }
.pdf-preview-row.alt { background: #FBF9F6; }
.pdf-preview-row .col-desc { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-preview-row .col-qty { flex: 0 0 24px; text-align: right; }
.pdf-preview-row .col-price { flex: 0 0 46px; text-align: right; }
.pdf-preview-row .col-amount { flex: 0 0 46px; text-align: right; font-variant-numeric: tabular-nums; }

.pdf-preview-totals { margin: 10px 16px 0; }
.pdf-preview-totals-row { display: flex; justify-content: flex-end; gap: 10px; font-size: 9px; color: #7A766D; padding: 2px 6px; }
.pdf-preview-totals-row span:last-child { color: #2B2924; font-weight: 600; min-width: 50px; text-align: right; }
.pdf-preview-total-bar { display: flex; justify-content: space-between; background: #2B2924; color: #FFFFFF; font-weight: 700; font-size: 11px; padding: 6px 10px; margin-top: 4px; border-radius: 2px; }
.pdf-preview-notes { margin: 12px 16px 0; font-size: 9px; }
.pdf-preview-footer { margin-top: auto; text-align: center; font-size: 7px; color: #7A766D; padding: 10px 16px; }

/* ================================================================
   BACKWARD COMPAT ALIASES
   ================================================================ */

/* old class names still used by pdfgenerator.js / clients.js */
.text-overdue { color: var(--danger); }
.btn-generate {
  background: var(--cta);
  color: var(--cta-fg);
  border-color: var(--cta);
}
.btn-generate:hover { background: var(--cta-hover); border-color: var(--cta-hover); }

/* mb-3 used in some places */
.mb-3 { margin-bottom: var(--sp-5); }

/* ================================================================
   UTILITY
   ================================================================ */

.text-muted   { color: var(--text-2); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--sage-fg); }
.mt-0 { margin-top: 0; }
.mb-4 { margin-bottom: var(--sp-4); }
.hidden { display: none !important; }
.label {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-2);
}

/* ================================================================
   PLACEHOLDER / COMING SOON PAGES
   ================================================================ */

.coming-soon-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  text-align: center;
  color: var(--text-2);
}

.coming-soon-page h2 {
  font-family: var(--ff-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  margin: var(--sp-4) 0 var(--sp-3);
}

.coming-soon-page p {
  font-size: 15px;
  margin: 0;
  max-width: 320px;
  line-height: 1.6;
}

.coming-soon-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--r-xl);
  background: var(--bg-struct);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  margin: 0 auto;
}

.coming-soon-icon svg { width: 28px; height: 28px; }

/* ================================================================
   TOPBAR TABS (kept for backward compat but hidden when sidebar active)
   ================================================================ */

.topbar-tabs {
  display: flex;
  gap: 3px;
}

.tab-button {
  border: none;
  background: transparent;
  padding: 6px 13px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}

.tab-button:hover { color: var(--text-1); }

.tab-button.active {
  background: var(--bg-surface);
  color: var(--text-1);
  box-shadow: var(--sh-card);
}

/* ================================================================
   ANIMATIONS
   ================================================================ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 220ms ease forwards; }

/* ================================================================
   REDUCED MOTION
   ================================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .generator-page { flex-direction: column; }
  .generator-form { flex: 1 1 auto; width: 100%; }
  .generator-preview-panel { position: static; width: 100%; }
  .home-feature-grid { grid-template-columns: repeat(2, 140px); }
  .home-primary-card { width: 130px; }
  .home-feature-card { width: 120px; }
}

/* ════════════════════════════════════════════════════════════════════
   AUTH SCREENS — login, signup, PIN
   ════════════════════════════════════════════════════════════════════ */

.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 9000;
  opacity: 0;
  transition: opacity 300ms ease;
}
.auth-screen.visible { opacity: 1; }
.auth-screen.hidden { display: none; }

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 32px 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 32px;
}
.auth-logo .atws-icon { width: 40px; height: 40px; }
.auth-brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-1);
}

.auth-field {
  margin-bottom: 16px;
}
.auth-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.auth-field input {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border: 1.5px solid var(--text-2, #7A766D);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-1);
  outline: none;
  transition: border-color 150ms ease;
  box-sizing: border-box;
}
.auth-field input:focus {
  border-color: var(--cta);
}

.auth-error {
  font-size: 13px;
  color: var(--rose-fg, #d32f2f);
  min-height: 20px;
  margin-bottom: 4px;
}

.auth-submit {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  margin: 4px 0 12px;
  cursor: pointer;
}
.auth-remember input { cursor: pointer; }
.auth-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
  font-size: 13px;
}
.auth-links a {
  color: var(--cta);
  text-decoration: none;
}
.auth-links a:hover {
  text-decoration: underline;
}

.pin-biometric-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 16px auto 8px;
  padding: 12px 20px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.pin-biometric-btn:hover {
  border-color: var(--cta);
  background: var(--bg-struct);
}
.pin-biometric-btn .bio-icon {
  width: 32px;
  height: 32px;
  color: var(--text-2);
  transition: color 0.3s;
}
.pin-biometric-btn .bio-icon.bio-active {
  color: var(--cta);
  animation: bio-pulse 1s ease infinite;
}
.pin-biometric-btn .bio-label {
  font-size: 11px;
  color: var(--text-2);
  letter-spacing: 0.3px;
}
@keyframes bio-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* PIN screen */

.pin-card {
  max-width: 340px;
  text-align: center;
}
.pin-label {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-2);
  margin: 0 0 20px;
}

.pin-entry {
  margin-bottom: 12px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 4px;
}
.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--text-2);
  background: transparent;
  transition: background 150ms ease, border-color 150ms ease;
}
.pin-dot.filled {
  background: var(--cta);
  border-color: var(--cta);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}
.pin-pad button {
  width: 64px;
  height: 52px;
  font-size: 22px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-1);
  cursor: pointer;
  transition: background 100ms ease;
  -webkit-tap-highlight-color: transparent;
}
.pin-pad button:active {
  background: var(--bg-struct);
}
.pin-pad-empty {
  visibility: hidden;
}
.pin-pad-action {
  font-size: 18px !important;
  color: var(--text-2) !important;
}

/* Shake animation for wrong PIN */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.shake {
  animation: shake 400ms ease;
}

@media (max-width: 480px) {
  .auth-card { margin: 16px; padding: 28px 20px 24px; }
  .pin-pad { gap: 8px; }
  .pin-pad button { width: 56px; height: 46px; font-size: 20px; }
}

/* ================================================================
   Progress Bars (Revenue Goals)
   ================================================================ */

.progress-bar-outer {
  width: 100%;
  height: 20px;
  background: var(--bg-surface, #F5F2EC);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-color, #E4DED3);
}

.progress-bar-inner {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s ease;
  min-width: 2px;
}

/* ================================================================
   Client Health Badges
   ================================================================ */

.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.health-excellent {
  background: rgba(168, 188, 161, 0.2);
  color: #6B8C5E;
}

.health-good {
  background: rgba(169, 191, 209, 0.2);
  color: #5E7E8C;
}

.health-fair {
  background: rgba(217, 194, 140, 0.2);
  color: #8C7B4E;
}

.health-at-risk {
  background: rgba(184, 92, 92, 0.2);
  color: #B85C5C;
}

/* ================================================================
   QUICK ACTIONS BAR
   ================================================================ */

.quick-actions-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}

.quick-action-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-md);
  border: 1px solid var(--divider); background: var(--bg-surface);
  color: var(--text-1); font-family: var(--ff-body); font-size: 12.5px;
  font-weight: 600; cursor: pointer; transition: var(--t-fast);
}

.quick-action-btn:hover {
  background: var(--primary-bg); border-color: var(--primary);
  color: var(--primary-fg);
}

.qa-icon { font-size: 14px; }

/* ================================================================
   ACTIVITY FEED
   ================================================================ */

.widget-activity-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--divider-subtle);
  font-size: 12.5px;
}

.widget-activity-row:last-child { border-bottom: none; }

.activity-action {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}

.activity-insert { background: var(--green-bg); color: var(--green-fg); }
.activity-update { background: var(--blue-bg); color: var(--blue-fg); }
.activity-delete { background: var(--rose-bg); color: var(--rose-fg); }

.activity-table {
  flex: 1; color: var(--text-1); text-transform: capitalize;
}

.activity-time {
  color: var(--text-3); font-size: 11px;
}
