/* ============================================================
   Muñoz Law, P.C. — Legal Suite
   Dark theme — Black / Gold / White
   ============================================================ */

:root {
  /* Surfaces */
  --bg:          #000000;
  --surface:     #0E0E0E;
  --surface-2:   #161616;
  --surface-3:   #1F1F1F;
  --border:      #2A2A2A;
  --border-2:    #3A3A3A;

  /* Gold palette */
  --gold:        #C9A84C;
  --gold-light:  #E8D08A;
  --gold-soft:   rgba(201,168,76,0.12);
  --gold-soft-2: rgba(201,168,76,0.22);
  --gold-line:   rgba(201,168,76,0.35);

  /* Legacy semantic names (remapped to the dark palette so
     existing rules "just work" without changing every selector) */
  --navy:        #C9A84C;       /* was primary accent — now gold */
  --navy-dark:   #B8943D;
  --navy-light:  #E8D08A;
  --navy-fade:   rgba(201,168,76,0.1);
  --gold-dim:    rgba(201,168,76,0.18);

  --white:       #FFFFFF;
  --offwhite:    #0E0E0E;       /* repurposed as a dark offset surface */

  --gray-light:  #1F1F1F;
  --gray:        #2A2A2A;
  --gray-med:    #555555;
  --gray-dark:   #B8B8B8;

  --text:        #F5DC7A;
  --text-light:  #FAE99A;
  --text-dim:    #D4A83A;

  --success:     #4ECB82;
  --warning:     #E8D08A;
  --danger:      #E06A5E;

  --shadow-sm:   0 1px 4px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.55);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.7);
  --shadow-gold: 0 0 0 1px rgba(201,168,76,0.25), 0 8px 28px rgba(201,168,76,0.12);

  --radius:      10px;
  --radius-lg:   16px;
  --transition:  all 0.2s ease;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-light); }

::selection { background: var(--gold); color: #000; }

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  /* Solid black top bar — clean and uncluttered behind the logo */
  background: #000000;
  /* Padding only on top — leave horizontal flush so .nav-tabs extends
     edge-to-edge of the viewport. Logo row gets its own padding below. */
  padding: 1.25rem 0 0;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--gold-line);
  box-shadow: var(--shadow-lg);
  overflow: visible;
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 1.5rem;
  padding: 0 2rem;
}

/* Left column: brand + active section + sub-tabs */
.header-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.55rem;
  min-width: 180px;
}

.header-brand {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #B8892D;
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 25%, #E8C968 50%, #B8892D 75%, #8A6A1C 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.header-active-section {
  padding: 0 0 0.25rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border-bottom: 1px solid #B8892D;
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 25%, #E8C968 50%, #B8892D 75%, #8A6A1C 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-align: left;
  align-self: flex-start;
}

.logo-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  text-decoration: none;
  overflow: visible;
  /* The logo image is transformed up by 55px but its layout box still
     occupies the full 178px slot, which overhangs into the nav-tabs and
     tab-panel area below — capturing clicks meant for the tabs. Disable
     pointer events on the wrapper so only the visible logo image itself
     is clickable. */
  pointer-events: none;
}

.logo-img {
  height: 72px;
  width: auto;
  object-fit: contain;
  display: block;
  pointer-events: auto;
}

/* ── Top-right hamburger button ── */
.hamburger-btn {
  justify-self: end;
  align-self: flex-start;
  margin-top: 0.25rem;
  width: 44px;
  height: 44px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  /* Solid dark fill so the button stays readable wherever it sits on
     the gradient (lighter edges, dark middle). */
  background: #000000;
  border: 1px solid #B8892D;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.hamburger-btn:hover {
  border-color: #E8C968;
  background: #1A1A1A;
  box-shadow: 0 4px 14px rgba(184, 137, 45, 0.35);
}
.hamburger-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.hamburger-bar {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 25%, #E8C968 50%, #B8892D 75%, #8A6A1C 100%);
  transition: transform 0.25s ease, opacity 0.2s ease;
  transform-origin: center;
}
.hamburger-btn.open .hamburger-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.open .hamburger-bar:nth-child(2) {
  opacity: 0;
}
.hamburger-btn.open .hamburger-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Section drawer (slide-in from right) ── */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 198;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.drawer-backdrop:not([hidden]) {
  opacity: 1;
}

.section-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(320px, 88vw);
  background: #000;
  border-left: 1px solid var(--gold-line);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
  z-index: 199;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.22, 0.9, 0.32, 1);
}
.section-drawer:not([hidden]) {
  transform: translateX(0);
}

.section-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--gold-line);
}
.section-drawer-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 25%, #E8C968 50%, #B8892D 75%, #8A6A1C 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.section-drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-2);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}
.section-drawer-close:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold-light);
}

.section-drawer-nav {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0;
  gap: 0.15rem;
}

/* Drawer items reuse the gold-gradient text from .section-nav-link */
.section-drawer-nav .section-nav-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.85rem 1.5rem;
  border: none;
  border-left: 3px solid transparent;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 25%, #E8C968 50%, #B8892D 75%, #8A6A1C 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.section-drawer-nav .section-nav-link:hover {
  filter: brightness(1.25);
  background-color: var(--gold-soft);
  border-left-color: var(--gold-line);
}
.section-drawer-nav .section-nav-link.active {
  display: block;
  background-color: var(--gold-soft-2);
  border-left-color: var(--gold);
}

/* Hide the hamburger on the home view (header itself is hidden there) */
body.section-home .hamburger-btn { display: none; }

/* ── Employment sub-tabs: horizontal tab bar below header ── */
.nav-tabs {
  display: none;
  width: 100%;
  /* Pronounced gold rule between gradient logo strip and cream tab bar */
  border-top: 1px solid #B8892D;
  border-bottom: 1px solid rgba(184,137,45,0.25);
  /* Cream tab bar — sits beneath the gradient logo strip */
  background: #FAF7EE;
  margin-top: 0;
}
body.section-employment #employment-tabs { display: block; }
body.section-immigration #immigration-tabs { display: block; }

.nav-tabs-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  gap: 2rem;
  padding: 0.85rem 2rem;
  align-items: center;
  justify-content: flex-start;
  overflow-x: auto;
}

.nav-tab {
  flex: 0 0 auto;
  padding: 0.35rem 0 0.3rem;
  border: none;
  background: transparent;
  color: #1B2B5E;                    /* firm navy on cream */
  -webkit-text-fill-color: #1B2B5E;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;               /* overlap the .nav-tabs bottom border */
}

.nav-tab:hover {
  color: #8A6A1C;                    /* deep gold on hover */
  -webkit-text-fill-color: #8A6A1C;
}

.nav-tab.active {
  color: #8A6A1C;                    /* active = deep gold */
  -webkit-text-fill-color: #8A6A1C;
  border-bottom-color: #8A6A1C;
}

/* Legacy back button (no longer rendered) */
.back-btn {
  display: none;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--gold-line);
  background: transparent;
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: var(--transition);
  margin-left: auto;
}

.back-btn:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
}

body:not(.section-home) .back-btn { display: inline-block; }

/* When Employment tabs are visible, keep back-btn at far right */
body.section-employment .back-btn { margin-left: 0; }

/* ── Main layout ─────────────────────────────────────────── */
.app-main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 2.25rem 2rem;
}

.view { display: none; }
.view.active { display: block; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Home hero ──────────────────────────────────────────── */
/* Hide the header entirely on the home page for a clean, all-black canvas */
body.section-home .app-header { display: none; }

.home-hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6rem 1rem 2rem;
  background: #000;
  position: relative;
}

.home-brand {
  position: absolute;
  top: 1.5rem;
  left: 2rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #B8892D;
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 25%, #E8C968 50%, #B8892D 75%, #8A6A1C 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
}

.home-logo {
  width: 380px;
  max-width: 55vw;
  height: auto;
  margin-top: 2rem;
  margin-bottom: 2rem;
  pointer-events: none;
}

.home-links {
  position: relative;
  z-index: 2;
}

.home-link {
  position: relative;
  z-index: 2;
}


.home-links {
  display: flex;
  flex-direction: row;
  gap: 2rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.home-link {
  border: none;
  padding: 0.15rem 0.25rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 25%, #E8C968 50%, #B8892D 75%, #8A6A1C 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
}

.home-link:hover {
  filter: brightness(1.25);
}

/* ── Records Chat title override ── */
#tab-chat .page-title,
#imm-tab-chat .page-title {
  font-size: 1.15rem;
}

/* ── Collapsible Template Manager inside Document Generator ── */
.template-manager-collapse {
  margin-top: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.template-manager-collapse > summary {
  cursor: pointer;
  padding: 1rem 1.25rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--gold);
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.template-manager-collapse > summary::-webkit-details-marker { display: none; }

.template-manager-collapse > summary::after {
  content: "▾";
  margin-left: auto;
  font-size: 0.9rem;
  transition: transform 0.2s ease;
}

.template-manager-collapse[open] > summary::after { transform: rotate(180deg); }

.template-manager-collapse > summary:hover { filter: brightness(1.15); }

.template-manager-body {
  padding: 1rem 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Placeholder views (Immigration, Referrals) ──────────── */
.placeholder-view {
  max-width: 640px;
  margin: 5rem auto;
  text-align: center;
  padding: 3rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.placeholder-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 2.1rem;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
}

.placeholder-text {
  color: var(--text-light);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.placeholder-hint {
  color: var(--text-dim);
  font-size: 0.82rem;
  font-style: italic;
}

/* ── Page header inside sections ─────────────────────────── */
.page-header {
  margin-bottom: 1.75rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.page-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.85rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
}

.page-subtitle {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover { border-color: var(--border-2); }

.card-header {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #0B0B0B;
}

.card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card-body { padding: 1.25rem; }

/* ── Grid & flex ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }
.flex-row { display: flex; gap: 1rem; align-items: flex-start; }
.flex-col { display: flex; flex-direction: column; gap: 1rem; }

/* ── Drop zone ───────────────────────────────────────────── */
.drop-zone {
  border: 4px dashed rgba(201,168,76,0.45);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #000;
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: #E8C968;
  background: rgba(201,168,76,0.04);
  box-shadow: 0 0 40px rgba(232,201,104,0.55), 0 0 80px rgba(232,201,104,0.2), inset 0 0 60px rgba(232,201,104,0.45), inset 0 0 120px rgba(232,201,104,0.25);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dz-logo-img {
  width: 178px;
  height: 178px;
  object-fit: contain;
  display: block;
  margin: 0 auto 1rem;
  pointer-events: none;
  opacity: 0.82;
  transition: opacity 0.3s, filter 0.3s;
}
.drop-zone:hover .dz-logo-img,
.drop-zone.drag-over .dz-logo-img {
  opacity: 1;
  filter: drop-shadow(0 0 14px rgba(201,168,76,0.7));
}

.drop-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.drop-hint {
  font-size: 0.62rem;
  color: var(--text-dim);
}

.drop-formats {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.format-chip {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Processing / spinner ────────────────────────────────── */
.processing-overlay {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem;
  text-align: center;
}

.processing-overlay.visible { display: flex; }

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.processing-text {
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 500;
}

/* ── Suggestions ─────────────────────────────────────────── */
.suggestion-list { display: flex; flex-direction: column; gap: 0.6rem; }

.suggestion-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.suggestion-card:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
  transform: translateX(3px);
}

.suggestion-card.top-match {
  border-color: var(--gold);
  background: linear-gradient(90deg, rgba(201,168,76,0.1) 0%, var(--surface-2) 70%);
}

.suggestion-card.top-match::before {
  content: "BEST MATCH";
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #000;
  background: var(--gold);
  border-radius: 3px;
  padding: 0.12rem 0.45rem;
}

.suggestion-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  width: 2.5rem;
  text-align: center;
}

.suggestion-info { flex: 1; min-width: 0; }

.suggestion-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-category {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.suggestion-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.4rem;
}

.kw-chip {
  background: var(--surface-3);
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  font-size: 0.65rem;
  font-weight: 500;
}

.confidence-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.confidence-badge.High   { background: rgba(78,203,130,0.15); color: var(--success); border: 1px solid rgba(78,203,130,0.3); }
.confidence-badge.Medium { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-line); }
.confidence-badge.Low    { background: var(--surface-3); color: var(--text-dim); border: 1px solid var(--border); }

/* ── Facts grid ──────────────────────────────────────────── */
.facts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.fact-item {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
}

.fact-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 0.25rem;
}

.fact-value {
  font-size: 0.82rem;
  color: var(--white);
  font-weight: 400;
  word-break: break-word;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  border: none;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary {
  background: var(--gold);
  color: #000;
}
.btn-primary:hover {
  background: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold) 0%, #B8943D 100%);
  color: #000;
}
.btn-gold:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-outline {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-line);
}
.btn-outline:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--white); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(224,106,94,0.4);
}
.btn-danger:hover { background: rgba(224,106,94,0.1); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.7rem; border-radius: 6px; }
.btn-lg { padding: 0.8rem 1.8rem; font-size: 0.85rem; border-radius: var(--radius-lg); }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: saturate(0.5);
}

