/* ============================================================
   TCC DIGITAL HUB — App Prototype Design System
   Brand: Deep Navy #1a2d4a + Emerald #0d7a5f + Warm White
   Fonts: Cabinet Grotesk (display) + Satoshi (body)
   ============================================================ */

@import url('https://api.fontshare.com/v2/css?f[]=cabinet-grotesk@400,500,700,800&f[]=satoshi@300,400,500,700&display=swap');

/* ─── DESIGN TOKENS ──────────────────────────────────────── */

:root, [data-theme="light"] {
  /* Type scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* TCC Brand — Light Mode */
  --color-bg:              #f2f5f8;
  --color-surface:         #ffffff;
  --color-surface-2:       #f8fafc;
  --color-surface-offset:  #edf2f7;
  --color-divider:         #e2e8f0;
  --color-border:          #cbd5e0;

  --color-text:            #0f1923;
  --color-text-muted:      #4a5568;
  --color-text-faint:      #a0aec0;
  --color-text-inverse:    #f4f7f9;

  /* Primary — Emerald */
  --color-primary:         #0d7a5f;
  --color-primary-hover:   #0a6350;
  --color-primary-active:  #074d3d;
  --color-primary-light:   #e6f4ef;
  --color-primary-muted:   rgba(13,122,95,0.12);

  /* Secondary — Deep Navy */
  --color-navy:            #1a2d4a;
  --color-navy-mid:        #243d5e;
  --color-navy-light:      #e8edf5;

  /* Accent — Blue */
  --color-accent:          #2563eb;
  --color-accent-light:    #dbeafe;

  /* Semantic */
  --color-success:         #059669;
  --color-success-light:   #d1fae5;
  --color-warning:         #d97706;
  --color-warning-light:   #fef3c7;
  --color-error:           #dc2626;
  --color-error-light:     #fee2e2;
  --color-info:            #0284c7;
  --color-info-light:      #e0f2fe;

  /* Radius */
  --radius-sm:   0.375rem;
  --radius-md:   0.5rem;
  --radius-lg:   0.75rem;
  --radius-xl:   1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(15,25,35,0.06), 0 1px 2px rgba(15,25,35,0.04);
  --shadow-md: 0 4px 12px rgba(15,25,35,0.08), 0 2px 4px rgba(15,25,35,0.04);
  --shadow-lg: 0 12px 32px rgba(15,25,35,0.12), 0 4px 8px rgba(15,25,35,0.06);

  /* Transitions */
  --transition: 160ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Fonts */
  --font-display: 'Cabinet Grotesk', 'Helvetica Neue', sans-serif;
  --font-body:    'Satoshi', 'Inter', sans-serif;

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --header-height: 56px;
}

[data-theme="dark"] {
  --color-bg:              #0c1420;
  --color-surface:         #111b2a;
  --color-surface-2:       #162032;
  --color-surface-offset:  #0f1825;
  --color-divider:         #1e2d42;
  --color-border:          #2a3d56;

  --color-text:            #e2e8f0;
  --color-text-muted:      #8096ae;
  --color-text-faint:      #455a72;
  --color-text-inverse:    #0f1923;

  --color-primary:         #34d399;
  --color-primary-hover:   #10b981;
  --color-primary-active:  #059669;
  --color-primary-light:   #0d2a1e;
  --color-primary-muted:   rgba(52,211,153,0.12);

  --color-navy:            #1e3a5f;
  --color-navy-mid:        #2a4a72;
  --color-navy-light:      #0f1e30;

  --color-accent:          #60a5fa;
  --color-accent-light:    #1e3a6e;

  --color-success:         #34d399;
  --color-success-light:   #0d2a1e;
  --color-warning:         #fbbf24;
  --color-warning-light:   #2d1f04;
  --color-error:           #f87171;
  --color-error-light:     #2d0a0a;
  --color-info:            #38bdf8;
  --color-info-light:      #0c2a3d;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:              #0c1420;
    --color-surface:         #111b2a;
    --color-surface-2:       #162032;
    --color-surface-offset:  #0f1825;
    --color-divider:         #1e2d42;
    --color-border:          #2a3d56;
    --color-text:            #e2e8f0;
    --color-text-muted:      #8096ae;
    --color-text-faint:      #455a72;
    --color-text-inverse:    #0f1923;
    --color-primary:         #34d399;
    --color-primary-hover:   #10b981;
    --color-primary-active:  #059669;
    --color-primary-light:   #0d2a1e;
    --color-primary-muted:   rgba(52,211,153,0.12);
    --color-navy:            #1e3a5f;
    --color-navy-mid:        #2a4a72;
    --color-navy-light:      #0f1e30;
    --color-accent:          #60a5fa;
    --color-accent-light:    #1e3a6e;
    --color-success:         #34d399;
    --color-success-light:   #0d2a1e;
    --color-warning:         #fbbf24;
    --color-warning-light:   #2d1f04;
    --color-error:           #f87171;
    --color-error-light:     #2d0a0a;
    --color-info:            #38bdf8;
    --color-info-light:      #0c2a3d;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.45);
  }
}

