/* ═══════════════════════════════════════════════════════
   Legacy GovCon — Main Stylesheet
   Broadsheet design tokens (see design_handoff_legacy_govcon/)
   ═══════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  /* Broadsheet tokens */
  --ink:           #201e1d;
  --paper:         #f3f2f2;
  --paper-surface: #eae9e9;
  --divider:       color-mix(in srgb, #201e1d 16%, transparent);

  --neutral-100: #f8f4f4;
  --neutral-200: #eae7e7;
  --neutral-300: #d7d3d3;
  --neutral-400: #bab6b6;
  --neutral-500: #9b9797;
  --neutral-600: #7d7979;
  --neutral-700: #605d5d;
  --neutral-800: #444141;
  --neutral-900: #2d2b2b;

  --cyan-100: #e9f8ff; --cyan-200: #cbeeff; --cyan-300: #99e0ff; --cyan-400: #62c5ee;
  --cyan-500: #38a6cf; --cyan-600: #1186ac; --cyan-700: #006786; --cyan-800: #004961; --cyan-900: #0a303e;

  --magenta-100: #fff1f4; --magenta-200: #ffdee6; --magenta-300: #ffc0d0; --magenta-400: #ff90b1;
  --magenta-500: #ff458e; --magenta-600: #d82071; --magenta-700: #aa0b56; --magenta-800: #790e3d; --magenta-900: #4b1528;

  --font-heading: "Source Serif 4", Georgia, 'Times New Roman', serif;
  --font-body:    "Source Serif 4", Georgia, 'Times New Roman', serif;

  /* Legacy variable names, remapped onto the tokens above so every
     existing view keeps working unchanged — cyan is the one interactive
     accent, magenta is reserved for urgent/cold, everything else is ink,
     paper, or a step of the neutral ramp. */
  --brand:       var(--cyan-700);
  --brand-light: var(--cyan-600);
  --accent:      var(--magenta-600);
  --bg:          var(--paper);
  --surface:     var(--paper-surface);
  --border:      var(--divider);
  --text:        var(--ink);
  --text-muted:  color-mix(in srgb, var(--ink) 55%, transparent);
  --danger:      var(--magenta-700);
  --success:     var(--cyan-700);
  --warn:        var(--magenta-700);
  --sidebar-w:   224px;
  --topbar-h:    52px;
  --radius:      2px;
  --shadow:      0 1px 2px color-mix(in srgb, var(--neutral-900) 14%, transparent);
  --shadow-md:   0 3px 10px color-mix(in srgb, var(--neutral-900) 16%, transparent);
  --shadow-lg:   0 12px 32px color-mix(in srgb, var(--neutral-900) 22%, transparent);
}

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

html { font-size: 15px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  display: flex;
  min-height: 100vh;
  font-feature-settings: "pnum" 1, "tnum" 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

a { color: var(--cyan-700); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--cyan-700); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--cyan-700) 30%, transparent); }

/* ── Login ─────────────────────────────────────────────── */
.login-body { background: var(--neutral-900); display: flex; align-items: center; justify-content: center; }
.login-wrap { width: 100%; max-width: 400px; padding: 1.5rem; }
.login-card  { background: var(--paper); border-radius: var(--radius); padding: 2.5rem; box-shadow: var(--shadow-lg); }
.login-brand { text-align: center; margin-bottom: 2rem; }
.brand-mark-lg {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; background: var(--cyan-700); color: var(--paper);
  font-family: var(--font-heading); font-weight: 600; font-size: 1.5rem;
  border-radius: var(--radius); margin-bottom: .75rem;
}
.login-brand h1 { font-size: 1.2rem; color: var(--text); }
.login-brand p  { color: var(--text-muted); font-size: .85rem; }
.login-form .form-group { margin-bottom: 1rem; }
.btn-full { width: 100%; margin-top: .5rem; }

/* ── Sidebar — navy/gold brand chrome, distinct from the cyan/magenta
   content-area accent system used everywhere else in the app ─────────── */