/* ── Editor ──────────────────────────────────────────────── */
.editor-toolbar {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar-btn {
  padding: 0.3rem 0.5rem;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-light);
  transition: var(--transition);
  font-family: inherit;
}

.toolbar-btn:hover { background: var(--surface-3); color: var(--gold); }
.toolbar-btn.active { background: var(--gold-soft); color: var(--gold); }

.toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 0.2rem;
}

.editor-body {
  min-height: 420px;
  max-height: 620px;
  overflow-y: auto;
  padding: 1.5rem;
  font-size: 0.92rem;
  line-height: 1.8;
  color: var(--text-light);
  outline: none;
  white-space: pre-wrap;
  font-family: 'Cormorant Garamond', 'Georgia', 'Times New Roman', serif;
  background: var(--surface);
}

.editor-body:focus { outline: none; }

.editor-body:empty::before {
  content: attr(data-placeholder);
  color: var(--text-dim);
  font-style: italic;
}

.editor-body .var-highlight {
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  border-radius: 3px;
  padding: 0 3px;
  font-family: monospace;
  font-size: 0.85em;
  color: var(--gold);
}

/* ── Template manager ────────────────────────────────────── */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.template-card:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
  transform: translateY(-2px);
}

.template-card-header {
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: #0B0B0B;
}

.template-icon { font-size: 1.5rem; flex-shrink: 0; }

.template-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.template-card-cat {
  font-size: 0.66rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.template-card-body {
  padding: 0.85rem 1.1rem;
  flex: 1;
}

.template-preview-text {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.template-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.75rem;
}

.var-chip {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  font-size: 0.65rem;
  font-family: monospace;
  color: var(--gold);
}

.template-card-footer {
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  background: #0B0B0B;
}

/* Category filter pills */
.filter-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-pill {
  padding: 0.35rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: inherit;
}

.filter-pill:hover { border-color: var(--gold); color: var(--gold); }
.filter-pill.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #000;
}

/* ── Forms / inputs ──────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--white);
  background: var(--surface-2);
  transition: var(--transition);
  font-family: inherit;
  outline: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-dim);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
  background: var(--surface-3);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-select option {
  background: var(--surface-2);
  color: var(--white);
}

/* ── Status banners ──────────────────────────────────────── */
.status-banner {
  display: none;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.83rem;
  margin-bottom: 1rem;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.status-banner.visible { display: flex; }
.status-banner.success { background: rgba(78,203,130,0.1); color: var(--success); border: 1px solid rgba(78,203,130,0.3); }
.status-banner.error   { background: rgba(224,106,94,0.1); color: var(--danger); border: 1px solid rgba(224,106,94,0.3); }
.status-banner.info    { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-line); }

/* ── Var fill grid ───────────────────────────────────────── */
.var-fill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* ── Export buttons ──────────────────────────────────────── */
.export-options {
  display: flex;
  gap: 0.75rem;
}

.export-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  color: var(--text-light);
}

.export-btn:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.export-btn .export-icon { font-size: 1.6rem; }
.export-btn .export-label { font-size: 0.76rem; font-weight: 700; color: var(--gold); letter-spacing: 0.08em; text-transform: uppercase; }
.export-btn .export-desc { font-size: 0.68rem; color: var(--text-dim); }

/* ── Section divider ─────────────────────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-divider-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ── Extracted text preview ──────────────────────────────── */
.text-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.78rem;
  color: var(--text-light);
  line-height: 1.7;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: 'Courier New', monospace;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.modal {
  background: var(--surface);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-gold);
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from { transform: translateY(-12px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.modal-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0B0B0B;
}

.modal-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
}

.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-2);
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}

.modal-close:hover { background: var(--gold); color: #000; border-color: var(--gold); }

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  background: #0B0B0B;
}

/* ── Utilities ───────────────────────────────────────────── */
.text-navy  { color: var(--gold); }
.text-gold  { color: var(--gold); }
.text-muted { color: var(--text-dim); }
.text-sm    { font-size: 0.8rem; }
.text-xs    { font-size: 0.72rem; }
.fw-700     { font-weight: 700; }
.mt-1       { margin-top: 0.5rem; }
.mt-2       { margin-top: 1rem; }
.mt-3       { margin-top: 1.5rem; }
.mb-1       { margin-bottom: 0.5rem; }
.mb-2       { margin-bottom: 1rem; }
.gap-1      { gap: 0.5rem; }
.hidden     { display: none !important; }
.full-w     { width: 100%; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-line); }

/* ── Empty states ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-dim);
}

.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.6; }
.empty-state-text { font-size: 0.88rem; font-weight: 500; color: var(--text-light); }
.empty-state-hint { font-size: 0.76rem; margin-top: 0.3rem; color: var(--text-dim); }

/* ── Global gold-gradient applied to labels, titles, hints ── */
.page-title,
.page-subtitle,
.card-title,
.drop-title,
.drop-hint,
.suggestion-name,
.suggestion-category,
.fact-label,
.template-card-title,
.template-card-cat,
.placeholder-title,
.placeholder-hint,
.modal-title,
.form-label,
.section-divider-label,
.empty-state-text,
.empty-state-hint,
.export-btn .export-label,
.export-btn .export-desc,
.text-muted,
.text-gold,
.text-xs {
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 25%, #E8C968 50%, #B8892D 75%, #8A6A1C 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* Format chips keep their own background, just gold text */
.format-chip { color: #E8C968; border-color: #B8892D; }
.filter-pill { color: #E8C968; border-color: #B8892D; }

/* ── New Client Packet generator ─────────────────────────── */
.packet-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}

#packet-drop-zone { cursor: pointer; }
#packet-drop-zone.drag-over {
  background: rgba(201,168,76,0.04);
  border-color: var(--gold);
  box-shadow: 0 0 32px rgba(201,168,76,0.45), 0 0 64px rgba(201,168,76,0.15), inset 0 0 24px rgba(201,168,76,0.06);
}
#packet-intake-input { display: none; }

/* ── Demands tab ─────────────────────────────────────────── */
#demand-drop-zone { cursor: pointer; }
#demand-drop-zone.drag-over {
  background: rgba(201,168,76,0.04);
  border-color: var(--gold);
  box-shadow: 0 0 32px rgba(201,168,76,0.45), 0 0 64px rgba(201,168,76,0.15), inset 0 0 24px rgba(201,168,76,0.06);
}
#demand-intake-input { display: none; }

.demand-claims-options {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 180px;
  overflow-y: auto;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
}
.demand-claims-options label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1.3;
  padding: 0.1rem 0;
}
.demand-claims-options input[type="checkbox"] {
  margin-top: 0.2rem;
  accent-color: #C9A84C;
  flex-shrink: 0;
}

/* Letter-shaped editor body — white paper look for the demand preview */
.demand-letter-body {
  background: #FAF8F3;
  color: #1a1a1a;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.98rem;
  line-height: 1.7;
  padding: 2.25rem 2.5rem;
  min-height: 640px;
  max-height: none;
}
.demand-letter-body h1,
.demand-letter-body h2,
.demand-letter-body h3 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  color: #8A6A1C;
  margin-top: 1.2rem;
  margin-bottom: 0.4rem;
  letter-spacing: 0.03em;
}
.demand-letter-body h1 {
  font-size: 1.15rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-bottom: 1.5px solid #C9A84C;
  padding-bottom: 0.3rem;
  margin-bottom: 0.8rem;
}
.demand-letter-body h2 {
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  border-bottom: 1px solid #C9A84C;
  padding-bottom: 0.2rem;
}
.demand-letter-body h3 {
  font-size: 1rem;
  font-weight: 700;
}
.demand-letter-body p { margin: 0 0 0.7rem 0; }
.demand-letter-body ol, .demand-letter-body ul {
  margin: 0.2rem 0 0.7rem 1.5rem;
}
/* ── Firm letterhead (top of letter preview) ────────────────── */
.demand-letter-body .letter-letterhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}
.demand-letter-body .letter-letterhead .lh-col {
  font-size: 0.78rem;
  line-height: 1.35;
  color: #5a5a5a;
}
.demand-letter-body .letter-letterhead .lh-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 1;
}
.demand-letter-body .letter-letterhead .lh-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  flex: none;
}
.demand-letter-body .letter-letterhead .lh-name {
  font-weight: 700;
  color: #8A6A1C;
  font-size: 0.95rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  font-family: 'Cormorant Garamond', Georgia, serif;
}
.demand-letter-body .letter-letterhead .lh-title {
  font-size: 0.78rem;
  color: #666;
}
.demand-letter-body .letter-letterhead .lh-center {
  flex: 1;
  text-align: center;
}
.demand-letter-body .letter-letterhead .lh-right {
  flex: 1;
  text-align: right;
}
.demand-letter-body .letter-rule {
  border: none;
  border-top: 1.5px solid #C9A84C;
  border-bottom: 0.5px solid #C9A84C;
  margin: 0.4rem 0 1.3rem 0;
  height: 3px;
}

.demand-letter-body .letter-confidential {
  text-align: center;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  color: #8A6A1C;
  margin: 0.6rem 0 1.4rem 0;
  line-height: 1.45;
}
.demand-letter-body .letter-date {
  text-align: left;
  margin: 0 0 1rem 0;
}
.demand-letter-body .letter-via {
  font-weight: 700;
  font-style: normal;
  text-decoration: none;
  margin-bottom: 0.9rem;
}
.demand-letter-body .letter-recipient {
  margin-bottom: 0.9rem;
  white-space: pre-line;
}
.demand-letter-body .letter-re {
  font-weight: 700;
  margin-bottom: 1rem;
}
.demand-letter-body .letter-signature {
  margin-top: 2.2rem;
}
.demand-letter-body .letter-signature p {
  margin: 0 0 2.2rem 0;
}
.demand-letter-body .letter-signature div {
  line-height: 1.35;
}
.demand-letter-body .letter-signature b {
  color: #8A6A1C;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

/* ── Code tags ───────────────────────────────────────────── */
code {
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 0.08rem 0.4rem;
  border-radius: 4px;
  font-size: 0.82em;
  color: var(--gold);
  font-family: 'Courier New', monospace;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid-2, .grid-3, .var-fill-grid { grid-template-columns: 1fr; }
  .facts-grid { grid-template-columns: 1fr; }
  .app-main { padding: 1.25rem 1rem; }
  .header-inner { gap: 0.75rem; height: 64px; }
  .export-options { flex-direction: column; }
  .home-grid { grid-template-columns: 1fr; max-width: 420px; }
  .home-title { font-size: 2rem; }
  .home-logo { width: 260px; max-width: 80vw; }
}

@media (max-width: 600px) {
  .header-title-wrap { display: none; }
  .nav-tab { padding: 0.45rem 0.7rem; font-size: 0.7rem; }
}

/* ════════════════════════════════════════════════════════════
   RECORDS CHAT — black / gold
   ════════════════════════════════════════════════════════════ */

.rc-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  height: calc(100vh - 260px);
  min-height: 520px;
  width: 75%;
  min-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

/* Header — dropzone + file chips */
.rc-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: #0B0B0B;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.rc-dropzone-mini {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 1rem;
  border: 4px dashed rgba(201,168,76,0.45);
  border-radius: var(--radius);
  background: #000;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.78rem;
  color: var(--text-light);
  min-width: 260px;
}

.rc-dropzone-mini:hover,
.rc-dropzone-mini.drag-over {
  border-color: var(--gold);
  background: rgba(201,168,76,0.04);
  box-shadow: 0 0 22px rgba(201,168,76,0.42), inset 0 0 12px rgba(201,168,76,0.05);
}

.rc-dz-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.78;
  pointer-events: none;
  transition: opacity 0.3s, filter 0.3s;
}
.rc-dropzone-mini:hover .rc-dz-logo,
.rc-dropzone-mini.drag-over .rc-dz-logo {
  opacity: 1;
  filter: drop-shadow(0 0 8px rgba(201,168,76,0.65));
}

.rc-dropzone-mini input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.rc-dz-icon {
  font-size: 1.4rem;
  color: var(--gold);
  flex-shrink: 0;
}

.rc-dz-text {
  font-size: 0.65rem;
  line-height: 1.35;
  color: var(--white);
}
.rc-dz-text span {
  color: var(--text-dim);
  font-size: 0.58rem;
}