/* ─── BASE RESET ─────────────────────────────────────────── */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-bg);
  overflow: hidden;
  line-height: 1.5;
}

img, svg { display: block; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
input, textarea, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Tabular numbers for data values */
.num { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum"; }

/* ─── APP SHELL ──────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 1fr;
  height: 100dvh;
  transition: grid-template-columns var(--transition);
}

.app.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed) 1fr;
}

/* ─── SIDEBAR ────────────────────────────────────────────── */

.sidebar {
  grid-row: 1 / -1;
  background: var(--color-navy);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,0.06);
  position: relative;
  z-index: 20;
  transition: width var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--header-height);
  overflow: hidden;
}

.sidebar-logo svg { flex-shrink: 0; }

.logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
}

.logo-text strong {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.logo-text span {
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: var(--space-4) var(--space-3) var(--space-2);
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.55);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.85);
}

.nav-item.active {
  background: rgba(13,122,95,0.25);
  color: #ffffff;
}

[data-theme="dark"] .nav-item.active {
  background: rgba(52,211,153,0.18);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  bottom: 25%;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}

.nav-item svg { flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--color-error);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

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

.sidebar-bottom {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}

.user-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
  overflow: hidden;
}

.user-card:hover { background: rgba(255,255,255,0.07); }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info {
  overflow: hidden;
  white-space: nowrap;
}

.user-info strong {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info span {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
}

/* ─── MAIN AREA ──────────────────────────────────────────── */

.main-area {
  display: grid;
  grid-template-rows: var(--header-height) 1fr;
  overflow: hidden;
  min-width: 0;
}

/* ─── HEADER ─────────────────────────────────────────────── */

.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.header-breadcrumb .page-title {
  color: var(--color-text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
}

.header-breadcrumb .sep { color: var(--color-text-faint); }

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

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.icon-btn:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

.notif-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-error);
  border: 2px solid var(--color-surface);
}

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--color-divider);
}

/* ─── CONTENT AREA ───────────────────────────────────────── */

.content-area {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  background: var(--color-bg);
}

.screen {
  display: none;
  padding: var(--space-6);
  max-width: 1400px;
  animation: fadeIn 180ms ease;
}

.screen.active {
  display: block;
}

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

/* ─── SHARED COMPONENTS ──────────────────────────────────── */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
}

.section-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card--flat {
  box-shadow: none;
  border: 1px solid var(--color-divider);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge--success   { background: var(--color-success-light); color: var(--color-success); }
.badge--warning   { background: var(--color-warning-light); color: var(--color-warning); }
.badge--error     { background: var(--color-error-light);   color: var(--color-error); }
.badge--info      { background: var(--color-info-light);    color: var(--color-info); }
.badge--navy      { background: var(--color-navy-light);    color: var(--color-navy); }
.badge--muted     { background: var(--color-surface-offset); color: var(--color-text-muted); }
.badge--primary   { background: var(--color-primary-light); color: var(--color-primary); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background var(--transition), box-shadow var(--transition), transform 80ms;
  cursor: pointer;
  border: none;
}

.btn:active { transform: scale(0.98); }

.btn--primary {
  background: var(--color-primary);
  color: white;
}
.btn--primary:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 2px 8px rgba(13,122,95,0.3);
}

.btn--secondary {
  background: var(--color-surface-offset);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn--secondary:hover {
  background: var(--color-divider);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-3);
}
.btn--ghost:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

.btn--sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

/* ─── SCREEN 1 — OVERVIEW DASHBOARD ─────────────────────── */

.overview-greeting {
  margin-bottom: var(--space-6);
}