:root {
  --navy-900: #16324f;
  --navy-800: #1c3d60;
  --navy-700: #234a72;
  --gold-300: #e4c977;
  --gold-500: #c9a84c;
  --gold-700: #a8863a;
}
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(184deg, var(--navy-700) 0%, var(--navy-900) 78%);
  color: #cddcec;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform .25s;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .7rem;
  padding: 1.15rem 1.1rem .95rem;
  border-bottom: 1px solid color-mix(in srgb, #fff 12%, transparent);
  text-decoration: none;
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; background: color-mix(in srgb, var(--gold-500) 20%, transparent);
  color: var(--gold-300);
  border-radius: 50%; flex-shrink: 0; border: 1px solid color-mix(in srgb, var(--gold-500) 45%, transparent);
}
.brand-logo {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  object-fit: contain; background: var(--paper);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name {
  font-family: var(--font-heading); font-weight: 600; font-size: 1.05rem;
  letter-spacing: -0.01em; color: var(--gold-300);
}
.brand-sub { font-size: .74rem; color: #dfe9f3; }
.brand-tagline { font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; color: #91a7bd; margin-top: .15rem; }

.nav-list { list-style: none; padding: .6rem 0; flex: 1; }
.nav-section {
  font-size: .64rem; font-weight: 700; letter-spacing: .13em;
  text-transform: uppercase; color: var(--gold-500);
  padding: 1rem 1.1rem .35rem;
}
.nav-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem 1.1rem; font-size: .875rem; color: #c3d2e2;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-link:hover { background: color-mix(in srgb, #fff 7%, transparent); color: #fff; text-decoration: none; }
.nav-link.active {
  background: color-mix(in srgb, #fff 9%, transparent);
  color: #fff;
  border-left-color: var(--gold-500);
  font-weight: 600;
}
.nav-icon { display: inline-flex; opacity: .8; flex-shrink: 0; }
.nav-link.active .nav-icon { opacity: 1; color: var(--gold-300); }
.nav-icon-svg { display: block; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
  font-size: .72rem; color: #b7c6d6; background: color-mix(in srgb, #fff 12%, transparent);
  padding: .05rem .45rem; border-radius: 10px; flex-shrink: 0;
}
.nav-link.active .nav-count { background: color-mix(in srgb, var(--gold-500) 30%, transparent); color: var(--gold-300); }

.sidebar-footer {
  display: flex; align-items: center; gap: .6rem;
  padding: .9rem 1.1rem;
  border-top: 1px solid color-mix(in srgb, #fff 12%, transparent);
}
.sidebar-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--gold-500); color: var(--navy-900);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-weight: 700; font-size: .8rem;
}
.sidebar-footer-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sidebar-footer-name { font-size: .85rem; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer-role { font-size: .74rem; color: #9fb2c5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Dateline rail ──────────────────────────────────────── */
.dateline-rail {
  border-top: 3px solid var(--text);
  border-bottom: 1px solid var(--text);
  padding: 5px 1.5rem;
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--neutral-700);
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}
.dateline-sep { opacity: .4; }

/* ── Layout ─────────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  flex: 1; min-height: 100vh;
}
.topbar {
  position: sticky; top: 0; z-index: 90;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1.1rem;
  padding: 0 1.5rem;
}
.topbar-title { font-family: var(--font-heading); font-weight: 600; font-size: 1.05rem; }
.menu-toggle  { display: none; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text); }
.logout-form  { margin-left: 0; }

.top-tabs { display: flex; align-items: center; gap: 1.3rem; }
.top-tab {
  font-size: .92rem; color: var(--text-muted); padding: .3rem 0;
  border-bottom: 2px solid transparent; line-height: 1.2;
}
.top-tab:hover { color: var(--text); text-decoration: none; }
.top-tab.active { color: var(--text); border-bottom-color: var(--cyan-700); font-weight: 600; }

.topbar-search { flex: 1; max-width: 360px; margin-left: auto; }
.topbar-search .input {
  width: 100%; height: 34px; padding: 0 .7rem;
  font-size: .85rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.topbar-search .input:focus { outline: none; border-color: var(--cyan-700); }

.content { padding: 1.75rem 2rem; max-width: none; width: 100%; }

/* ── Overlay (mobile) ───────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 99;
}

/* ── Flash messages ─────────────────────────────────────── */
.flash {
  border-radius: var(--radius); padding: .7rem 1rem;
  margin-bottom: 1rem; font-size: .875rem; font-weight: 500;
}
.flash-success { background: var(--cyan-100); color: var(--cyan-800); border: 1px solid var(--cyan-200); }
.flash-error   { background: var(--magenta-100); color: var(--magenta-700); border: 1px solid var(--magenta-200); }
.flash-info    { background: var(--cyan-100); color: var(--cyan-800); border: 1px solid var(--cyan-200); }

/* ── Page header ────────────────────────────────────────── */
.page-header {
  display: flex; align-items: baseline; gap: 1rem;
  margin-bottom: .5rem; flex-wrap: wrap;
}
.page-header h2 { font-size: 2.05rem; font-weight: 600; letter-spacing: -0.015em; }
.page-actions   { display: flex; gap: .5rem; align-items: center; margin-left: auto; flex-wrap: wrap; }
.page-desc {
  color: var(--text-muted); font-size: .95rem;
  margin-bottom: 1.5rem; line-height: 1.5;
  width: 100%; max-width: 60ch;
}

/* ── Getting Started ────────────────────────────────────── */
.gs-steps { display: flex; flex-direction: column; gap: 1.25rem; }
.gs-step {
  display: flex; gap: 1.25rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
}
.gs-step--resources { background: var(--paper-surface); }
.gs-step-num {
  flex-shrink: 0; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--cyan-700); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .875rem;
}
.gs-step--resources .gs-step-num {
  background: var(--magenta-600); font-size: 1rem;
}
.gs-step-body { flex: 1; }
.gs-step-body h3 { font-size: 1rem; font-weight: 700; margin-bottom: .35rem; }
.gs-step-body p { font-size: .875rem; color: var(--text-muted); margin-bottom: .75rem; line-height: 1.5; }
.gs-example {
  font-size: .8rem; color: var(--text-muted);
  background: var(--bg); border-radius: var(--radius);
  padding: .6rem .75rem; margin-top: .75rem; line-height: 1.6;
}
.gs-pipeline-stages {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .5rem;
}
.gs-arrow { color: var(--text-muted); font-size: .8rem; }
.gs-resource-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1rem; margin-top: .5rem; }
.gs-resource { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.gs-resource strong { display: block; margin-bottom: .35rem; font-size: .9rem; }
.gs-resource p { font-size: .8rem; color: var(--text-muted); margin-bottom: .5rem; line-height: 1.5; }

/* ── Stat tiles — unboxed editorial KPI figures, not admin-panel cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.5rem 1.25rem; margin-bottom: 2rem;
  padding-top: .5rem; border-top: 1px solid var(--border);
}
.stat-tile {
  background: transparent; padding: 0; text-align: left;
  border-left: 2px solid var(--divider); padding-left: .9rem;
}
.stat-tile--warn { border-left-color: var(--magenta-500); }
.stat-value {
  font-family: var(--font-heading); font-size: 2.6rem; font-weight: 600;
  color: var(--text); line-height: 1; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: .68rem; color: var(--text-muted); margin-top: .4rem; text-transform: uppercase; letter-spacing: .09em; }
.stat-tile--warn .stat-value { color: var(--magenta-700); }
a.stat-tile { display: block; text-decoration: none; color: inherit; transition: border-color .15s, background .15s; }
a.stat-tile:hover { background: color-mix(in srgb, var(--text) 4%, transparent); border-left-color: var(--cyan-700); }

.stat-inline { display: flex; gap: 1.5rem; color: var(--text-muted); font-size: .9rem; }
.stat-inline strong { color: var(--text); }

/* ── Dashboard columns ──────────────────────────────────── */
.dashboard-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Cards — used for discrete listings, never as page layout ───────── */
.card { background: var(--surface); border-radius: var(--radius); padding: 1.25rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.card h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: .75rem; }
.card-header h3 { margin-bottom: 0; }

/* ── Item list ──────────────────────────────────────────── */
.item-list { list-style: none; }
.item-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .875rem; flex-wrap: wrap;
}
.item-row:last-child { border-bottom: none; }
.item-title { font-weight: 500; flex: 1; min-width: 0; }

/* ── Activity list ──────────────────────────────────────── */
.activity-list { list-style: none; }
.activity-item { display: flex; gap: .75rem; padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .82rem; }
.activity-item:last-child { border-bottom: none; }
.activity-time { color: var(--text-muted); white-space: nowrap; }

/* ── Communication log ──────────────────────────────────── */
.comm-log-form { padding: .85rem 1rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; }
.comm-log-form .form-row { margin-bottom: .5rem; }
.comm-log-form .form-group { margin-bottom: .5rem; min-width: 8rem; }
.comm-log-list { list-style: none; }
.comm-log-item { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.comm-log-item:last-child { border-bottom: none; }
.comm-log-header { display: flex; align-items: center; gap: .6rem; font-size: .8rem; color: var(--text-muted); }
.comm-log-direction { text-transform: uppercase; letter-spacing: .03em; font-size: .7rem; }
.comm-log-subject { font-weight: 600; margin-top: .3rem; font-size: .9rem; }
.comm-log-notes { margin-top: .2rem; font-size: .85rem; color: var(--text-muted); white-space: pre-wrap; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
  text-align: left; padding: .6rem .75rem;
  background: transparent; border-bottom: 1px solid var(--border);
  font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted);
  white-space: nowrap;
}
.data-table td { padding: .6rem .75rem; border-bottom: 1px solid color-mix(in srgb, var(--text) 8%, transparent); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: color-mix(in srgb, var(--text) 4%, transparent); }

/* ── Badges — near-square tags in the cyan/magenta/neutral system ───── */
.badge {
  display: inline-block; padding: .15rem .55rem;
  border-radius: var(--radius); font-size: .7rem; font-weight: 600; letter-spacing: .02em;
  background: var(--neutral-200); color: var(--neutral-800);
}
.badge--governmentcontract, .badge--government-contract { background: var(--cyan-100); color: var(--cyan-800); }
.badge--grant { background: var(--cyan-200); color: var(--cyan-800); }
.badge--job   { background: var(--neutral-200); color: var(--neutral-800); }
.badge--subcontract { background: var(--neutral-200); color: var(--neutral-800); }
.badge--new       { background: var(--cyan-100); color: var(--cyan-800); }
.badge--pursuing  { background: var(--cyan-200); color: var(--cyan-800); }
.badge--submitted { border: 1px solid var(--cyan-700); color: var(--cyan-700); background: transparent; }
.badge--awarded   { background: var(--cyan-700); color: var(--paper); }
.badge--closed, .badge--not-pursuing { background: var(--neutral-200); color: var(--neutral-700); }
.badge--federal     { background: var(--cyan-100); color: var(--cyan-800); }
.badge--foundation  { background: var(--neutral-200); color: var(--neutral-800); }
.badge--state       { background: var(--cyan-200); color: var(--cyan-800); }
.badge--high   { background: var(--magenta-100); color: var(--magenta-700); }
.badge--medium { background: var(--cyan-100); color: var(--cyan-800); }
.badge--low    { background: var(--neutral-200); color: var(--neutral-700); }
.badge--active   { background: var(--cyan-700); color: var(--paper); }
.badge--inactive { background: var(--neutral-200); color: var(--neutral-700); }
.badge--email   { background: var(--cyan-100); color: var(--cyan-800); }
.badge--call    { background: var(--neutral-200); color: var(--neutral-800); }
.badge--meeting { background: var(--cyan-200); color: var(--cyan-800); }
.badge--other   { background: var(--neutral-200); color: var(--neutral-700); }
.badge--sent   { background: var(--cyan-700); color: var(--paper); }
.badge--failed { background: var(--magenta-100); color: var(--magenta-700); }
.badge--template { background: var(--neutral-200); color: var(--neutral-800); }

/* ── Stars & scores ─────────────────────────────────────── */
.star  { color: var(--magenta-600); }
.score { font-size: .8rem; color: var(--cyan-700); font-weight: 600; }

/* ── Due date ───────────────────────────────────────────── */
.due-date--urgent { color: var(--magenta-700); font-weight: 600; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .35rem; padding: .45rem 1rem; border-radius: var(--radius);
  font-family: var(--font-heading); font-size: .875rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, border-color .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: .25rem .65rem; font-size: .8rem; }
.btn-primary   { background: var(--cyan-700); color: var(--paper); border-color: var(--cyan-700); }
.btn-primary:hover { background: var(--cyan-600); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.btn-danger    { background: var(--magenta-100); color: var(--magenta-700); border-color: var(--magenta-300); }
.btn-danger:hover { background: var(--magenta-200); }
.btn-link      { background: none; border: none; color: var(--cyan-700); cursor: pointer; font-size: .875rem; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.btn-link--danger { color: var(--magenta-700); }

/* ── Filter bar ─────────────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.filter-input  { padding: .4rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .875rem; min-width: 180px; }
.filter-input--sm { min-width: 80px; max-width: 120px; }
.filter-select { padding: .4rem .5rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .875rem; background: var(--surface); }

/* ── Forms ──────────────────────────────────────────────── */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; max-width: 860px; }
.form-section-title { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 1.5rem 0 .75rem; border-bottom: 1px solid var(--border); padding-bottom: .4rem; }
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.form-group { display: flex; flex-direction: column; gap: .3rem; min-width: 140px; flex: 1; }
.form-group--wide { flex: 2; min-width: 220px; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: .45rem .7rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .875rem; background: var(--surface); color: var(--text);
  transition: border-color .15s; font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--cyan-700); box-shadow: 0 0 0 2px color-mix(in srgb, var(--cyan-700) 20%, transparent); }
.form-group textarea { resize: vertical; }
.form-check { flex-direction: row; align-items: center; gap: .5rem; }
.form-check input { width: auto; }
.form-actions { margin-top: 1.25rem; display: flex; gap: .75rem; }
.form-context { font-size: .875rem; color: var(--text-muted); margin-bottom: 1rem; }
.inline-form  { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.req { color: var(--danger); }

/* ── Detail grid & list ─────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: .35rem .75rem; font-size: .875rem; }
.detail-list dt { font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.detail-list dd { word-break: break-word; }

/* ── Guide grid ─────────────────────────────────────────── */
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.guide-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.guide-card-header { display: flex; gap: .5rem; margin-bottom: .5rem; }
.guide-title { font-size: .95rem; font-weight: 600; margin-bottom: .75rem; }
.guide-content { white-space: pre-wrap; font-family: inherit; font-size: .875rem; }

/* ── Prose ──────────────────────────────────────────────── */
.prose { font-size: .9rem; line-height: 1.65; color: var(--text); white-space: pre-wrap; }

/* ── Digest preview ─────────────────────────────────────── */
.digest-preview { max-height: 600px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; background: var(--bg); }

/* ── Settings ───────────────────────────────────────────── */
.settings-group-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin: 1.25rem 0 .5rem; }
.profile-logo-row { display: flex; gap: 1.25rem; align-items: flex-start; margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.profile-logo-preview { width: 80px; height: 80px; flex-shrink: 0; border: 1px solid var(--border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; background: var(--bg); overflow: hidden; }
.profile-logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.profile-logo-placeholder { font-size: .7rem; color: var(--text-muted); text-align: center; }
.profile-logo-form { display: flex; flex-direction: column; gap: .35rem; align-items: flex-start; }

/* ── Misc ───────────────────────────────────────────────── */
.empty-state { color: var(--text-muted); font-size: .9rem; padding: 1.5rem 0; }
.muted       { color: var(--text-muted); font-size: .8rem; }
.text-error  { color: var(--danger); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open {
    display: block;
  }
  .main-wrap {
    margin-left: 0;
  }
  .menu-toggle {
    display: block;
  }
  .dashboard-cols,
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .filter-bar {
    gap: .4rem;
  }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .content   { padding: 1rem; }
  .form-card { padding: 1rem; }
}

/* ── How-to panel ──────────────────────────────────────── */
.how-to {
  background: var(--cyan-100); border: 1px solid var(--cyan-200);
  border-radius: var(--radius); margin-bottom: 1.25rem;
  font-size: .85rem;
}
.how-to summary {
  padding: .6rem 1rem; cursor: pointer; font-weight: 600;
  color: var(--cyan-800); list-style: none;
  display: flex; align-items: center; gap: .4rem;
  user-select: none;
}
.how-to summary::before { content: '▶'; font-size: .6rem; transition: transform .15s; }
.how-to[open] summary::before { transform: rotate(90deg); }
.how-to summary::-webkit-details-marker { display: none; }
.how-to-body { padding: .1rem 1rem .85rem; }
.how-to-body ol, .how-to-body ul { padding-left: 1.3rem; line-height: 1.9; color: var(--cyan-900); }
.how-to-body li { margin-bottom: .1rem; }
.how-to-body strong { color: var(--cyan-800); }
.how-to-body p { margin-top: .5rem; color: var(--text-muted); }

/* ── Email Inbox ───────────────────────────────────────── */
.inbox-error {
  background: var(--magenta-100); border: 1px solid var(--magenta-200); border-radius: var(--radius);
  padding: 1rem 1.25rem; color: var(--danger); margin-bottom: 1rem; line-height: 1.7;
}
.inbox-table { table-layout: fixed; }
.inbox-table .inbox-dot-cell { width: 1.75rem; text-align: center; }
.inbox-unread-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent);
}
.inbox-table .inbox-from  { width: 26%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; padding-top: .75rem; }
.inbox-table .inbox-subject { vertical-align: top; padding-top: .75rem; }
.inbox-subject-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-preview { white-space: normal; font-size: .8rem; color: var(--text-muted); margin-top: .25rem; line-height: 1.4; }
.inbox-table .inbox-date  { width: 9rem; white-space: nowrap; color: var(--text-muted); font-size: .85rem; vertical-align: top; padding-top: .75rem; }
.inbox-table .inbox-action{ width: 7rem; text-align: right; vertical-align: top; padding-top: .75rem; }
.inbox-table .inbox-dot-cell { vertical-align: top; padding-top: .9rem; }
.inbox-table .inbox-relevance-cell { width: 1.75rem; text-align: center; vertical-align: top; padding-top: .75rem; }
.inbox-relevance { font-weight: 700; font-size: 1rem; cursor: help; }
.inbox-relevance--yes { color: var(--success); }
.inbox-relevance--no { color: var(--text-muted); }
.inbox-unread td { font-weight: 600; }
.inbox-converted { opacity: .65; }
.inbox-converted td { text-decoration: none; }
.inbox-converted-dot { color: var(--success); font-size: .95rem; font-weight: 700; }
.inbox-note { margin-top: .75rem; font-size: .8rem; color: var(--text-muted); }
.badge-success { background: var(--cyan-100); color: var(--success); }
.btn-link--muted { color: var(--text-muted); font-size: .8rem; margin-left: .25rem; }

.email-preview-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.email-preview-row {
  display: flex; gap: .75rem; padding: .3rem 0;
  border-bottom: 1px solid var(--border); font-size: .875rem;
}
.email-preview-row:last-of-type { border-bottom: none; }
.email-lbl { color: var(--text-muted); min-width: 4.5rem; font-weight: 500; flex-shrink: 0; }
.email-preview-body { margin-top: .75rem; }
.email-body-text {
  font-size: .8rem; line-height: 1.6; color: var(--text-muted);
  white-space: pre-wrap; word-break: break-word;
  max-height: 200px; overflow-y: auto;
  background: var(--bg); border-radius: var(--radius);
  padding: .75rem; border: 1px solid var(--border);
}
.section-heading { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; color: var(--brand); }

/* ── SAM.gov Search ────────────────────────────────────── */
.sam-no-key {
  background: var(--magenta-100); border: 1px solid var(--magenta-200); border-radius: var(--radius);
  padding: 1rem 1.25rem; color: var(--magenta-700); margin-bottom: 1.25rem; font-size: .875rem;
}
.sam-no-key code { background: var(--magenta-200); padding: .1rem .35rem; border-radius: 3px; font-family: monospace; }
.sam-search-form { background: var(--surface); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.sam-search-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: .5rem; }
.sam-search-row:last-child { margin-bottom: 0; }
.sam-search-wide { flex: 1; min-width: 200px; }
.sam-search-btn-group { display: flex; gap: .5rem; align-items: flex-end; }
.sam-results-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; font-size: .875rem; color: var(--text-muted); }
.sam-pagination { display: flex; gap: .5rem; }
.sam-pagination--bottom { margin-top: 1rem; justify-content: center; }
.sam-results { display: flex; flex-direction: column; gap: .65rem; }
.sam-card { background: var(--surface); border-radius: var(--radius); padding: .9rem 1.1rem; }
.sam-card-title { font-weight: 600; font-size: .95rem; margin-bottom: .4rem; }
.sam-card-title a { color: var(--cyan-700); }
.sam-card-title a:hover { color: var(--cyan-600); }
.sam-card-meta { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .8rem; color: var(--text-muted); margin-bottom: .4rem; }
.sam-meta-item strong { color: var(--text); }
.sam-set-aside { background: var(--cyan-100); color: var(--cyan-800); padding: .1rem .5rem; border-radius: var(--radius); font-weight: 600; font-size: .72rem; }
.sam-card-dates { display: flex; gap: 1rem; font-size: .8rem; color: var(--text-muted); margin-bottom: .6rem; }
.sam-due--urgent { color: var(--danger); font-weight: 700; }
.sam-card-actions { display: flex; gap: .5rem; }

/* ── Digest banner ─────────────────────────────────────── */
.digest-banner {
  display: flex; align-items: center; gap: 1rem;
  background: var(--cyan-100); border: 1px solid var(--cyan-200); border-radius: var(--radius);
  padding: .85rem 1.1rem; margin-bottom: 1.25rem;
  color: var(--cyan-800);
}
.digest-banner-icon { font-size: .6rem; flex-shrink: 0; }
.digest-banner > div { flex: 1; font-size: .9rem; }

/* ── Parse digest view ─────────────────────────────────── */
.parse-email-meta {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline;
  margin-bottom: 1rem; font-size: .9rem;
}
.parse-email-from { color: var(--text-muted); font-size: .8rem; }
.parse-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem;
}
.parse-select-all { display: flex; align-items: center; gap: .5rem; font-size: .875rem; cursor: pointer; }
.parse-list { display: flex; flex-direction: column; gap: .85rem; }
.parse-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow);
  transition: opacity .15s;
}
.parse-card--unchecked { opacity: .4; }
.parse-card-header {
  display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem;
}
.parse-checkbox-label { display: flex; align-items: center; gap: .4rem; cursor: pointer; flex-shrink: 0; }
.parse-num { font-size: .75rem; color: var(--text-muted); font-weight: 600; min-width: 1.8rem; }
.parse-title-input {
  flex: 1; font-size: .95rem; font-weight: 600;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .35rem .6rem; background: var(--bg);
}
.parse-title-input:focus { outline: none; border-color: var(--brand-light); background: var(--surface); }
.parse-card-fields {
  display: flex; flex-wrap: wrap; gap: .6rem 1rem; margin-bottom: .5rem;
}
.parse-card-fields .form-group { margin-bottom: 0; min-width: 9rem; }
.parse-card-fields .form-group label { font-size: .75rem; }
.parse-card-fields .form-group input,
.parse-card-fields .form-group select { font-size: .8rem; padding: .3rem .5rem; }
.parse-preview { margin-top: .5rem; }
.parse-preview summary {
  font-size: .78rem; color: var(--text-muted); cursor: pointer;
  list-style: none; display: flex; align-items: center; gap: .35rem;
}
.parse-preview summary::before { content: '▶'; font-size: .6rem; }
.parse-preview[open] summary::before { content: '▼'; }
.parse-footer { margin-top: 1.25rem; display: flex; align-items: center; gap: 1rem; }