.rc-dz-tags {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.rc-dz-tags span {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  font-weight: 600;
}

/* File chips */
.rc-file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}
.rc-file-chips:empty { display: none; }
.rc-file-chips .file-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface-2);
  border: 1px solid var(--gold-line);
  border-radius: 10px;
  padding: 0.25rem 0.7rem 0.25rem 0.55rem;
  font-size: 0.72rem;
  color: var(--text-light);
}
.rc-file-chips .file-item:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.rc-file-chips .fi-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.rc-file-chips .fi-size {
  color: var(--text-dim);
  font-size: 0.65rem;
}
.rc-file-chips .fi-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1;
  padding: 0 0 0 2px;
  transition: color 0.2s;
}
.rc-file-chips .fi-remove:hover { color: var(--danger); }

/* Empty state */
.rc-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 0.6rem;
  padding: 2.5rem 1.5rem;
  text-align: center;
}
.rc-empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  color: var(--gold);
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rc-empty-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.rc-empty-sub {
  font-size: 0.82rem;
  color: var(--text-dim);
  max-width: 420px;
  line-height: 1.6;
}

/* File chips bar — shown above messages after upload */
.rc-file-chips-bar {
  flex: none;
  flex-shrink: 0;
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--border);
  min-height: 0;
}
.rc-file-chips-bar:empty { display: none; }

/* After upload — compact success state */
.rc-empty-state.files-ready {
  flex: none;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(78,203,130,0.2);
}
.rc-empty-state.files-ready .rc-chat-upload-zone {
  flex-direction: row;
  padding: 0.4rem 1rem;
  gap: 0.6rem;
  border-color: rgba(78,203,130,0.3);
  background: rgba(78,203,130,0.04);
  cursor: default;
  min-width: 0;
  border-radius: var(--radius);
}
.rc-empty-state.files-ready .rc-chat-dz-logo {
  width: 28px;
  height: 28px;
  opacity: 1;
}
.rc-empty-state.files-ready .drop-hint,
.rc-empty-state.files-ready .drop-formats {
  display: none;
}
.rc-empty-state.files-ready .drop-title {
  color: var(--success);
  font-size: 0.78rem;
  font-weight: 600;
}

/* Centered chat upload zone (empty state) */
.rc-chat-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.25rem 1.5rem;
  border: 4px dashed rgba(201,168,76,0.45);
  border-radius: var(--radius-lg);
  background: #000;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  min-width: 220px;
}
.rc-chat-upload-zone:hover {
  border-color: #E8C968;
  background: rgba(201,168,76,0.04);
  box-shadow: 0 0 40px rgba(232,201,104,0.55), 0 0 80px rgba(232,201,104,0.2), inset 0 0 60px rgba(232,201,104,0.45), inset 0 0 120px rgba(232,201,104,0.25);
}
.rc-chat-dz-logo {
  width: 140px;
  height: 140px;
  object-fit: contain;
  opacity: 0.82;
  pointer-events: none;
  transition: opacity 0.3s, filter 0.3s;
}
.rc-chat-upload-zone:hover .rc-chat-dz-logo {
  opacity: 1;
  filter: drop-shadow(0 0 14px rgba(201,168,76,0.7));
}
.rc-chat-upload-zone .drop-title {
  font-size: 1rem;
}
.rc-chat-upload-zone .drop-hint {
  font-size: 0.78rem;
}
.rc-chat-upload-zone .drop-formats {
  margin-top: 1rem;
  gap: 0.6rem;
}
.rc-chat-upload-zone .format-chip {
  font-size: 0.72rem;
  padding: 0.22rem 0.7rem;
}
.rc-chat-dz-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--white);
  letter-spacing: 0.02em;
}
.rc-chat-dz-hint {
  font-size: 0.62rem;
  color: var(--text-dim);
}

/* Messages */
.rc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1.25rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  scroll-behavior: smooth;
  background: var(--bg);
  min-height: 0;
}
.rc-messages::-webkit-scrollbar { width: 6px; }
.rc-messages::-webkit-scrollbar-track { background: transparent; }
.rc-messages::-webkit-scrollbar-thumb {
  background: rgba(201,168,76,0.25);
  border-radius: 4px;
}
.rc-messages::-webkit-scrollbar-thumb:hover { background: rgba(201,168,76,0.45); }

/* Chat bubbles */
.cmsg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: cmsg-in 0.3s ease-out;
}
.cmsg.user { align-self: flex-end; }
.cmsg.assistant { align-self: flex-start; max-width: 94%; }

.cmsg-bubble {
  border-radius: 14px;
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  line-height: 1.65;
}
.cmsg.user .cmsg-bubble {
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 50%, #C9A84C 100%);
  color: #000;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 14px rgba(201,168,76,0.25);
  font-weight: 500;
}
.cmsg.user .cmsg-bubble strong { color: #000; }
.cmsg.assistant .cmsg-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-light);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.4);
}
.cmsg-text { white-space: pre-wrap; word-break: break-word; }
.cmsg.assistant .cmsg-text strong { color: var(--gold); font-weight: 600; }
.cmsg.assistant .cmsg-text em { color: var(--text-dim); font-style: italic; }
.cmsg-time {
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-top: 3px;
  padding: 0 6px;
  opacity: 0;
  transition: opacity 0.2s;
}
.cmsg:hover .cmsg-time { opacity: 1; }
.cmsg.user .cmsg-time { text-align: right; }

.cite-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.cite-chip {
  font-size: 0.66rem;
  padding: 2px 9px;
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  border-radius: 12px;
  color: var(--gold);
  white-space: nowrap;
}
.cite-badge {
  background: var(--gold-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--gold);
  font-weight: 500;
  border: 1px solid var(--gold-line);
}

/* Thinking animation */
.thinking-msg .cmsg-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.thinking-dots { display: inline-flex; gap: 5px; }
.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.5;
  animation: rc-dot-pulse 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes rc-dot-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40%           { opacity: 1;   transform: scale(1.15); }
}
@keyframes cmsg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Disclosure */
.cmsg-details {
  margin-top: 10px;
  border-top: 1px solid var(--gold-line);
  padding-top: 6px;
}
.cmsg-details summary {
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--gold);
  list-style: none;
  padding: 4px 0;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cmsg-details summary::-webkit-details-marker { display: none; }
.cmsg-details summary::before {
  content: '▸';
  font-size: 0.68rem;
  transition: transform 0.15s ease;
}
.cmsg-details[open] summary::before { transform: rotate(90deg); }
.cmsg-details summary:hover { color: var(--gold-light); }
.cmsg-details-body {
  margin-top: 8px;
  padding-left: 2px;
  font-size: 0.82rem;
  color: var(--text-light);
  opacity: 0.92;
}

.cite-bar-details { margin-top: 5px; }
.cite-bar-details summary {
  cursor: pointer;
  font-size: 0.66rem;
  color: var(--gold);
  font-weight: 500;
  list-style: none;
  padding: 2px 0;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  opacity: 0.85;
}
.cite-bar-details summary::-webkit-details-marker { display: none; }
.cite-bar-details summary::before {
  content: '▸';
  font-size: 0.64rem;
  transition: transform 0.15s ease;
}
.cite-bar-details[open] summary::before { transform: rotate(90deg); }
.cite-bar-details summary:hover { opacity: 1; }
.cite-bar-details .cite-bar { margin-top: 5px; }

.rc-note {
  display: block;
  font-size: 0.74rem;
  color: var(--warning);
  opacity: 0.9;
  margin-top: 8px;
  line-height: 1.5;
}

/* Preset chips */
.rc-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.6rem 1.1rem;
  border-top: 1px solid var(--border);
  background: #0B0B0B;
  flex-shrink: 0;
}
.rc-presets:empty { padding: 0; border: none; }
.rc-presets .preset-pill {
  padding: 0.35rem 0.85rem;
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  border-radius: 16px;
  font-size: 0.7rem;
  color: var(--gold);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.rc-presets .preset-pill:hover {
  background: var(--gold);
  color: #000;
  border-color: var(--gold);
  box-shadow: 0 2px 12px rgba(201,168,76,0.35);
  transform: translateY(-1px);
}
.rc-presets .preset-pill:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* Input bar */
.rc-input-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1rem 0.9rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.rc-input {
  flex: 1;
  padding: 0.65rem 1.05rem;
  border: 1px solid var(--gold-line);
  border-radius: 22px;
  font-size: 0.86rem;
  color: var(--white);
  background: var(--surface-2);
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}
.rc-input::placeholder { color: var(--text-dim); }
.rc-input:focus {
  border-color: var(--gold);
  background: var(--surface-3);
  box-shadow: 0 0 0 2px var(--gold-soft), 0 0 18px rgba(201,168,76,0.15);
}
.rc-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--surface-2);
}
.rc-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 50%, #C9A84C 100%);
  border: none;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 2px 14px rgba(201,168,76,0.25);
}
.rc-send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 4px 22px rgba(201,168,76,0.45);
}
.rc-send-btn:active:not(:disabled) { transform: scale(0.95); }
.rc-send-btn:disabled {
  background: var(--surface-3);
  box-shadow: none;
  cursor: default;
  color: var(--text-dim);
}

/* ── API Key Setup Banner ─────────────────────────────── */
.rc-api-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  text-align: center;
}
.rc-api-setup-icon { font-size: 2rem; }
.rc-api-setup-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.02em;
}
.rc-api-setup-sub {
  font-size: 0.83rem;
  color: var(--text-dim);
  max-width: 400px;
  line-height: 1.6;
}
.rc-api-setup-sub code {
  background: var(--surface-3);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--gold-light);
  font-family: monospace;
  font-size: 0.78rem;
}
.rc-api-setup-row {
  display: flex;
  gap: 0.6rem;
  width: 100%;
  max-width: 440px;
}
.rc-api-key-input {
  flex: 1;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.85rem;
  font-family: monospace;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.rc-api-key-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-soft);
}
.rc-api-key-btn {
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 50%, #C9A84C 100%);
  border: none;
  border-radius: 8px;
  color: #000;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  box-shadow: 0 2px 12px rgba(201,168,76,0.2);
}
.rc-api-key-btn:hover:not(:disabled) {
  opacity: 0.88;
  box-shadow: 0 4px 20px rgba(201,168,76,0.35);
  transform: translateY(-1px);
}
.rc-api-key-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.rc-api-setup-msg {
  font-size: 0.8rem;
  color: var(--text-dim);
  min-height: 1.1em;
}
.rc-api-setup-msg.success { color: var(--success); }
.rc-api-setup-msg.error { color: var(--danger); }

@media (max-width: 700px) {
  .rc-card { height: calc(100vh - 220px); min-height: 480px; }
  .rc-header { padding: 0.7rem 0.8rem; }
  .rc-dropzone-mini { min-width: 0; width: 100%; }
}

/* ============================================================
   SCAN DOCUMENT UPLOADS
   ============================================================ */

/* ── Scan two-card layout ─────────────────────────── */
.scan-top-row {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 1.25rem;
  margin: 0 auto 1.25rem;
  max-width: 1050px;
}

.scan-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
}

.scan-upload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.scan-card-title {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 1rem;
}
.scan-accent { color: var(--gold); }

.scan-info-desc,
.scan-upload-desc {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.scan-feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.scan-feature-list li {
  font-size: 0.87rem;
  color: var(--text-dim);
}

.scan-upload-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.scan-upload-right {
  flex-shrink: 0;
  width: 210px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/* Compact drop zone inside the upload card */
.scan-dz-compact {
  width: 220px !important;
  min-height: 160px !important;
  padding: 1rem !important;
  cursor: pointer;
}
.scan-dz-compact .rc-chat-dz-logo {
  width: 42px !important;
  height: 42px !important;
  margin-bottom: 0.5rem !important;
}
.scan-dz-compact .drop-title {
  font-size: 0.78rem !important;
  margin-bottom: 0.4rem !important;
}
.scan-dz-compact .drop-formats {
  gap: 0.3rem !important;
}
.scan-dz-compact .format-chip {
  font-size: 0.65rem !important;
  padding: 0.15rem 0.45rem !important;
}

/* Status label below drop zone */
.scan-dz-status {
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  min-height: 1.2em;
  color: var(--gold);
}
.scan-dz-status.processing { color: var(--text-dim); }

.scan-stats {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.scan-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}


.scan-table-wrap {
  max-width: 1050px;
  margin: 0.75rem auto 0;
  overflow-x: auto;
}
.scan-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
  font-size: 0.92rem;
}
.scan-table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-2);
  padding: 0.75rem 0.6rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.scan-th-actions { text-align: right; }
.scan-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}
.scan-table tbody tr:hover { background: rgba(201,168,76,0.04); }
.scan-table td {
  padding: 0.7rem 0.6rem;
  vertical-align: middle;
}

.scan-row.scan-conf-low {
  background: rgba(232,208,138,0.07);
  border-left: 3px solid var(--warning);
}
.scan-row.scan-conf-med {
  border-left: 3px solid var(--gold-line);
}
.scan-row.scan-conf-high {
  border-left: 3px solid var(--success);
}
.scan-row-done {
  opacity: 0.6;
}