.overview-greeting h1 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.2;
  margin-bottom: var(--space-1);
}

.overview-greeting h1 span { color: var(--color-primary); }

.overview-greeting p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.kpi-card.k-green::after  { background: var(--color-success); }
.kpi-card.k-warn::after   { background: var(--color-warning); }
.kpi-card.k-error::after  { background: var(--color-error); }
.kpi-card.k-blue::after   { background: var(--color-accent); }

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
}

.kpi-icon.k-green { background: var(--color-success-light); color: var(--color-success); }
.kpi-icon.k-warn  { background: var(--color-warning-light); color: var(--color-warning); }
.kpi-icon.k-error { background: var(--color-error-light);   color: var(--color-error); }
.kpi-icon.k-blue  { background: var(--color-accent-light);  color: var(--color-accent); }

.kpi-value {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2vw, 2rem);
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.kpi-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  margin-top: var(--space-2);
}
.kpi-delta.up   { color: var(--color-success); }
.kpi-delta.down { color: var(--color-error); }
.kpi-delta.flat { color: var(--color-text-faint); }

/* Dashboard body layout */
.dash-body {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--space-5);
}

/* Compliance Health Ring */
.health-ring-card {
  text-align: center;
  padding: var(--space-6);
}

.ring-container {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto var(--space-4);
}

.ring-container svg {
  width: 160px;
  height: 160px;
  transform: rotate(-90deg);
}

.ring-bg { fill: none; stroke: var(--color-divider); stroke-width: 10; }
.ring-fill {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 440;
  stroke-dashoffset: 66; /* ~85% */
  transition: stroke-dashoffset 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.ring-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.ring-pct {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
}

.ring-sub {
  font-size: 10px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.health-breakdown {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.health-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.health-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--color-divider);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.health-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.health-item-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  min-width: 60px;
  text-align: right;
}

/* Upcoming deadlines */
.deadline-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.deadline-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition);
}

.deadline-item:hover { border-color: var(--color-primary); }

.deadline-date {
  text-align: center;
  min-width: 40px;
}

.deadline-date .day {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
}

.deadline-date .mon {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-faint);
}

.deadline-info { flex: 1; }

.deadline-info strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.deadline-info span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Activity Feed */
.activity-feed {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-divider);
  position: relative;
}

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

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-dot.green  { background: var(--color-success); }
.activity-dot.yellow { background: var(--color-warning); }
.activity-dot.red    { background: var(--color-error); }
.activity-dot.blue   { background: var(--color-accent); }
.activity-dot.gray   { background: var(--color-text-faint); }

.activity-content { flex: 1; }

.activity-content strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.activity-content span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.activity-time {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  white-space: nowrap;
}

/* Alert Banner */
.alert-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--color-warning-light);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  color: var(--color-warning);
}

.alert-banner svg { flex-shrink: 0; }
.alert-banner p { font-size: var(--text-sm); font-weight: 500; flex: 1; }

/* ─── SCREEN 2 — COMPLIANCE CALENDAR ────────────────────── */

.cal-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-5);
}

.cal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.cal-month {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text);
}