/* ── USASpending Research ──────────────────────────────── */
.usas-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; margin-bottom: .5rem;
}
.usas-recipient {
  font-size: 1rem; font-weight: 700; color: var(--text); flex: 1;
}
.usas-amount {
  font-size: 1rem; font-weight: 700; color: var(--success);
  white-space: nowrap; flex-shrink: 0;
}
.usas-description {
  font-size: .82rem; color: var(--text-muted); margin-bottom: .5rem;
  line-height: 1.4;
}
.usas-total-value { font-size: .82rem; color: var(--text-muted); }
.usas-total-value strong { color: var(--text); }

/* ── Grants.gov Search ────────────────────────────────── */
.grants-award-range { font-size: .82rem; }

/* ── Institution relationship status badges ───────────── */
.inst-status {
  display: inline-block; padding: .15rem .55rem; border-radius: var(--radius);
  font-size: .72rem; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
}
.inst-status--target   { background: var(--neutral-200); color: var(--neutral-800); }
.inst-status--prospect { background: var(--cyan-100); color: var(--cyan-800); }
.inst-status--partner  { background: var(--cyan-200); color: var(--cyan-800); }
.inst-status--client   { background: var(--cyan-700); color: var(--paper); }
.inst-status--vendor   { background: var(--neutral-200); color: var(--neutral-700); }
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; display: block; }