.scan-input {
  width: 100%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}
.scan-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201,168,76,0.2);
}
.scan-input.scan-filename { font-weight: 500; }
.scan-meta-line {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
  line-height: 1.35;
  word-break: break-word;
}
.scan-meta-summary { font-style: italic; }

.scan-conf-badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  font-size: 0.78rem;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: var(--surface-3);
  color: var(--text-dim);
  text-transform: capitalize;
  white-space: nowrap;
}
.scan-conf-high .scan-conf-badge {
  background: rgba(78,203,130,0.12);
  border-color: rgba(78,203,130,0.4);
  color: var(--success);
}
.scan-conf-med .scan-conf-badge {
  background: var(--gold-soft);
  border-color: var(--gold-line);
  color: var(--text-light);
}
.scan-conf-low .scan-conf-badge {
  background: rgba(232,208,138,0.18);
  border-color: rgba(232,208,138,0.5);
  color: var(--warning);
}

.scan-status {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.scan-actions-cell {
  text-align: right;
  white-space: nowrap;
}
/* Icon-only circle buttons (preview + remove) */
.scan-btn-mini {
  background: var(--surface-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.78rem;
  cursor: pointer;
  margin-left: 0.25rem;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  vertical-align: middle;
}
.scan-btn-mini:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--gold);
  color: var(--gold);
}
.scan-btn-mini:disabled { opacity: 0.35; cursor: not-allowed; }
/* Remove button — red tint on hover */
.scan-remove-btn:hover:not(:disabled) {
  background: rgba(220,50,50,0.1);
  border-color: rgba(220,50,50,0.5);
  color: #e05555;
}
/* Transfer button — prominent pill */
.scan-transfer-btn {
  background: var(--gold-soft-2);
  border: 1px solid var(--gold-line);
  color: var(--text-light);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  width: auto;
  height: auto;
  cursor: pointer;
  margin-left: 0.35rem;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
.scan-transfer-btn:hover:not(:disabled) {
  background: var(--gold);
  color: #000;
  border-color: var(--gold);
}
.scan-transfer-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Preview modal */
.scan-modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.scan-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(2px);
}
.scan-modal-frame {
  position: relative;
  width: min(92vw, 1100px);
  height: min(90vh, 900px);
  background: var(--surface);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.scan-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.scan-modal-title {
  color: var(--text-light);
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-right: 1rem;
}
.scan-modal-close {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: 6px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}
.scan-modal-close:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold-light);
}
.scan-modal-body {
  flex: 1;
  background: #fff;
  overflow: hidden;
}

@media (max-width: 900px) {
  .scan-table thead { display: none; }
  .scan-table, .scan-table tbody, .scan-table tr, .scan-table td { display: block; width: 100%; }
  .scan-table tr { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
  .scan-actions-cell { text-align: left; padding-top: 0.25rem; }
}

/* ============================================================
   REFERRAL TRACKING
   ============================================================ */

.ref-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 0 0 1.1rem 0;
}
@media (max-width: 900px) {
  .ref-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.ref-stat-card {
  background: var(--surface);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  padding: 0.95rem 1rem 0.85rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.ref-stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
}
.ref-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 600;
}
.ref-stat-value {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.85rem;
  font-weight: 600;
  color: var(--gold-light);
  margin-top: 0.25rem;
  line-height: 1.1;
}
.ref-stat-value.ref-stat-paid     { color: var(--success, #4ECB82); }
.ref-stat-value.ref-stat-outstanding { color: var(--warning, #E8D08A); }
.ref-stat-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
}

.ref-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  margin-bottom: 0.9rem;
}
.ref-toolbar-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 160px;
}
.ref-toolbar-group:first-child { flex: 1 1 280px; min-width: 240px; }
.ref-toolbar-grow { flex: 1 1 auto; align-items: flex-end; justify-content: flex-end; }
.ref-toolbar-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
}
.ref-search { width: 100%; }

.ref-table-wrap {
  background: var(--surface);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-md);
}
.ref-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
  font-size: 0.88rem;
}
.ref-table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface-2);
  border-bottom: 1px solid var(--gold-line);
  padding: 0.7rem 0.8rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.ref-table th.ref-num,
.ref-table td.ref-num { text-align: right; font-variant-numeric: tabular-nums; }
.ref-table th.ref-actions-th,
.ref-table td.ref-actions-cell { text-align: right; white-space: nowrap; }

.ref-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}
.ref-table tbody tr:last-child { border-bottom: 0; }
.ref-table tbody tr:hover { background: rgba(201,168,76,0.05); }
.ref-table td {
  padding: 0.7rem 0.8rem;
  vertical-align: middle;
}
.ref-table .ref-case-name { font-weight: 600; color: var(--text-light); }
.ref-table .ref-case-num  { font-size: 0.74rem; color: var(--text-dim); margin-top: 0.15rem; }
.ref-table .ref-firm-name { font-weight: 500; }
.ref-table .ref-firm-att  { font-size: 0.74rem; color: var(--text-dim); margin-top: 0.15rem; }

.ref-empty-row {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-dim);
  font-style: italic;
}

.ref-status-pill {
  display: inline-block;
  padding: 0.18rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  background: var(--surface-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.ref-status-pill.ref-status-Ongoing {
  background: var(--gold-soft);
  border-color: var(--gold-line);
  color: var(--gold-light);
}
.ref-status-pill.ref-status-Paid {
  background: rgba(78,203,130,0.14);
  border-color: rgba(78,203,130,0.45);
  color: var(--success, #4ECB82);
}
.ref-status-pill.ref-status-Cancelled {
  background: rgba(180,180,180,0.1);
  border-color: rgba(180,180,180,0.3);
  color: #9a9a9a;
}

.ref-row-btn {
  background: var(--surface-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.78rem;
  cursor: pointer;
  margin-left: 0.25rem;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  vertical-align: middle;
}
.ref-row-btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--gold);
  color: var(--gold);
}
.ref-row-btn.ref-row-delete:hover:not(:disabled) {
  background: rgba(220,50,50,0.1);
  border-color: rgba(220,50,50,0.5);
  color: #e05555;
}
.ref-row-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.ref-readonly {
  background: var(--surface-2) !important;
  color: var(--gold-light) !important;
  font-weight: 600 !important;
  font-variant-numeric: tabular-nums;
  cursor: default;
}

@media (max-width: 900px) {
  .ref-table thead { display: none; }
  .ref-table, .ref-table tbody, .ref-table tr, .ref-table td { display: block; width: 100%; }
  .ref-table tr {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border);
  }
  .ref-table td { padding: 0.3rem 0.5rem; text-align: left !important; }
  .ref-table td::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 110px;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: 600;
    margin-right: 0.5rem;
  }
}

/* ============================================================
   EMPLOYMENT INTAKE
   ============================================================ */

.intake-wrap {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.intake-toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.1rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 0.25rem;
}
.intake-title { margin: 0; font-size: 1.4rem; }
.intake-subtitle { margin: 0.15rem 0 0; }
.intake-toolbar-left { flex: 1 1 320px; min-width: 240px; }
.intake-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.intake-savestate {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 0.3rem 0.6rem;
  background: var(--surface-3);
  border-radius: 999px;
  border: 1px solid var(--border);
}
.intake-savedot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.2s ease;
}
.intake-savestate.saving .intake-savedot { background: var(--gold); animation: pulse 1.2s ease-in-out infinite; }
.intake-savestate.saved  .intake-savedot { background: var(--success, #4ECB82); }
.intake-savestate.error  .intake-savedot { background: var(--danger, #e05555); }
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.intake-progressbar {
  width: 100%;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  margin: 0.15rem 0 0.5rem;
}
.intake-progressbar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  transition: width 0.3s ease;
}

.intake-section {
  background: var(--surface);
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
.intake-section[open] {
  box-shadow: var(--shadow-md);
}
.intake-section-summary {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s ease;
}
.intake-section-summary::-webkit-details-marker { display: none; }
.intake-section-summary::marker { display: none; }
.intake-section-summary:hover { background: rgba(201,168,76,0.04); }
.intake-section-summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--gold);
  font-size: 0.85rem;
  transition: transform 0.2s ease;
}
.intake-section[open] > .intake-section-summary::after { transform: rotate(180deg); }

.intake-section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  color: var(--gold-light);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.intake-section[data-complete="true"] .intake-section-num {
  background: rgba(78,203,130,0.15);
  border-color: rgba(78,203,130,0.4);
  color: var(--success, #4ECB82);
}
.intake-section-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-light);
}
.intake-section-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-style: italic;
}
.intake-section-body {
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.intake-subhead {
  margin: 1rem 0 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 600;
}
.intake-yesno-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}
@media (max-width: 700px) {
  .intake-yesno-grid { grid-template-columns: 1fr; }
}
.intake-ynrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
}
.intake-ynrow > span {
  font-size: 0.85rem;
  color: var(--text);
}
.intake-ynrow > select {
  width: auto;
  min-width: 110px;
}

.intake-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.4rem 0.85rem;
  margin-top: 0.3rem;
}
.intake-chk {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  transition: var(--transition);
}
.intake-chk:hover { border-color: var(--gold-line); background: var(--gold-soft); }
.intake-chk input[type="checkbox"] {
  width: 14px; height: 14px;
  accent-color: var(--gold);
  cursor: pointer;
}
.intake-chk input[type="checkbox"]:checked + * {
  color: var(--gold-light);
}

.intake-disclaimer {
  background: var(--surface-2);
  border-left: 3px solid var(--gold);
  padding: 0.85rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.55;
}
.intake-disclaimer p { margin: 0 0 0.55rem; }
.intake-disclaimer p:last-child { margin-bottom: 0; }
.intake-disclaimer strong { color: var(--gold-light); }

/* ============================================================
   INTAKE PAPER VARIANT — light "legal paper" layout for the form
   only. Toolbar and header cards stay dark.
   ============================================================ */

.intake-paper {
  /* Re-scope theme variables to light values inside the paper */
  --surface:     #FAF7EE;   /* cream paper */
  --surface-2:   #F2EEDF;   /* slight tint */
  --surface-3:   #FFFFFF;   /* input bg */
  --text:        #1B2B5E;   /* firm navy primary */
  --text-light:  #0F1A3D;
  --text-dim:    #6B6B6B;
  --border:      #E5E0D0;
  --border-2:    #D8D2BD;
  --gold:        #8A6A1C;   /* deep paper-friendly gold */
  --gold-light:  #B8892D;
  --gold-line:   rgba(138, 106, 28, 0.30);
  --gold-soft:   rgba(138, 106, 28, 0.08);
  --gold-soft-2: rgba(138, 106, 28, 0.16);

  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 2rem 2.25rem 1rem;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.45);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Sections inside paper: no individual cards, just dividers */
.intake-paper .intake-section {
  background: transparent;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  margin: 0;
}
.intake-paper .intake-section:last-of-type { border-bottom: 0; }
.intake-paper .intake-section[open] { box-shadow: none; }

.intake-paper .intake-section-summary {
  padding: 1rem 0;
}
.intake-paper .intake-section-summary:hover {
  background: var(--gold-soft);
  border-radius: 6px;
}
.intake-paper .intake-section-summary::after {
  color: var(--gold);
}

.intake-paper .intake-section-num {
  background: var(--gold-soft);
  border-color: var(--gold-line);
  color: var(--gold);
  font-weight: 700;
}
.intake-paper .intake-section[data-complete="true"] .intake-section-num {
  background: rgba(78, 145, 80, 0.12);
  border-color: rgba(78, 145, 80, 0.45);
  color: #357A37;
}

.intake-paper .intake-section-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  color: var(--text-light);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}
.intake-paper .intake-section-hint {
  color: #8A6A1C;
  font-style: italic;
}
.intake-paper .intake-section-body {
  border-top: 1px dashed var(--border);
  padding: 1rem 0 1.5rem;
}

/* Form fields on white paper */
.intake-paper .form-label {
  color: var(--text);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.intake-paper .form-input,
.intake-paper .form-textarea,
.intake-paper .form-select {
  background: #FFFFFF;
  border: 1px solid var(--border-2);
  color: var(--text);
  font-family: 'Inter', sans-serif;
}
.intake-paper .form-input::placeholder,
.intake-paper .form-textarea::placeholder {
  color: #9A9A9A;
}
.intake-paper .form-input:focus,
.intake-paper .form-textarea:focus,
.intake-paper .form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(138, 106, 28, 0.18);
  outline: none;
}
.intake-paper .ref-readonly,
.intake-paper input[readonly] {
  background: var(--surface-2) !important;
  color: var(--text-light) !important;
}
.intake-paper .text-muted,
.intake-paper .text-xs.text-muted {
  color: #7A7A7A !important;
}