.cal-nav { display: flex; gap: var(--space-2); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day-label {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  padding: var(--space-2) 0;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: var(--space-1) var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  min-height: 56px;
}

.cal-day:hover { background: var(--color-surface-offset); }

.cal-day.today {
  background: var(--color-primary-muted);
  color: var(--color-primary);
  font-weight: 700;
}

.cal-day.has-event { color: var(--color-text); }

.cal-day .day-num {
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.cal-dots {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
}

.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.cal-dot.red    { background: var(--color-error); }
.cal-dot.orange { background: var(--color-warning); }
.cal-dot.green  { background: var(--color-success); }
.cal-dot.blue   { background: var(--color-accent); }

.cal-day.other-month { opacity: 0.3; pointer-events: none; }

/* Upcoming panel */
.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.upcoming-item {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.upcoming-pill {
  width: 4px;
  border-radius: var(--radius-full);
  align-self: stretch;
  flex-shrink: 0;
}

.upcoming-pill.red    { background: var(--color-error); }
.upcoming-pill.orange { background: var(--color-warning); }
.upcoming-pill.green  { background: var(--color-success); }
.upcoming-pill.blue   { background: var(--color-accent); }

.upcoming-body strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.upcoming-body span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.upcoming-body .due-date {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 11px;
  font-weight: 600;
  margin-top: var(--space-1);
}

.due-date.urgent { color: var(--color-error); }
.due-date.soon   { color: var(--color-warning); }
.due-date.ok     { color: var(--color-success); }

/* ─── SCREEN 3 — DOCUMENT VAULT ─────────────────────────── */

.vault-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.search-field {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-2) var(--space-4);
  color: var(--color-text-muted);
  transition: border-color var(--transition);
}

.search-field:focus-within {
  border-color: var(--color-primary);
  color: var(--color-text);
}

.search-field input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.search-field input::placeholder { color: var(--color-text-faint); }

.filter-chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.chip {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.chip.active {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.vault-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-5);
}

.vault-tree {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.tree-folder {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-weight: 500;
}

.tree-folder:hover { background: var(--color-surface-offset); color: var(--color-text); }
.tree-folder.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.tree-folder svg { flex-shrink: 0; }

.tree-count {
  margin-left: auto;
  font-size: 11px;
  background: var(--color-surface-offset);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: var(--space-4);
}

.upload-zone:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-muted);
}

.upload-zone svg {
  margin: 0 auto var(--space-3);
  color: var(--color-text-faint);
}

.upload-zone p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}

.upload-zone span {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* File table */
.file-table {
  width: 100%;
  border-collapse: collapse;
}

.file-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface-2);
  position: sticky;
  top: 0;
}

.file-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-sm);
  color: var(--color-text);
  vertical-align: middle;
}

.file-table tr:hover td { background: var(--color-surface-offset); }

.file-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

.file-icon.pdf  { background: #fee2e2; color: #dc2626; }
.file-icon.xlsx { background: #d1fae5; color: #059669; }
.file-icon.docx { background: #dbeafe; color: #2563eb; }
.file-icon.zip  { background: #fef3c7; color: #d97706; }

.file-name-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ─── SCREEN 4 — NOTICES CENTER ─────────────────────────── */

.notices-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.notice-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.notice-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notice-stat-val {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
}

.notice-stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.notices-filters {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  align-items: center;
}

.notices-table {
  width: 100%;
  border-collapse: collapse;
}

.notices-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid var(--color-divider);
  background: var(--color-surface);
  position: sticky;
  top: 0;
}

.notices-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-sm);
  vertical-align: middle;
}

.notices-table tr:hover td { background: var(--color-surface-offset); }

.notice-row-title {
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.notice-row-ref {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.priority-dot.high   { background: var(--color-error); }
.priority-dot.medium { background: var(--color-warning); }
.priority-dot.low    { background: var(--color-success); }

.row-actions {
  display: flex;
  gap: var(--space-2);
  opacity: 0;
  transition: opacity var(--transition);
}

.notices-table tr:hover .row-actions { opacity: 1; }

/* ─── SCREEN 5 — CHAT / HELP PANEL ──────────────────────── */

.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-5);
  height: calc(100dvh - var(--header-height) - var(--space-12));
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow: hidden;
}

.chat-sidebar-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.chat-threads {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.thread-item {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
}

.thread-item:hover { background: var(--color-surface-offset); }
.thread-item.active {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.thread-item strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.thread-item span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.thread-item .thread-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

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

/* Chat window */
.chat-window {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-window-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.agent-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), var(--color-navy));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.agent-info strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.agent-info span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 0 2px var(--color-surface);
  margin-left: auto;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.msg-group {
  display: flex;
  gap: var(--space-3);
  max-width: 80%;
}

.msg-group.user {
  flex-direction: row-reverse;
  margin-left: auto;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
}

.msg-avatar.agent { background: linear-gradient(135deg, var(--color-primary), var(--color-navy)); }
.msg-avatar.user  { background: linear-gradient(135deg, var(--color-accent), #7c3aed); }

.msg-bubble {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-text);
}

.msg-group.user .msg-bubble {
  background: var(--color-primary);
  color: white;
  border-color: transparent;
}

.msg-time {
  font-size: 10px;
  color: var(--color-text-faint);
  margin-top: var(--space-1);
  padding: 0 var(--space-2);
}

.msg-group.user .msg-time { text-align: right; }

.quick-actions {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-divider);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.quick-chip {
  padding: var(--space-1) var(--space-3);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.quick-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.chat-input-row {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-divider);
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  resize: none;
  color: var(--color-text);
  min-height: 44px;
  max-height: 120px;
  transition: border-color var(--transition);
  outline: none;
}

.chat-input:focus { border-color: var(--color-primary); }
.chat-input::placeholder { color: var(--color-text-faint); }

.chat-send {
  width: 40px;
  height: 40px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: background var(--transition), transform 80ms;
  flex-shrink: 0;
  border: none;
}

.chat-send:hover { background: var(--color-primary-hover); }
.chat-send:active { transform: scale(0.95); }

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: var(--space-2);
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-faint);
  animation: bounce 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* ─── HELP ARTICLES sidebar for chat ────────────────────── */
.faq-item {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-divider);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color var(--transition);
  margin-bottom: var(--space-2);
}

.faq-item:hover { border-color: var(--color-primary); }

.faq-item strong {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.faq-item span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .app.mobile-open {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    z-index: 100;
    transition: transform var(--transition);
  }

  .app.mobile-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
  }

  .app.mobile-open .mobile-overlay { display: block; }

  .kpi-grid         { grid-template-columns: repeat(2, 1fr); }
  .dash-body        { grid-template-columns: 1fr; }
  .cal-layout       { grid-template-columns: 1fr; }
  .vault-layout     { grid-template-columns: 1fr; }
  .chat-layout      { grid-template-columns: 1fr; height: auto; }
  .chat-sidebar     { display: none; }
  .notices-summary  { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .kpi-grid         { grid-template-columns: 1fr 1fr; }
  .screen           { padding: var(--space-4); }
  .notices-summary  { grid-template-columns: 1fr 1fr; }
}

/* ─── SCROLLBARS ─────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--color-text-faint); }

/* ─── PROGRESS MINI ──────────────────────────────────────── */

.progress-bar {
  height: 6px;
  background: var(--color-divider);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-2);
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transition: width 0.6s ease;
}