/* ── Institution primary contact block ────────────────── */
.inst-primary-contact {
  margin-top: 1rem; padding: .75rem 1rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.inst-contact-name {
  font-size: .95rem; font-weight: 600; color: var(--text); margin-top: .25rem;
}
.inst-contact-title { font-weight: 400; color: var(--text-muted); }
.inst-contact-details {
  display: flex; gap: 1rem; margin-top: .3rem;
  font-size: .82rem; color: var(--text-muted); flex-wrap: wrap;
}
.inst-contact-details a { color: var(--brand); }
.form-section-title {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  padding-bottom: .4rem; margin-bottom: .75rem;
}

/* ── App Footer ─────────────────────────────────────────── */
.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 1.5rem;
  font-size: .72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ── Email sync timestamp ───────────────────────────────── */
.sync-timestamp {
  font-size: .75rem;
  color: var(--text-muted);
  margin-right: .75rem;
}

/* ── Automation toggles ─────────────────────────────────── */
.auto-toggles { display: flex; flex-direction: column; gap: 0; }
.auto-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.auto-toggle-row:last-child { border-bottom: none; }

.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; margin-top: .2rem; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 24px;
  transition: background .2s;
}
.toggle-slider:before {
  content: '';
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: white; border-radius: 50%;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--cyan-700); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