/* Yes/No grid */
.intake-paper .intake-ynrow {
  background: #FFFFFF;
  border-color: var(--border-2);
}
.intake-paper .intake-ynrow > span { color: var(--text); }
.intake-paper .intake-subhead {
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}

/* Checkbox grid */
.intake-paper .intake-chk {
  background: #FFFFFF;
  border-color: var(--border-2);
  color: var(--text);
}
.intake-paper .intake-chk:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.intake-paper .intake-chk input[type="checkbox"] {
  accent-color: var(--gold);
}

/* Conflict-check section: keep visually distinct on the paper */
.intake-paper .intake-section[data-intake-section="conflict"] {
  background: #FBF6E5;
  border: 1px solid rgba(184, 137, 45, 0.5);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  padding: 0 1rem;
  margin: 0 0 1.25rem;
}
.intake-paper .intake-section[data-intake-section="conflict"] .intake-section-summary {
  padding: 0.85rem 0;
}
.intake-paper .intake-section[data-intake-section="conflict"] .intake-section-num {
  background: rgba(184, 137, 45, 0.18);
  border-color: rgba(184, 137, 45, 0.55);
  color: #8A6A1C;
}

/* Disclaimer block on paper */
.intake-paper .intake-disclaimer {
  background: #FFFFFF;
  color: var(--text);
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  font-size: 0.88rem;
}
.intake-paper .intake-disclaimer strong { color: var(--text-light); }
.intake-paper .intake-disclaimer p { color: var(--text); }

/* Tighten the gap between paper and previous header cards */
.intake-wrap > .intake-paper { margin-top: 0.5rem; }

/* ============================================================
   INTAKE TAB — FULL CREAM BACKGROUND
   When the intake tab is active, the entire content area below
   the top tab bar becomes cream-themed (toolbar, header cards,
   form). Re-scoping theme variables here lets all descendants
   inherit the light palette.
   ============================================================ */

#tab-intake {
  /* Re-scope theme variables to light values for the whole tab */
  --surface:     #FFFFFF;       /* white inner cards */
  --surface-2:   #F2EEDF;       /* slightly tinted cream */
  --surface-3:   #FAF7EE;       /* page bg cream */
  --text:        #1B2B5E;       /* firm navy primary */
  --text-light:  #0F1A3D;
  --text-dim:    #6B6B6B;
  --border:      #E5E0D0;
  --border-2:    #D8D2BD;
  --gold:        #8A6A1C;
  --gold-light:  #B8892D;
  --gold-line:   rgba(138, 106, 28, 0.30);
  --gold-soft:   rgba(138, 106, 28, 0.08);
  --gold-soft-2: rgba(138, 106, 28, 0.16);
  --shadow-md:   0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg:   0 6px 28px rgba(0, 0, 0, 0.12);

  background: transparent;
  color: var(--text);

  /* Push the panel out to the edges of the content area */
  margin: -1rem -2rem 0;
  padding: 1.25rem 2rem 3rem;
  min-height: calc(100vh - 180px);
}

/* Toolbar on cream — white card with warm border */
#tab-intake .intake-toolbar {
  background: #FFFFFF;
  border: 1px solid var(--border-2);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
#tab-intake .intake-title {
  color: var(--text-light);
  background: none;
  -webkit-text-fill-color: var(--text-light);
}
#tab-intake .intake-subtitle {
  color: var(--text-dim);
}
#tab-intake .intake-savestate {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text-dim);
}
#tab-intake .intake-savedot { background: #B0B0B0; }
#tab-intake .intake-savestate.saving .intake-savedot { background: var(--gold); }
#tab-intake .intake-savestate.saved .intake-savedot { background: #357A37; }
#tab-intake .intake-savestate.error .intake-savedot { background: #C44; }

/* Progress bar track on cream */
#tab-intake .intake-progressbar {
  background: rgba(138, 106, 28, 0.12);
}

/* Header cards (Open Existing, MerusCase Link) */
#tab-intake .card {
  background: #FFFFFF;
  border: 1px solid var(--border-2);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  color: var(--text);
}
#tab-intake .card-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
#tab-intake .card-title {
  color: var(--text-light);
  font-weight: 700;
}
#tab-intake .text-xs.text-muted,
#tab-intake .text-muted {
  color: var(--text-dim) !important;
}

/* Buttons on cream */
#tab-intake .btn-outline {
  background: #FFFFFF;
  border-color: var(--border-2);
  color: var(--text);
}
#tab-intake .btn-outline:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}
#tab-intake .btn-ghost {
  color: var(--text-dim);
  background: transparent;
}
#tab-intake .btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
#tab-intake .btn-gold {
  /* Gold button stays gold but with darker text for contrast */
  color: #1B1B1B;
}

/* Form labels and inputs */
#tab-intake .form-label {
  color: var(--text);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
#tab-intake .form-input,
#tab-intake .form-textarea,
#tab-intake .form-select {
  background: #FFFFFF;
  border: 1px solid var(--border-2);
  color: var(--text);
}
#tab-intake .form-input::placeholder,
#tab-intake .form-textarea::placeholder { color: #9A9A9A; }
#tab-intake .form-input:focus,
#tab-intake .form-textarea:focus,
#tab-intake .form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(138, 106, 28, 0.18);
  outline: none;
}

/* Status banner overrides on cream */
#tab-intake .status-banner.info {
  background: rgba(138, 106, 28, 0.08);
  color: var(--gold);
  border-color: var(--gold-line);
}
#tab-intake .status-banner.success {
  background: rgba(78, 145, 80, 0.10);
  color: #357A37;
  border-color: rgba(78, 145, 80, 0.4);
}
#tab-intake .status-banner.error {
  background: rgba(196, 68, 68, 0.10);
  color: #B23B3B;
  border-color: rgba(196, 68, 68, 0.4);
}

/* Form sections live directly on cream — drop the paper card chrome */
#tab-intake .intake-paper {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin-top: 0.25rem;
}

/* Section blocks: white inner cards with thin warm border */
#tab-intake .intake-paper .intake-section {
  background: #FFFFFF;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  margin-bottom: 0.55rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
#tab-intake .intake-paper .intake-section[open] {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
#tab-intake .intake-paper .intake-section-summary {
  padding: 0.85rem 1.15rem;
}
#tab-intake .intake-paper .intake-section-summary:hover {
  background: var(--surface-2);
  border-radius: 8px;
}
#tab-intake .intake-paper .intake-section-body {
  padding: 0.5rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* Conflict-check stays distinct on cream */
#tab-intake .intake-paper .intake-section[data-intake-section="conflict"] {
  background: #FBF6E5;
  border: 1px solid rgba(184, 137, 45, 0.55);
  border-left: 4px solid var(--gold);
}

/* Yes/No grid + checkbox grid on white inner cards */
#tab-intake .intake-ynrow {
  background: var(--surface-3);
  border-color: var(--border-2);
}
#tab-intake .intake-chk {
  background: var(--surface-3);
  border-color: var(--border-2);
  color: var(--text);
}
#tab-intake .intake-chk:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

/* Disclaimer block */
#tab-intake .intake-disclaimer {
  background: var(--surface-3);
  color: var(--text);
  border-left: 3px solid var(--gold);
}
#tab-intake .intake-disclaimer strong { color: var(--text-light); }

/* MerusCase picker pieces inside intake */
#tab-intake .merus-picker-status { color: var(--text-dim); }

/* ============================================================
   SIDEBAR MOCKUP — vertical nav on the left, hides top header
   Activated by body.sidebar-mode
   ============================================================ */

.app-sidebar {
  display: none;            /* off unless body.sidebar-mode */
  position: fixed;
  top: 0;
  left: 0;
  width: 200px;
  height: 100vh;
  /* Pure black to match the top bar — one continuous L-shaped frame */
  background: #000000;
  /* Crisper gold rule on the right edge — echoes the firm theme */
  border-right: 1px solid #B8892D;
  z-index: 200;
  flex-direction: column;
  overflow-y: auto;
  font-family: 'Inter', -apple-system, sans-serif;
}

body.sidebar-mode .app-sidebar { display: flex; }
/* Hide the entire top bar — firm logo lives in the sidebar now. */
body.sidebar-mode .app-header { display: none !important; }
body.sidebar-mode .nav-tabs,
body.sidebar-mode #employment-tabs,
body.sidebar-mode #immigration-tabs { display: none !important; }
body.sidebar-mode .hamburger-btn { display: none; }
body.sidebar-mode .app-main { margin-left: 200px; }
body.sidebar-mode .home-hero,
body.sidebar-mode .home-links { /* sidebar replaces top-level nav */ }
/* Home view stays dark; sidebar sits cleanly on the left of it */
body.sidebar-mode.section-home .app-main { background: transparent; }

/* Sidebar runs full height; brand block sits at top, no top-bar offset. */
body.sidebar-mode .app-sidebar {
  top: 0;
  height: 100vh;
  padding-top: 0;
  z-index: 90;
}

/* Sidebar brand at top — vertical, logo centered, gold rule below */
body.sidebar-mode .sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0.75rem 0.75rem 0.65rem;
  border-bottom: 1px solid rgba(184, 137, 45, 0.35);
  background: #000000;
}
body.sidebar-mode .sidebar-logo {
  width: auto;
  height: 56px;
  object-fit: contain;
}
/* Logo image alone is enough — hide the redundant text label */
body.sidebar-mode .sidebar-brand-text { display: none; }

/* Hide the revert toggle (production polish — keep in DOM for emergency) */
body.sidebar-mode .sidebar-footer { display: none; }

/* ============================================================
   DASHBOARD (home view) — calendar + tasks + news widgets
   Munoz cream theme with navy + gold accents.
   ============================================================ */

.dash {
  max-width: 1500px;
  margin: 0 auto;
  padding: 1.5rem 1.75rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  color: #1B2B5E;
}