/* Tag pill */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}


/* ============================================================
   PHASE 2 PORTAL UPGRADE
   ============================================================ */
.comparison-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.comparison-card,
.report-summary-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.comparison-label,
.report-summary-card span {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.comparison-card strong,
.report-summary-card strong {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: 1;
}

.reports-shell,
.settings-shell {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.reports-header,
.report-grid,
.settings-grid {
  display: grid;
  gap: var(--space-5);
}

.reports-header {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.reports-actions,
.report-periods {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-4);
}

.report-summary-accent {
  background: linear-gradient(135deg, var(--color-navy) 0%, var(--color-navy-mid) 100%);
  border-color: transparent;
  color: white;
}

.report-summary-accent span,
.report-summary-accent small { color: rgba(255,255,255,0.76); }

.report-grid {
  grid-template-columns: 1.2fr 0.9fr;
}

.metric-rows {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.metric-row-item,
.setting-row,
.premium-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-divider);
}

.metric-row-item:last-child,
.setting-row:last-child,
.premium-line:last-child { border-bottom: none; }

.metric-row-item span,
.setting-row span,
.settings-list-item span {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  display: block;
  margin-top: 0.2rem;
}

.metric-row-value {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
}

.report-chart-card { min-height: 100%; }

.report-bars {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-4) 0;
}

.report-bar-row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: var(--space-3);
  align-items: center;
}

.report-bar-label,
.report-bar-value,
.report-advisory {
  font-size: var(--text-xs);
}

.report-bar-track {
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--color-surface-offset);
  overflow: hidden;
}

.report-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-accent) 100%);
}

.report-advisory {
  color: var(--color-text-muted);
  line-height: 1.7;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
}

.comparison-table th,
.comparison-table td {
  text-align: left;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-xs);
}

.comparison-table th {
  color: var(--color-text-muted);
  font-weight: 700;
}

.settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.settings-card,
.premium-card {
  min-height: 100%;
}

.settings-list {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-3);
}

.settings-list-item {
  padding: var(--space-4);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
}

.premium-card {
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-primary) 10%, var(--color-surface)) 0%, var(--color-surface) 100%);
}

@media (max-width: 1100px) {
  .report-grid,
  .reports-header {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .report-bar-row {
    grid-template-columns: 72px 1fr auto;
  }

  .metric-row-item,
  .setting-row,
  .premium-line {
    align-items: flex-start;
    flex-direction: column;
  }
}