/* ── Claude Assistant (dedicated page) ───────────────────── */
.claude-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - 3rem - 90px);
  min-height: 420px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.claude-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  color: white;
  font-weight: 600;
  flex-shrink: 0;
}

.claude-chat-header-actions {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.claude-chat-toggle {
  background: none;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: var(--radius);
  color: white;
  font-size: .85rem;
  cursor: pointer;
  padding: .3rem .6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.claude-attachment-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin: 0 1rem;
  padding: .4rem .6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .8rem;
  color: var(--text);
}

.claude-attachment-chip button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1;
}

#claudeAttachBtn {
  flex-shrink: 0;
  padding: 0.75rem;
  align-self: flex-end;
}

.claude-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.claude-message {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  line-height: 1.5;
  font-size: 0.95rem;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.claude-message-user {
  background: var(--brand);
  color: white;
  margin-left: 2rem;
  align-self: flex-end;
  max-width: min(85%, 720px);
}

.claude-message-claude {
  background: var(--bg);
  color: var(--text);
  margin-right: 2rem;
  align-self: flex-start;
  max-width: min(85%, 720px);
  border: 1px solid var(--border);
}

.claude-message-error {
  background: var(--magenta-100);
  color: var(--danger);
  border: 1px solid var(--magenta-200);
}

.claude-chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#claudeInput {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  max-height: 100px;
}

#claudeInput:focus {
  outline: none;
  border-color: var(--cyan-700);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan-700) 15%, transparent);
}

#claudeSend {
  flex-shrink: 0;
  padding: 0.75rem 1.5rem;
  white-space: nowrap;
  align-self: flex-end;
}

@media (max-width: 640px) {
  .claude-page {
    height: calc(100vh - var(--topbar-h) - 3rem - 70px);
  }

  .claude-message-user,
  .claude-message-claude {
    max-width: 90%;
  }

  #claudeInput {
    font-size: 16px;
  }
}