/* Greeting header */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.dash-greeting h1 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.95rem;
  font-weight: 600;
  color: #0F1A3D;
  letter-spacing: 0.02em;
  margin: 0;
}
.dash-subtitle {
  margin-top: 0.25rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.dash-role-chip {
  display: inline-block;
  background: rgba(138,106,28,0.12);
  border: 1px solid rgba(138,106,28,0.35);
  color: #8A6A1C;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
}

/* Stat tiles */
.dash-stat-tiles {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.dash-stat-tile {
  display: grid;
  grid-template-areas: "icon val" "icon lbl";
  grid-template-columns: auto 1fr;
  gap: 0.1rem 0.7rem;
  align-items: center;
  background: #FFFFFF;
  border: 1px solid #D8D2BD;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  min-width: 160px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.dash-stat-tile:hover {
  border-color: #8A6A1C;
  box-shadow: 0 2px 10px rgba(138,106,28,0.12);
  transform: translateY(-1px);
}
.dash-stat-tile:active { transform: translateY(0); }
@keyframes dash-flash {
  0%, 100% { box-shadow: 0 1px 4px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.04); }
  50% { box-shadow: 0 0 0 3px rgba(138,106,28,0.30), 0 4px 16px rgba(138,106,28,0.20); }
}
.dash-card.flash-highlight { animation: dash-flash 1.2s ease; }
.dst-icon {
  grid-area: icon;
  width: 22px;
  height: 22px;
  color: #8A6A1C;
}
.dst-val {
  grid-area: val;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  color: #0F1A3D;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.dst-lbl {
  grid-area: lbl;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6B6B6B;
}
.dash-stat-tile[data-stat="tasks-overdue"] .dst-val { color: #B23B3B; }
.dash-stat-tile[data-stat="tasks-overdue"] .dst-icon { color: #B23B3B; }

/* Main grid */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-side-col {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* Cards */
.dash-card {
  background: #FFFFFF;
  border: 1px solid #D8D2BD;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.04);
  overflow: hidden;
}
.dash-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #E5E0D0;
}
.dash-card-title-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.dash-card-head h2 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: #0F1A3D;
  margin: 0;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
}

/* Calendar nav buttons + primary buttons */
.dash-cal-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.dash-icon-btn {
  background: #FFFFFF;
  border: 1px solid #D8D2BD;
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
  color: #1B2B5E;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s ease;
}
.dash-icon-btn:hover {
  background: rgba(138,106,28,0.08);
  border-color: #8A6A1C;
  color: #8A6A1C;
}
.dash-primary-btn {
  background: #8A6A1C;
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.dash-primary-btn:hover { background: #B8892D; }

/* Calendar grid */
.dash-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid #E5E0D0;
}
.dash-cal-dowhead {
  padding: 0.5rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: #8A6A1C;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: #FAF7EE;
  border-bottom: 1px solid #E5E0D0;
  border-right: 1px solid #E5E0D0;
  text-align: center;
}
.dash-cal-dowhead:nth-child(7n) { border-right: none; }
.dash-cal-cell {
  min-height: 92px;
  padding: 0.35rem 0.45rem;
  border-right: 1px solid #E5E0D0;
  border-bottom: 1px solid #E5E0D0;
  cursor: pointer;
  transition: background 0.1s ease;
  position: relative;
  background: #FFFFFF;
}
.dash-cal-cell:nth-child(7n) { border-right: none; }
.dash-cal-cell:hover { background: #FAF7EE; }
.dash-cal-cell.dim { background: #FBF9F0; color: #B8B0A0; }
.dash-cal-cell.today { background: #FBF6E5; }
.dash-cal-cell.today .dash-cal-day { color: #8A6A1C; font-weight: 700; }
.dash-cal-day {
  font-size: 0.78rem;
  font-weight: 600;
  color: #1B2B5E;
  margin-bottom: 0.25rem;
}

.dash-cal-event {
  display: block;
  font-size: 0.72rem;
  line-height: 1.25;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  font-weight: 500;
}
.dash-cal-event[data-kind="meeting"]  { background: rgba(11,61,145,0.10); color: #0B3D91; }
.dash-cal-event[data-kind="deadline"] { background: rgba(178,59,59,0.10); color: #8A1F1F; }
.dash-cal-event[data-kind="personal"] { background: rgba(53,122,55,0.10); color: #1F5F3A; }
.dash-cal-event[data-kind="other"]    { background: rgba(108,108,108,0.10); color: #2C3340; }
.dash-cal-event[data-source="external"] {
  background: rgba(184,137,45,0.12) !important;
  color: #6B5215 !important;
  border-left: 2px solid #B8892D;
}
.dash-cal-event-more {
  font-size: 0.68rem;
  color: #6B6B6B;
  padding-left: 0.4rem;
}

/* Calendar subscriptions list (below grid) */
.dash-cal-subs {
  padding: 0.55rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  border-top: 1px solid #E5E0D0;
  background: #FAF7EE;
}
.dash-cal-sub-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.74rem;
  background: #FFFFFF;
  border: 1px solid #D8D2BD;
  border-radius: 999px;
  padding: 0.2rem 0.6rem 0.2rem 0.55rem;
  color: #1B2B5E;
}
.dash-cal-sub-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #B8892D;
}
.dash-cal-sub-chip-x {
  border: none;
  background: transparent;
  color: #B23B3B;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 0.15rem;
}

/* News widget */
.dash-news .dash-card-head h2 { font-size: 0.92rem; }
.dash-news-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(138,106,28,0.12);
  color: #8A6A1C;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
}
.dash-news-body {
  padding: 0.6rem 1rem 1rem;
  /* Show ~2 stories + a teaser of the 3rd; user scrolls for the rest. */
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #B8892D #FAF7EE;
}
.dash-news-body::-webkit-scrollbar { width: 6px; }
.dash-news-body::-webkit-scrollbar-track { background: #FAF7EE; }
.dash-news-body::-webkit-scrollbar-thumb { background: #D8D2BD; border-radius: 3px; }
.dash-news-body::-webkit-scrollbar-thumb:hover { background: #B8892D; }
.dash-news-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid #F0EBD8;
}
.dash-news-item:last-child { border-bottom: none; }
.dash-news-headline {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.92rem;
  font-weight: 600;
  color: #0F1A3D;
  text-decoration: none;
  line-height: 1.35;
}
.dash-news-headline:hover { color: #8A6A1C; text-decoration: underline; }
.dash-news-meta {
  font-size: 0.7rem;
  color: #6B6B6B;
  margin-top: 0.2rem;
}
.dash-news-loading,
.dash-news-empty {
  display: block;
  padding: 1rem 0;
  font-size: 0.82rem;
  color: #6B6B6B;
  font-style: italic;
  text-align: center;
}
.dash-news-err {
  font-size: 0.78rem;
  color: #B23B3B;
  font-style: italic;
  padding: 0.5rem 0;
}

/* Quick-add task input */
.dash-task-quickadd-wrap {
  padding: 0.6rem 1rem 0.4rem;
  border-bottom: 1px solid #F0EBD8;
}
.dash-task-quickadd {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #D8D2BD;
  border-radius: 6px;
  background: #FAF7EE;
  font-size: 0.86rem;
  color: #1B2B5E;
  font-family: inherit;
  transition: all 0.15s ease;
}
.dash-task-quickadd::placeholder { color: #9A9A9A; font-style: italic; }
.dash-task-quickadd:focus {
  outline: none;
  background: #FFFFFF;
  border-color: #8A6A1C;
  box-shadow: 0 0 0 3px rgba(138,106,28,0.15);
}

/* Task list */
.dash-task-tabs {
  display: flex;
  gap: 0;
  padding: 0 1rem;
  border-bottom: 1px solid #E5E0D0;
  background: #FAF7EE;
}
.dash-task-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.55rem 0.85rem;
  font-size: 0.8rem;
  color: #6B6B6B;
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.dash-task-tab.active {
  color: #8A6A1C;
  border-bottom-color: #8A6A1C;
  font-weight: 700;
}
.dash-task-tab-count {
  display: inline-block;
  min-width: 1.4em;
  padding: 0.05rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  background: #E5E0D0;
  color: #6B6B6B;
  font-variant-numeric: tabular-nums;
  text-align: center;
  line-height: 1.3;
}
.dash-task-tab.active .dash-task-tab-count {
  background: rgba(138,106,28,0.18);
  color: #8A6A1C;
}
.dash-task-list {
  padding: 0.3rem 0;
  max-height: 480px;
  overflow-y: auto;
}
.dash-task-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #F0EBD8;
  transition: background 0.1s ease;
}
.dash-task-row:last-child { border-bottom: none; }
.dash-task-row:hover { background: #FAF7EE; }
.dash-task-row.done .dash-task-title {
  text-decoration: line-through;
  color: #9A9A9A;
}
.dash-task-check {
  margin-top: 0.18rem;
  cursor: pointer;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: #8A6A1C;
}
.dash-task-body { flex: 1; min-width: 0; }
.dash-task-title {
  font-size: 0.88rem;
  color: #1B2B5E;
  font-weight: 500;
  cursor: pointer;
}
.dash-task-meta {
  display: flex;
  gap: 0.55rem;
  font-size: 0.7rem;
  color: #6B6B6B;
  margin-top: 0.2rem;
  flex-wrap: wrap;
  align-items: center;
}
.dash-task-meta .due { font-weight: 500; }
.dash-task-meta .due.overdue { color: #B23B3B; font-weight: 700; }
.dash-task-meta .due.soon { color: #B8892D; font-weight: 700; }
.dash-task-meta .priority-high { color: #B23B3B; font-weight: 700; }
.dash-task-meta .priority-med  { color: #8A6A1C; }
.dash-task-meta .priority-low  { color: #6B6B6B; }
.dash-task-meta .assignee {
  background: rgba(138,106,28,0.10);
  color: #8A6A1C;
  padding: 0.05rem 0.5rem;
  border-radius: 9px;
  font-weight: 600;
}
.dash-task-empty {
  padding: 1.6rem 1rem;
  text-align: center;
  color: #6B6B6B;
  font-style: italic;
  font-size: 0.85rem;
}

/* Modals (event / task / sub) */
.dash-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 26, 61, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}
.dash-modal-bg[hidden] { display: none; }
.dash-modal {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 1.5rem 1.6rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-height: 90vh;
  overflow-y: auto;
}
.dash-modal h3 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  margin: 0 0 1rem;
  font-size: 1.15rem;
  color: #0F1A3D;
}
.dash-modal label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #8A6A1C;
  margin: 0.75rem 0 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.dash-modal input,
.dash-modal select,
.dash-modal textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid #D8D2BD;
  border-radius: 6px;
  font-size: 0.88rem;
  box-sizing: border-box;
  font-family: inherit;
  background: #FFFFFF;
  color: #1B2B5E;
}
.dash-modal input:focus,
.dash-modal select:focus,
.dash-modal textarea:focus {
  outline: none;
  border-color: #8A6A1C;
  box-shadow: 0 0 0 3px rgba(138,106,28,0.18);
}
.dash-modal textarea { resize: vertical; min-height: 60px; }
.dash-modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.dash-modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.2rem;
}
.dash-modal-actions .right { display: flex; gap: 0.55rem; }
.dash-modal-err {
  color: #B23B3B;
  font-size: 0.82rem;
  margin-top: 0.6rem;
  min-height: 1.1em;
}
.dash-btn {
  padding: 0.45rem 0.95rem;
  border-radius: 6px;
  border: 1px solid #D8D2BD;
  background: #FFFFFF;
  font-size: 0.84rem;
  cursor: pointer;
  font-family: inherit;
  color: #1B2B5E;
  font-weight: 500;
}
.dash-btn:hover {
  background: #FAF7EE;
  border-color: #8A6A1C;
  color: #8A6A1C;
}
.dash-btn.primary {
  background: #8A6A1C;
  color: #FFFFFF;
  border-color: #8A6A1C;
  font-weight: 600;
}
.dash-btn.primary:hover { background: #B8892D; }
.dash-btn.danger { color: #B23B3B; border-color: #E0C0C0; }
.dash-btn.danger:hover { background: rgba(178,59,59,0.08); }

/* When in sidebar mode, the home view becomes the cream dashboard —
   override the dark theme that body has on .section-home by re-scoping
   light theme variables and forcing the cream background. */
body.sidebar-mode.section-home {
  --bg:          #FAF7EE;
  --surface:     #FFFFFF;
  --surface-2:   #F2EEDF;
  --surface-3:   #FAF7EE;
  --text:        #1B2B5E;
  --text-light:  #0F1A3D;
  --text-dim:    #6B6B6B;
  --border:      #E5E0D0;
  --border-2:    #D8D2BD;
  --gold:        #8A6A1C;
  --gold-light:  #B8892D;
  --gold-soft:   rgba(138,106,28,0.08);
  --gold-line:   rgba(138,106,28,0.30);
  background: #FAF7EE;
  color: #1B2B5E;
}
body.sidebar-mode.section-home .app-main { background: #FAF7EE; }
body.sidebar-mode.section-home .view#view-home { background: #FAF7EE; }

/* Standalone Dashboard link in sidebar (no section header above it) */
body.sidebar-mode .sidebar-nav > .sidebar-link-standalone {
  margin-top: 0.4rem;
  margin-bottom: 0.25rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* ============================================================
   LOGIN OVERLAY
   ============================================================ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background:
    radial-gradient(ellipse at center, rgba(184, 137, 45, 0.05) 0%, transparent 60%),
    #000000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
body.auth-pending .login-overlay { display: flex; }

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 2.25rem 2rem 1.5rem;
  background: #0E0E0E;
  border: 1px solid rgba(184, 137, 45, 0.35);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  text-align: center;
}
.login-logo {
  width: auto;
  height: 96px;
  object-fit: contain;
  margin-bottom: 0.85rem;
}
.login-brand {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 25%, #E8C968 50%, #B8892D 75%, #8A6A1C 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.login-sub {
  margin: 0.3rem 0 1.5rem;
  font-size: 0.82rem;
  color: #9A9A9A;
  letter-spacing: 0.04em;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  text-align: left;
}
.login-field { display: flex; flex-direction: column; gap: 0.3rem; }
.login-field label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #B8892D;
}
.login-field input {
  padding: 0.65rem 0.85rem;
  background: #161616;
  border: 1px solid rgba(184, 137, 45, 0.30);
  border-radius: 6px;
  color: #F5F5F5;
  font-size: 0.92rem;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.login-field input:focus {
  outline: none;
  border-color: #C9A84C;
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.18);
}

.login-submit {
  margin-top: 0.5rem;
  padding: 0.7rem;
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 50%, #C9A84C 100%);
  border: none;
  border-radius: 6px;
  color: #000;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
  box-shadow: 0 4px 14px rgba(184, 137, 45, 0.25);
}
.login-submit:hover { filter: brightness(1.08); }
.login-submit:active { transform: translateY(1px); }
.login-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.login-error {
  min-height: 1.2em;
  font-size: 0.82rem;
  color: #E06A5E;
  text-align: center;
}
.login-footer {
  margin-top: 1rem;
  font-size: 0.7rem;
  color: #6B6B6B;
  letter-spacing: 0.05em;
}

/* ============================================================
   SIDEBAR USER WIDGET (bottom)
   ============================================================ */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.85rem;
  border-top: 1px solid rgba(184, 137, 45, 0.25);
  background: #000000;
  margin-top: auto;
}
.sidebar-user-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.sidebar-user-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.92rem;
  font-weight: 600;
  color: #E8D08A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #B8892D;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logout-btn,
.sidebar-settings-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid rgba(184, 137, 45, 0.35);
  border-radius: 6px;
  color: #B8892D;
  font-size: 0.95rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.sidebar-logout-btn:hover,
.sidebar-settings-btn:hover {
  background: rgba(184, 137, 45, 0.14);
  border-color: #C9A84C;
  color: #E8D08A;
}

/* ============================================================
   SETTINGS MODAL
   ============================================================ */
.settings-modal {
  max-width: 560px;
  padding: 0;
}
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid #E5E0D0;
  background: #FAF7EE;
  position: sticky;
  top: 0;
  z-index: 1;
}
.settings-head h3 { margin: 0; }
.settings-head .dash-btn {
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.25rem 0.6rem;
}
.settings-section {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid #E5E0D0;
}
.settings-section:last-of-type { border-bottom: none; }
.settings-section h4 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: #0F1A3D;
  margin: 0 0 0.35rem;
  letter-spacing: 0.02em;
}
.settings-desc {
  font-size: 0.83rem;
  color: #6B6B6B;
  margin: 0 0 0.9rem;
  line-height: 1.5;
}
.settings-hint {
  font-size: 0.76rem;
  color: #8A6A1C;
  line-height: 1.55;
  background: rgba(184, 137, 45, 0.08);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  margin: 0 0 0.85rem;
}
.settings-readonly-note {
  font-size: 0.62rem;
  font-weight: 500;
  color: #9A9A9A;
  text-transform: none;
  letter-spacing: 0.02em;
  margin-left: 0.3rem;
}
.settings-modal input:read-only,
.settings-modal input[readonly] {
  background: #FAF7EE;
  color: #6B6B6B;
  cursor: not-allowed;
}
.settings-modal-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.75rem;
}
.settings-err {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: #B23B3B;
  min-height: 1em;
}
.settings-err.success { color: #357A37; }
.settings-flash {
  padding: 0 1.5rem;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: #357A37;
  min-height: 0;
  text-align: center;
}
.settings-flash.error { color: #B23B3B; }
.settings-footer {
  padding: 0.85rem 1.5rem;
  border-top: 1px solid #E5E0D0;
  background: #FAF7EE;
  display: flex;
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
}

/* Calendar subscriptions list inside settings */
.settings-cal-list {
  margin: 0 0 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.settings-cal-list:empty + .settings-modal-row { margin-top: 0; }
.settings-cal-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.7rem;
  background: #FAF7EE;
  border: 1px solid #E5E0D0;
  border-radius: 6px;
  font-size: 0.85rem;
}
.settings-cal-row-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.settings-cal-row-label {
  font-weight: 600;
  color: #1B2B5E;
}
.settings-cal-row-meta {
  font-size: 0.7rem;
  color: #6B6B6B;
  margin-left: auto;
}
.settings-cal-row-err { color: #B23B3B; }
.settings-cal-row-x {
  background: transparent;
  border: none;
  color: #B23B3B;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.3rem;
}
.settings-cal-empty {
  font-size: 0.82rem;
  color: #6B6B6B;
  font-style: italic;
  padding: 0.5rem 0;
}

/* ── Firm Tool toggle (Employment ↔ Immigration) ──────────── */
.firm-tool-toggle-wrap {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.85rem;
}
.firm-tool-toggle {
  display: inline-flex;
  background: #FFFFFF;
  border: 1px solid var(--border-2, #D8D2BD);
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.15rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.firm-tool-toggle button {
  padding: 0.4rem 0.95rem;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6B6B6B;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: 'Inter', sans-serif;
}
.firm-tool-toggle button:hover:not(.active) {
  color: #1B2B5E;
}
.firm-tool-toggle button.active {
  background: #8A6A1C;
  color: #FFFFFF;
  box-shadow: 0 1px 4px rgba(138, 106, 28, 0.30);
}

/* Brand at top of sidebar */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.1rem 1.1rem 0.95rem;
  border-bottom: 1px solid rgba(184, 137, 45, 0.25);
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
  cursor: pointer;
  transition: background 0.15s ease;
}
.sidebar-brand:hover { background: rgba(184, 137, 45, 0.08); }
.sidebar-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
}
.sidebar-brand-text {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #8A6A1C 0%, #B8892D 25%, #E8C968 50%, #B8892D 75%, #8A6A1C 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* Nav sections */
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.65rem 0;
  gap: 0.4rem;
}
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}
/* Collapsible <summary> styling — clickable section header */
.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #B8892D;
  padding: 0.55rem 1rem 0.4rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: color 0.15s ease;
}
.sidebar-section-label::-webkit-details-marker { display: none; }
.sidebar-section-label::marker { display: none; }
.sidebar-section-label::after {
  content: "▾";
  margin-left: auto;
  font-size: 0.7rem;
  color: rgba(184, 137, 45, 0.6);
  transition: transform 0.2s ease;
}
.sidebar-section[open] > .sidebar-section-label::after {
  transform: rotate(180deg);
}
.sidebar-section-label:hover { color: #E8C968; }

/* Items */
.sidebar-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 1rem;
  border: none;
  border-left: 4px solid transparent;
  background: transparent;
  color: #D4D4D4;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.02rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s ease;
}
.sidebar-link:hover {
  background: rgba(184, 137, 45, 0.10);
  color: #E8D08A;
  border-left-color: rgba(184, 137, 45, 0.45);
}
.sidebar-link.active {
  background: rgba(184, 137, 45, 0.20);
  border-left-color: #E8C968;
  color: #FAE99A;
  font-weight: 600;
  box-shadow: inset 0 0 16px rgba(184, 137, 45, 0.10);
}

/* Footer with revert toggle */
.sidebar-footer {
  padding: 0.85rem 1rem;
  border-top: 1px solid rgba(184, 137, 45, 0.18);
}
.sidebar-toggle-btn {
  width: 100%;
  padding: 0.5rem 0.85rem;
  background: transparent;
  border: 1px solid rgba(184, 137, 45, 0.3);
  border-radius: 6px;
  color: #B8892D;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.sidebar-toggle-btn:hover {
  background: rgba(184, 137, 45, 0.12);
  color: #E8D08A;
  border-color: #C9A84C;
}

/* When sidebar is on, drop the cream desk's left margin from .app-main
   children that previously expected full-width centering (referrals view) */
body.sidebar-mode .app-main { padding: 0; }
body.sidebar-mode .app-main > .view { padding: 0; }
body.sidebar-mode .view > .tab-panel,
body.sidebar-mode .view#view-referrals .tab-panel,
body.sidebar-mode #tab-intake,
body.sidebar-mode #imm-intake {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  padding-top: 1.5rem;
}
body.sidebar-mode #tab-intake { margin-left: 0; margin-right: 0; }

/* Responsive — collapse below 900px */
@media (max-width: 900px) {
  body.sidebar-mode .app-sidebar { width: 200px; }
  body.sidebar-mode .app-main { margin-left: 200px; }
}

/* ============================================================
   GLOBAL CREAM THEME — every page except home
   Re-scopes theme variables at body level when not on the home
   view so cards/inputs/text/buttons inherit a cream palette.
   Targeted overrides handle hard-coded dark values that don't
   come from variables.
   ============================================================ */

body:not(.section-home) {
  /* Surfaces */
  --bg:          #FAF7EE;       /* cream desk */
  --surface:     #FFFFFF;       /* white inner cards */
  --surface-2:   #F2EEDF;       /* warmer cream tint */
  --surface-3:   #FAF7EE;       /* page bg cream */
  --border:      #E5E0D0;
  --border-2:    #D8D2BD;

  /* Gold — deeper variants that read on cream */
  --gold:        #8A6A1C;
  --gold-light:  #B8892D;
  --gold-soft:   rgba(138,106,28,0.08);
  --gold-soft-2: rgba(138,106,28,0.16);
  --gold-line:   rgba(138,106,28,0.30);

  /* Legacy navy-* aliases need to map to the same gold here too */
  --navy:        #8A6A1C;
  --navy-dark:   #6B5215;
  --navy-light:  #B8892D;
  --navy-fade:   rgba(138,106,28,0.08);
  --gold-dim:    rgba(138,106,28,0.18);

  /* Text — firm navy primary, deep navy emphasis, muted gray secondary */
  --text:        #1B2B5E;
  --text-light:  #0F1A3D;
  --text-dim:    #6B6B6B;

  --gray-light:  #F2EEDF;
  --gray:        #E5E0D0;
  --gray-med:    #A8A8A8;
  --gray-dark:   #6B6B6B;

  --shadow-sm:   0 2px 6px rgba(0,0,0,0.18);
  --shadow-md:   0 4px 18px rgba(0,0,0,0.28);
  --shadow-lg:   0 10px 36px rgba(0,0,0,0.45);
  --shadow-gold: 0 0 0 1px rgba(138,106,28,0.25), 0 4px 16px rgba(138,106,28,0.10);

  background: var(--bg);
  color: var(--text);
}

/* ── Hard-coded dark color overrides on cream ─────────────── */

body:not(.section-home) a { color: var(--gold); }
body:not(.section-home) a:hover { color: var(--gold-light); }
body:not(.section-home) ::selection { background: var(--gold); color: #fff; }

/* Page heading */
body:not(.section-home) .page-title {
  color: var(--text-light);
  background: none;
  -webkit-text-fill-color: var(--text-light);
}
body:not(.section-home) .page-subtitle { color: var(--text-dim); }

/* Generic card */
body:not(.section-home) .card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}
body:not(.section-home) .card-header {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
body:not(.section-home) .card-title { color: var(--text-light); font-weight: 700; }

/* Form fields */
body:not(.section-home) .form-label {
  color: var(--text);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
body:not(.section-home) .form-input,
body:not(.section-home) .form-textarea,
body:not(.section-home) .form-select {
  background: #FFFFFF;
  border: 1px solid var(--border-2);
  color: var(--text);
}
body:not(.section-home) .form-input::placeholder,
body:not(.section-home) .form-textarea::placeholder { color: #9A9A9A; }
body:not(.section-home) .form-input:focus,
body:not(.section-home) .form-textarea:focus,
body:not(.section-home) .form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(138,106,28,0.18);
}

/* Text helpers */
body:not(.section-home) .text-muted,
body:not(.section-home) .text-xs.text-muted { color: var(--text-dim) !important; }
body:not(.section-home) .text-gold { color: var(--gold) !important; }

/* Buttons */
body:not(.section-home) .btn-outline {
  background: #FFFFFF;
  border-color: var(--border-2);
  color: var(--text);
}
body:not(.section-home) .btn-outline:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}
body:not(.section-home) .btn-ghost {
  background: transparent;
  color: var(--text-dim);
}
body:not(.section-home) .btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
body:not(.section-home) .btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-2);
}
body:not(.section-home) .btn-secondary:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}
body:not(.section-home) .btn-gold {
  /* Gold button stays gold but readable on cream — darken text */
  color: #1B1B1B;
}

/* Status banners on cream */
body:not(.section-home) .status-banner.info {
  background: rgba(138,106,28,0.08);
  color: var(--gold);
  border-color: var(--gold-line);
}
body:not(.section-home) .status-banner.success {
  background: rgba(78,145,80,0.10);
  color: #357A37;
  border-color: rgba(78,145,80,0.4);
}
body:not(.section-home) .status-banner.error {
  background: rgba(196,68,68,0.10);
  color: #B23B3B;
  border-color: rgba(196,68,68,0.4);
}

/* Drop zones (file upload) */
body:not(.section-home) .drop-zone {
  background: #FFFFFF;
  border: 2px dashed var(--border-2);
  color: var(--text-dim);
}
body:not(.section-home) .drop-zone:hover,
body:not(.section-home) .drop-zone.drag-over {
  background: var(--gold-soft);
  border-color: var(--gold);
}
body:not(.section-home) .drop-title { color: var(--text); }
body:not(.section-home) .drop-hint { color: var(--text-dim); }
body:not(.section-home) .format-chip {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text-dim);
}

/* Section divider */
body:not(.section-home) .section-divider::before,
body:not(.section-home) .section-divider::after {
  background: var(--border);
}
body:not(.section-home) .section-divider-label {
  background: var(--bg);
  color: var(--text-dim);
}

/* Editor (rich-text) */
body:not(.section-home) .editor-toolbar {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
body:not(.section-home) .toolbar-btn {
  background: #FFFFFF;
  color: var(--text);
  border: 1px solid var(--border-2);
}
body:not(.section-home) .toolbar-btn:hover {
  background: var(--gold-soft);
  color: var(--gold);
}
body:not(.section-home) .editor-body {
  background: #FFFFFF;
  color: var(--text);
}
body:not(.section-home) .editor-body[data-placeholder]:empty::before {
  color: #9A9A9A;
}

/* Modals — keep dark backdrop, light frame */
body:not(.section-home) .modal {
  background: #FFFFFF;
  color: var(--text);
}
body:not(.section-home) .modal-header {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
body:not(.section-home) .modal-title { color: var(--text-light); }
body:not(.section-home) .modal-close {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text);
}
body:not(.section-home) .modal-close:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}
body:not(.section-home) .modal-footer {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* Empty states */
body:not(.section-home) .empty-state-text { color: var(--text-dim); }
body:not(.section-home) .empty-state-hint { color: var(--text-dim); }

/* Scan tab — table, info, status */
body:not(.section-home) .scan-info-card,
body:not(.section-home) .scan-upload-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text);
}
body:not(.section-home) .scan-card-title { color: var(--text-light); }
body:not(.section-home) .scan-accent { color: var(--gold); }
body:not(.section-home) .scan-info-desc,
body:not(.section-home) .scan-upload-desc,
body:not(.section-home) .scan-stats { color: var(--text-dim); }
body:not(.section-home) .scan-feature-list li { color: var(--text); }
body:not(.section-home) .scan-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
}
body:not(.section-home) .scan-table thead th {
  color: var(--text-dim);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
body:not(.section-home) .scan-table tbody tr {
  border-bottom: 1px solid var(--border);
}
body:not(.section-home) .scan-table tbody tr:hover {
  background: var(--gold-soft);
}
body:not(.section-home) .scan-input {
  background: #FFFFFF;
  border-color: var(--border-2);
  color: var(--text);
}
body:not(.section-home) .scan-meta-line { color: var(--text-dim); }
body:not(.section-home) .scan-conf-badge {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text-dim);
}
body:not(.section-home) .scan-btn-mini {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text-dim);
}
body:not(.section-home) .scan-btn-mini:hover:not(:disabled) {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}
body:not(.section-home) .scan-transfer-btn {
  background: var(--gold-soft-2);
  border-color: var(--gold-line);
  color: var(--gold);
}
body:not(.section-home) .scan-transfer-btn:hover:not(:disabled) {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}
body:not(.section-home) .scan-modal-frame {
  background: #FFFFFF;
  border: 1px solid var(--border-2);
}
body:not(.section-home) .scan-modal-header {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

/* Records Chat (rc-*) */
body:not(.section-home) .rc-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
}
body:not(.section-home) .rc-empty-state,
body:not(.section-home) .rc-messages { color: var(--text); }
body:not(.section-home) .rc-chat-upload-zone {
  background: var(--surface-3);
  border: 2px dashed var(--border-2);
  color: var(--text-dim);
}
body:not(.section-home) .rc-chat-upload-zone:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
}
body:not(.section-home) .rc-input-bar {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
body:not(.section-home) .rc-input {
  background: #FFFFFF;
  border: 1px solid var(--border-2);
  color: var(--text);
}
body:not(.section-home) .rc-input::placeholder { color: #9A9A9A; }
body:not(.section-home) .rc-send-btn {
  background: var(--gold);
  color: #fff;
}
body:not(.section-home) .rc-send-btn:disabled {
  background: var(--surface-2);
  color: var(--text-dim);
}
body:not(.section-home) .rc-file-chips,
body:not(.section-home) .rc-presets {
  background: var(--surface-3);
}
body:not(.section-home) .rc-api-setup {
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text);
}
body:not(.section-home) .rc-api-setup-title { color: var(--text-light); }
body:not(.section-home) .rc-api-setup-sub { color: var(--text-dim); }
body:not(.section-home) .rc-api-key-input {
  background: #FFFFFF;
  border: 1px solid var(--border-2);
  color: var(--text);
}

/* Filter pills */
body:not(.section-home) .filter-pill {
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text-dim);
}
body:not(.section-home) .filter-pill:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-soft);
}
body:not(.section-home) .filter-pill.active {
  background: var(--gold-soft-2);
  border-color: var(--gold);
  color: var(--gold);
}

/* Template grid / cards */
body:not(.section-home) .template-grid .template-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text);
}
body:not(.section-home) .template-card:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-md);
}
body:not(.section-home) .template-vars { color: var(--text-dim); }

/* Demand letter editor body — keep white "letter" page */
body:not(.section-home) .demand-letter-body {
  background: #FFFFFF;
  color: #000;
}

/* Suggestion list */
body:not(.section-home) .suggestion-list .suggestion-item,
body:not(.section-home) .facts-grid > div {
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text);
}

/* Demand claim options */
body:not(.section-home) .demand-claims-options label {
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text);
}

/* Export buttons (DOCX/PDF/TXT cards) */
body:not(.section-home) .export-btn {
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text);
}
body:not(.section-home) .export-btn:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold);
}

/* Referral tab specific — already has light-friendly summary cards but
   re-affirm the table/toolbar styling on the new global cream palette */
body:not(.section-home) .ref-stat-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text);
}
body:not(.section-home) .ref-stat-label { color: var(--text-dim); }
body:not(.section-home) .ref-stat-value { color: var(--text-light); }
body:not(.section-home) .ref-toolbar {
  background: var(--surface);
  border: 1px solid var(--border-2);
}
body:not(.section-home) .ref-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border-2);
}
body:not(.section-home) .ref-table thead th {
  color: var(--text-dim);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
body:not(.section-home) .ref-table tbody tr { border-bottom: 1px solid var(--border); }
body:not(.section-home) .ref-table tbody tr:hover { background: var(--gold-soft); }
body:not(.section-home) .ref-table .ref-case-name,
body:not(.section-home) .ref-table .ref-firm-name { color: var(--text-light); }
body:not(.section-home) .ref-table .ref-case-num,
body:not(.section-home) .ref-table .ref-firm-att { color: var(--text-dim); }
body:not(.section-home) .ref-empty-row { color: var(--text-dim); }
body:not(.section-home) .ref-row-btn {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text-dim);
}
body:not(.section-home) .ref-row-btn:hover:not(:disabled) {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

/* Section drawer — keep dark; it's a navigation overlay */
/* (No overrides — drawer keeps its dark styling.) */

/* ============================================================
   CREAM THEME — POLISH FIXES (audit pass)
   Address washed-out text, faint borders, and low-contrast pills
   that show up under the cream palette but were fine on dark.
   ============================================================ */

/* Many text selectors use a gold-gradient -webkit-text-fill-color
   trick that's washed out on cream. Reset those to solid color. */
body:not(.section-home) .section-divider-label,
body:not(.section-home) .empty-state-text,
body:not(.section-home) .empty-state-hint,
body:not(.section-home) .export-btn .export-label,
body:not(.section-home) .export-btn .export-desc,
body:not(.section-home) .template-card-cat,
body:not(.section-home) .modal-title,
body:not(.section-home) .text-xs:not(.text-muted):not(.text-gold) {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: var(--text);
  color: var(--text);
}

/* Section divider lines & label on cream */
body:not(.section-home) .section-divider::before,
body:not(.section-home) .section-divider::after {
  background: var(--border-2);
}
body:not(.section-home) .section-divider-label {
  background: var(--bg);
  color: var(--text-dim);
  -webkit-text-fill-color: var(--text-dim);
  padding: 0 0.4rem;
}

/* Records-Chat preset pills on cream — visible white pill, solid gold text */
body:not(.section-home) .rc-presets {
  background: var(--surface-2);
  border-top-color: var(--border);
}
body:not(.section-home) .rc-file-chips {
  background: var(--surface-2);
}
body:not(.section-home) .rc-presets .preset-pill {
  background: #FFFFFF;
  border: 1px solid var(--border-2);
  color: var(--text);
  font-weight: 600;
}
body:not(.section-home) .rc-presets .preset-pill:hover {
  background: var(--gold);
  color: #FFFFFF;
  border-color: var(--gold);
  box-shadow: 0 2px 8px rgba(138,106,28,0.25);
}

/* Records-Chat input + send button on cream */
body:not(.section-home) .rc-input-bar {
  background: var(--surface-2);
  border-top-color: var(--border);
}
body:not(.section-home) .rc-input {
  background: #FFFFFF;
  border-color: var(--border-2);
  color: var(--text);
}
body:not(.section-home) .rc-input::placeholder { color: #9A9A9A; }
body:not(.section-home) .rc-input:focus {
  border-color: var(--gold);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(138,106,28,0.18);
}
body:not(.section-home) .rc-send-btn {
  background: var(--gold);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(138,106,28,0.30);
}
body:not(.section-home) .rc-send-btn:hover:not(:disabled) {
  box-shadow: 0 4px 14px rgba(138,106,28,0.45);
}
body:not(.section-home) .rc-send-btn:disabled {
  background: var(--surface-2);
  color: var(--text-dim);
  box-shadow: none;
}

/* Drop zones — make the dashed border more pronounced on cream */
body:not(.section-home) .drop-zone {
  border: 2px dashed var(--gold-line);
}
body:not(.section-home) .drop-zone:hover,
body:not(.section-home) .drop-zone.drag-over {
  border-color: var(--gold);
  background: var(--gold-soft);
}
body:not(.section-home) .rc-chat-upload-zone {
  border: 2px dashed var(--gold-line);
}
body:not(.section-home) .rc-chat-upload-zone:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

/* Format chips (PDF/DOCX/TXT/EML) — improve readability on cream */
body:not(.section-home) .format-chip {
  background: #FFFFFF;
  border: 1px solid var(--border-2);
  color: var(--text);
  font-weight: 600;
}

/* Suggestion list / facts grid items */
body:not(.section-home) .suggestion-list .suggestion-item:hover,
body:not(.section-home) .facts-grid > div:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

/* Modal close — subtle on cream */
body:not(.section-home) .modal-overlay { background: rgba(0,0,0,0.55); }

/* Word count + small labels in editor */
body:not(.section-home) #word-count { color: var(--text-dim); }

/* Hint texts that would be invisible (e.g., text-muted with gradient text) */
body:not(.section-home) .text-muted,
body:not(.section-home) .text-xs.text-muted,
body:not(.section-home) p.text-xs.text-muted {
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: var(--text-dim);
  color: var(--text-dim) !important;
}

/* Demand-letter editor body retains white "letter page" look */
body:not(.section-home) .demand-letter-body {
  background: #FFFFFF;
  color: #000000;
  border-radius: 4px;
}

/* "Optional" label in card headers */
body:not(.section-home) .card-header .text-xs.text-muted {
  color: var(--text-dim) !important;
  -webkit-text-fill-color: var(--text-dim);
}

/* ============================================================
   IMMIGRATION INTAKE — AI Case Review panel
   ============================================================ */

.imm-review-card {
  border-left: 4px solid #8A6A1C;
}
.imm-review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.85rem;
}
.imm-review-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6B6B6B;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.imm-review-value {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: #0F1A3D;
  line-height: 1.15;
}
.imm-review-primary { color: #8A6A1C; }
.imm-review-secondary {
  font-size: 0.78rem;
  color: #6B6B6B;
  margin-top: 0.2rem;
  font-style: italic;
}
.imm-urgency-high   { color: #B23B3B; }
.imm-urgency-medium { color: #B8892D; }
.imm-urgency-low    { color: #357A37; }

.imm-review-section { margin-top: 0.95rem; }
.imm-review-summary {
  margin: 0.25rem 0 0;
  line-height: 1.55;
  color: #1B2B5E;
}
.imm-review-list {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.imm-review-list li {
  padding: 0.55rem 0.7rem;
  background: #FAF7EE;
  border-radius: 6px;
  border-left: 2px solid #D8D2BD;
  font-size: 0.88rem;
  color: #1B2B5E;
}
.imm-risks li { border-left-color: #B23B3B; }
.imm-deadlines li { border-left-color: #8A6A1C; }
.imm-risk-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  font-size: 0.66rem;
  font-weight: 700;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.45rem;
  background: #6B6B6B;
  color: #FFFFFF;
}
.imm-risk-badge.imm-risk-high { background: #B23B3B; }
.imm-risk-badge.imm-risk-med  { background: #B8892D; }
.imm-risk-badge.imm-risk-low  { background: #357A37; }
.imm-days {
  font-size: 0.75rem;
  color: #B23B3B;
  font-weight: 600;
}

.imm-elig-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.imm-elig-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  background: #FAF7EE;
  border: 1px solid #E5E0D0;
  font-size: 0.82rem;
  color: #1B2B5E;
}
.imm-elig-val {
  text-transform: capitalize;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #E5E0D0;
  color: #6B6B6B;
}
.imm-elig-likely .imm-elig-val   { background: rgba(53,122,55,0.18); color: #357A37; }
.imm-elig-possible .imm-elig-val { background: rgba(184,137,45,0.18); color: #8A6A1C; }
.imm-elig-unlikely .imm-elig-val { background: rgba(178,59,59,0.15); color: #B23B3B; }
.imm-elig-unknown .imm-elig-val  { background: #E5E0D0; color: #6B6B6B; }

.imm-review-disclaimer {
  margin-top: 1rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.78rem;
  color: #8A6A1C;
  background: rgba(184,137,45,0.10);
  border: 1px solid rgba(184,137,45,0.35);
  border-radius: 6px;
  font-style: italic;
}
