/* =========================================================================
 * Asteco LOD — design system + preserved legacy class definitions
 * ---------------------------------------------------------------------
 * The new layout (sidebar + topbar + pages-wrap + settings two-panel) sits
 * on top of every legacy class the existing JS already references — none
 * of them are deleted, they're just restyled to match the refreshed
 * palette so the LOD checklist statuses, print preview, criteria badges,
 * milestone warnings etc. keep rendering correctly.
 * ========================================================================= */

:root {
  /* New palette (from design refresh) */
  --blue:        #1B4F9B;
  --blue-dk:     #0F2D5E;
  --blue-lt:     #EFF6FF;
  --orange:      #E8732A;
  --orange-lt:   #FFF7ED;
  --green:       #166534;
  --green-lt:    #F0FDF4;
  --red:         #991B1B;
  --red-lt:      #FEF2F2;
  --text:        #0F172A;
  --muted:       #64748B;
  --border:      #E2E8F0;
  --surface:     #F8FAFC;
  --white:       #FFFFFF;

  /* Legacy palette aliases — kept so JS using --green-bg etc. still works */
  --green-bg:    #F0FDF4;
  --red-bg:      #FEF2F2;
  --amber:       #92400E;
  --amber-bg:    #FFFBEB;
  --purple:      #5B21B6;
  --purple-bg:   #F5F3FF;
  --grey:        #64748B;
  --grey-bg:     #F1F5F9;

  /* Layout */
  --sidebar-w:         220px;
  --sidebar-collapsed: 60px;
  --topbar-h:          60px;
  --radius:            8px;
  --radius-lg:         12px;
  --shadow-sm:         0 1px 3px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  line-height: 1.5;
}

/* =========================================================================
 * APP SHELL — sidebar + main area + topbar + pages-wrap
 * ========================================================================= */

#appShell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--blue-dk);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
  overflow: hidden;
  z-index: 100;
}
.sidebar.collapsed {
  width: 0;
  border-right: none;
}

.sidebar-logo {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  cursor: pointer;
  padding: 8px 14px;
  transition: opacity 0.15s;
}
.sidebar-logo:hover { opacity: 0.85; }
.sidebar-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  /* The source PNG is the dark-on-transparent variant; this filter
     repaints every visible pixel pure white while preserving alpha,
     so the logo renders crisp white on the dark blue sidebar. */
  filter: brightness(0) invert(1);
}
.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 0; }

.nav-section-label {
  color: rgba(255,255,255,0.3);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 10px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}
.sidebar.collapsed .nav-section-label { opacity: 0; height: 0; padding: 0; margin: 2px 0; }

.nav-item {
  display: flex;
  align-items: center;
  padding: 9px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 1px;
  white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.active { background: rgba(255,255,255,0.15); }
.nav-item .nav-label {
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  overflow: hidden;
  transition: color 0.15s;
}
.nav-item:hover .nav-label  { color: white; }
.nav-item.active .nav-label { color: white; font-weight: 500; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 6px 0;
}

.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.sidebar-user:hover { background: rgba(255,255,255,0.08); }
.sidebar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { color: white; font-size: 12px; font-weight: 500; }
.sidebar-user-role { color: rgba(255,255,255,0.4); font-size: 10px; }
.sidebar.collapsed .sidebar-user-info { opacity: 0; width: 0; }

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  cursor: pointer;
  color: rgba(255,255,255,0.3);
  font-size: 18px;
  border-radius: var(--radius);
  margin-bottom: 4px;
}
.sidebar-collapse-btn:hover { color: white; background: rgba(255,255,255,0.08); }

/* MAIN AREA */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* TOPBAR — overrides legacy topbar styling for the new layout */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  /* unset legacy topbar */
  position: static;
  box-shadow: none;
  justify-content: flex-start;
}
.topbar-back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 11px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  display: none;
}
.topbar-back-btn:hover { color: var(--text); background: var(--surface); }
.topbar-back-btn.show { display: inline-flex; }

/* Sidebar toggle (hamburger) — far-left of topbar; shows/hides the sidebar */
.topbar-toggle {
  background: none;
  border: 1px solid transparent;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: inherit;
  margin-right: 4px;
  padding: 0;
}
.topbar-toggle:hover { background: var(--surface); border-color: var(--border); }
.topbar-toggle:active { background: var(--blue-lt); }
.topbar-toggle-icon,
.topbar-toggle-icon::before,
.topbar-toggle-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--muted);
  border-radius: 1px;
  transition: background 0.15s;
}
.topbar-toggle-icon { position: relative; }
.topbar-toggle-icon::before,
.topbar-toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
}
.topbar-toggle-icon::before { top: -6px; }
.topbar-toggle-icon::after  { top:  6px; }
.topbar-toggle:hover .topbar-toggle-icon,
.topbar-toggle:hover .topbar-toggle-icon::before,
.topbar-toggle:hover .topbar-toggle-icon::after { background: var(--text); }
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.topbar-title .crumb-sep {
  color: var(--border);
  margin: 0 8px;
  font-weight: 400;
}
.topbar-title .crumb-trail {
  color: var(--muted);
  font-weight: 400;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-user {
  font-size: 12px;
  color: var(--muted);
}

/* PAGES WRAPPER */
.pages-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.page {
  display: none;
  padding: 20px;
  min-height: 100%;
  max-width: none; /* override legacy 1080px cap */
  margin: 0;
}
.page.active { display: block; }

/* =========================================================================
 * CARDS
 * ========================================================================= */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.card-hdr {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Suppress the legacy ::after underline since we now have a real border */
.card-hdr::after { content: none; }

/* =========================================================================
 * BUTTONS
 * ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.btn-blue { background: var(--blue); color: white; }
.btn-blue:hover { background: var(--blue-dk); }
.btn-orange { background: var(--orange); color: white; }
.btn-orange:hover { opacity: 0.9; }
.btn-red { background: var(--red); color: white; }
.btn-red:hover { opacity: 0.92; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface); }
.btn-outline {
  background: transparent;
  color: var(--blue);
  border: 1px solid var(--blue);
}
.btn-outline:hover { background: var(--blue-lt); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* =========================================================================
 * FORM FIELDS
 * ========================================================================= */
.field {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue);
}
.fg2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fg3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* =========================================================================
 * BADGES + STATUS PILLS
 * ========================================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.badge-blue   { background: var(--blue-lt);   color: var(--blue); }
.badge-orange { background: var(--orange-lt); color: var(--orange); }
.badge-green  { background: var(--green-lt);  color: var(--green); }
.badge-grey   { background: var(--surface);   color: var(--muted); border: 1px solid var(--border); }
.badge-red    { background: var(--red-lt);    color: var(--red); }

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.status-received  { background: var(--blue-lt);  color: var(--blue); }
.status-verified  { background: var(--green-lt); color: var(--green); }
.status-pending   { background: var(--surface);  color: var(--muted); border: 1px solid var(--border); }
.status-missing   { background: var(--red-lt);   color: var(--red); }
.status-waived    { background: var(--purple-bg); color: var(--purple); }

/* =========================================================================
 * STAT CARDS (new) + legacy stat bar
 * ========================================================================= */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.stat-card-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}
.stat-card-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* Legacy LOD stat bar — restyled */
.stat-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.stat {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-n { font-size: 22px; font-weight: 600; color: var(--blue); }
.stat-l { font-size: 10px; color: var(--muted); margin-top: 2px; }
.s-green  .stat-n { color: var(--green); }
.s-amber  .stat-n { color: var(--amber); }
.s-red    .stat-n { color: var(--red); }
.s-purple .stat-n { color: var(--purple); }

/* =========================================================================
 * LOD CHECKLIST TABLE — preserves all legacy class names
 * ========================================================================= */
.cl-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cl-tbl thead tr {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.cl-tbl th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cl-tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.cl-tbl tr.doc-row { transition: background 0.15s; }
.cl-tbl tr.doc-row:hover td { background: var(--surface); }
.cl-tbl tr.doc-row.drag-over { border-top: 2px solid var(--orange); }
.cl-tbl tr.doc-row.dragging { opacity: 0.35; }

/* Per-member section header (new naming) + legacy mem-hdr */
.cl-section-row td,
.mem-hdr td {
  background: var(--blue-lt);
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 7px 12px;
  border-bottom: 1px solid #BFCFE8;
}
.sec-hdr td {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.drag-handle, .drag-h {
  cursor: grab;
  color: var(--border);
  font-size: 16px;
  padding: 0 4px;
  user-select: none;
}
.drag-handle:hover, .drag-h:hover { color: var(--muted); }

/* Status select (LOD doc statuses) — legacy .ss-* names + .ssel */
.ssel {
  font-size: 12px;
  padding: 4px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 500;
  width: 166px;
  font-family: inherit;
}
.ss-pending     { background: var(--amber-bg) !important; color: var(--amber)  !important; border-color: #FFD97D !important; }
.ss-received    { background: var(--green-lt) !important; color: var(--green)  !important; border-color: #BBF7D0 !important; }
.ss-rescan      { background: var(--red-lt)   !important; color: var(--red)    !important; border-color: #FCA5A5 !important; }
.ss-translation { background: var(--purple-bg)!important; color: var(--purple) !important; border-color: #C4B5FD !important; }
.ss-unavailable { background: #1E293B         !important; color: #F1F5F9       !important; border-color: #475569 !important; }
.ss-na          { background: var(--grey-bg)  !important; color: var(--grey)   !important; }
.ss-ita         { background: #DBEAFE         !important; color: #1D4ED8       !important; }
.ss-submission  { background: #FEF3C7         !important; color: #92400E       !important; }
.ss-notyetneed  { background: #F1F5F9         !important; color: #475569       !important; }
.ss-prsubmission{ background: #EDE9FE         !important; color: #5B21B6       !important; }

/* Notes input + progress bar */
.note-inp {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 8px;
  font-size: 12px;
  width: 100%;
  background: var(--white);
  font-family: inherit;
  color: var(--text);
}
.note-inp:focus { outline: none; border-color: var(--blue); }

.prog-bar {
  background: var(--border);
  border-radius: 2px;
  height: 4px;
  margin-bottom: 16px;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* =========================================================================
 * MEMBER PILLS / BADGES (LOD)
 * ========================================================================= */
.mem-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1.5px solid transparent;
  cursor: default;
}
.mem-pill .x {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  opacity: 0.6;
  padding: 0;
  line-height: 1;
}
.mem-pill .x:hover { opacity: 1; }
.mem-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* =========================================================================
 * CLIENT CARDS GRID
 * ========================================================================= */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.c-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.c-card:hover {
  border-color: var(--blue);
  box-shadow: 0 4px 12px rgba(27,79,155,0.1);
}
.cc-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin: 8px 0; }
.cc-stat  { text-align: center; padding: 5px 3px; border-radius: 6px; background: var(--surface); }
.cc-sn    { font-size: 15px; font-weight: 600; }
.cc-sl    { font-size: 10px; color: var(--muted); }

/* =========================================================================
 * PROGRAM LIBRARY + DOC LIBRARY GRIDS (legacy)
 * ========================================================================= */
.lib-grid    { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
.prog-list   { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; max-height: 540px; overflow-y: auto; background: var(--white); }
.prog-item   { padding: 9px 13px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.prog-item:last-child { border-bottom: none; }
.prog-item:hover { background: var(--blue-lt); }
.prog-item.sel   { background: var(--blue); color: white; }
.prog-item.sel .pcnt { background: rgba(255,255,255,0.2); color: white; }
.pcnt { font-size: 10px; background: var(--grey-bg); color: var(--muted); padding: 2px 6px; border-radius: 8px; font-weight: 600; }
.doc-row-lib   { display: grid; grid-template-columns: 24px 1fr 1fr auto; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.doc-row-lib-5 { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.doc-row-lib:last-child, .doc-row-lib-5:last-child { border-bottom: none; }
.doc-row-lib:hover, .doc-row-lib-5:hover { background: var(--surface); }
.sit-item { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

/* Criteria grid */
.cr-grid     { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
.cr-prog-list{ border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; max-height: 560px; overflow-y: auto; background: var(--white); }
.cr-prog-item{ padding: 9px 13px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.cr-prog-item:last-child { border-bottom: none; }
.cr-prog-item:hover { background: var(--blue-lt); }
.cr-prog-item.sel   { background: var(--blue); color: white; }
.cr-cnt { font-size: 10px; background: var(--grey-bg); color: var(--muted); padding: 2px 6px; border-radius: 8px; font-weight: 600; }

/* =========================================================================
 * CLIENT VIEW (PRINT) — legacy cv-* classes
 * ========================================================================= */
.cv-sheet {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
  max-width: 860px;
}
.cv-hdr        { display: flex; align-items: center; justify-content: space-between; padding-bottom: 16px; border-bottom: 2px solid var(--blue-dk); margin-bottom: 16px; }
.cv-firm       { text-align: right; font-size: 11px; color: var(--muted); line-height: 1.8; }
.cv-meta       { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 18px; background: var(--surface); border-radius: var(--radius); padding: 11px 14px; margin-bottom: 14px; border: 1px solid var(--border); font-size: 12px; }
.cv-meta b     { color: var(--blue-dk); }
.cv-stats-bar  { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.cv-stat       { text-align: center; padding: 8px; border-radius: 6px; border: 1px solid var(--border); }
.cv-sn         { font-size: 17px; font-weight: 600; }
.cv-sl         { font-size: 10px; color: var(--muted); }
.cv-notice     { border: 1.5px solid #C8943A; border-radius: var(--radius); padding: 11px 14px; margin-bottom: 14px; background: #FFFBF5; }
.cv-notice-title { font-size: 11px; font-weight: 700; color: #8A5E00; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px; }
.cv-notice p   { font-size: 12px; color: #5A3E00; line-height: 1.9; }
.cv-tbl        { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 16px; }
.cv-tbl th     { background: var(--blue-dk); color: white; padding: 7px 10px; text-align: left; font-size: 11px; letter-spacing: 0.04em; }
.cv-tbl td     { padding: 7px 10px; border-bottom: 1px solid #EEF2F7; vertical-align: top; }
.cv-tbl tr:nth-child(even) td { background: #FAFBFC; }
.cv-tbl tr.cv-mem-hdr td      { font-weight: 700; font-size: 12px; }
.cv-tbl tr.cv-sec-hdr td      { background: var(--blue-lt); color: var(--blue-dk); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.cv-tbl tr.cv-sec-emp td      { background: var(--purple-bg); color: var(--purple); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.cv-status     { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.cv-fname      { font-size: 10px; color: var(--blue); font-weight: 600; margin-top: 3px; }
.cv-footer     { border-top: 1px solid var(--border); padding-top: 11px; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }

/* =========================================================================
 * MODALS / OVERLAYS / TOAST / EMPTY / DELETE
 * ========================================================================= */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,45,94,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.16);
}
.modal h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 18px;
}
.chk-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
}
.chk-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.chk-list label:last-child { border-bottom: none; }

.toast {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  align-items: center;
  gap: 8px;
}

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty .ico { font-size: 32px; margin-bottom: 12px; }

.del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.del:hover { color: var(--red); background: var(--red-lt); }

/* =========================================================================
 * LOD CHECKLIST — compact info strip header
 * Replaces the tall form card; identity fields are read-only and shown
 * as label + value pairs in a single row.
 * ========================================================================= */
.lod-info-card {
  padding: 14px 18px 12px;
}
.lod-info-grid {
  display: grid;
  /* Application gets nearly 2× the width since program names run long. */
  grid-template-columns: 1fr 0.8fr 1.9fr 0.8fr 1fr;
  gap: 22px;
  align-items: flex-start;
}
.lod-info-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.lod-info-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.lod-info-input,
.lod-info-value {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  outline: none;
  width: 100%;
  min-height: 20px;
  font-family: inherit;
}
/* Inputs are single-line by nature — truncate with ellipsis + tooltip-on-hover via title=. */
.lod-info-input {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.lod-info-input[readonly] {
  cursor: default;
  color: var(--text);
}
.lod-info-input::placeholder {
  color: var(--muted);
  font-weight: 400;
  font-style: italic;
}
/* Application name (a div, not an input) is allowed to wrap to two lines. */
.lod-info-value {
  color: var(--blue-dk);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
}
.lod-info-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0 12px;
}
.lod-people-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 18px;
  align-items: start;
}
.lod-people-col { min-width: 0; }
.lod-people-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}
.lod-people-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 26px;
  align-items: center;
}
.lod-people-hint {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.lod-people-actions {
  align-self: end;
}
@media (max-width: 900px) {
  .lod-info-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .lod-people-row { grid-template-columns: 1fr; }
  .lod-people-actions { align-self: start; }
}

/* =========================================================================
 * MANAGE DOCUMENTS — two-pane modal (categories left, content right)
 * ========================================================================= */
.md-modal {
  width: min(1040px, 95vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.md-header {
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.md-header-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.md-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.md-search {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 12px;
  width: 240px;
}
.md-progress {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.md-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.md-nav {
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  padding: 8px 0;
}
.md-nav-group-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px 6px;
}
.md-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-left: 3px solid transparent;
  user-select: none;
  transition: background 0.12s;
}
.md-nav-item:hover { background: rgba(15, 54, 112, 0.05); }
.md-nav-item.active {
  background: #fff;
  border-left-color: var(--blue);
  font-weight: 600;
  color: var(--blue);
}
.md-nav-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}
.md-nav-item.active .md-nav-badge,
.md-nav-item:hover .md-nav-badge { background: #fff; }
.md-nav-badge.has-items {
  background: #DCFCE7;
  color: #166534;
  border-color: #BBF7D0;
}
.md-content {
  overflow-y: auto;
  padding: 20px 24px;
  background: #fff;
}
.md-content-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.md-content-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.md-content-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

/* Card for an existing emp/edu/funds/rel group, OR a situational sub-item */
.md-entry-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  margin-bottom: 8px;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}
.md-entry-card:hover { border-color: #CBD5E1; }
.md-entry-card.confirm-remove {
  border-color: #FCA5A5;
  background: #FEF2F2;
}
.md-entry-main { flex: 1; min-width: 0; }
.md-entry-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.md-entry-sub {
  font-size: 12px;
  color: var(--text);
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.md-entry-sub .dot {
  width: 3px; height: 3px; border-radius: 50%; background: var(--muted);
  display: inline-block;
}
.md-entry-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.md-entry-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.md-entry-confirm-msg {
  font-size: 13px;
  color: #991B1B;
  font-weight: 500;
}

/* + Add button at the bottom of a category */
.md-add-btn {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px dashed var(--border);
  background: var(--surface);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  margin-top: 4px;
}
.md-add-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-lt);
}

/* Inline add form (Employment / Education / Funds / Rel) */
.md-form {
  margin-top: 8px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.md-form-row {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}
.md-form-row.two { grid-template-columns: 1fr 1fr; }
.md-period-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}
.md-period-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.md-period-group > label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.md-period-inputs { display: flex; gap: 6px; }
.md-period-inputs select,
.md-period-inputs input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 13px;
  background: #fff;
  font-family: inherit;
}
.md-period-present {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 8px;
  white-space: nowrap;
}
.md-doc-checks {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  margin-bottom: 10px;
}
.md-doc-checks label {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 3px 0;
  font-size: 12.5px;
  cursor: pointer;
}

/* Situational items — show as cards with per-member rows */
.md-sit-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  background: #fff;
  overflow: hidden;
}
.md-sit-card.has-members { border-color: #BBF7D0; background: #F0FDF4; }
.md-sit-head {
  padding: 11px 14px 8px;
}
.md-sit-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.md-sit-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.md-sit-docs-list {
  padding: 6px 14px 10px;
  font-size: 11px;
  color: var(--muted);
}
.md-sit-docs-list .doc-bullet {
  display: block;
  padding: 1px 0 1px 12px;
  position: relative;
}
.md-sit-docs-list .doc-bullet::before {
  content: '·';
  position: absolute;
  left: 4px;
}
.md-sit-members {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  background: rgba(255,255,255,0.7);
}
.md-sit-card.has-members .md-sit-members { border-top-color: #BBF7D0; }
.md-sit-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 12.5px;
}
.md-sit-member-row.confirm-remove {
  background: #FEF2F2;
  border-radius: 5px;
  padding: 6px 8px;
  margin: 2px -8px;
}
.md-sit-add-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.md-sit-add-row select {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 12.5px;
  background: #fff;
}

.md-footer {
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 800px) {
  .md-body { grid-template-columns: 160px 1fr; }
  .md-period-row { grid-template-columns: 1fr 1fr; }
  .md-period-present { grid-column: 1 / -1; padding-bottom: 0; }
}

/* =========================================================================
 * SETTINGS — two-panel layout (new) + legacy set-tab compatibility
 * ========================================================================= */
.settings-wrap {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  min-height: calc(100vh - var(--topbar-h) - 40px);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.settings-sidenav {
  border-right: 1px solid var(--border);
  padding: 8px;
  background: var(--white);
}
.settings-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 10px 4px;
}
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  transition: all 0.15s;
  margin-bottom: 1px;
}
.settings-nav-item:hover { background: var(--surface); color: var(--text); }
.settings-nav-item.active { background: var(--blue-lt); color: var(--blue); font-weight: 500; }
.settings-content {
  padding: 20px 24px;
  background: var(--surface);
}
.settings-panel { display: none; }
.settings-panel.active { display: block; }

/* Horizontal sub-tab strip inside a settings panel (e.g. LOD → Programs / Doc Library). */
.settings-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: -4px 0 16px;
  flex-wrap: wrap;
}
.settings-tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.settings-subpanel { display: none; }
.settings-subpanel.active { display: block; }

/* Legacy set-tab buttons — kept for any HTML that still uses them */
.set-tab {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.set-tab:hover { color: var(--blue); }
.set-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 500; }
.set-tab-content { display: block; }

/* =========================================================================
 * UCL APPLICATION-CARD BADGES
 * ========================================================================= */
.ucl-badge        { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; margin-right: 4px; }
.ucl-badge-lod    { background: var(--blue-lt);   color: var(--blue); }
.ucl-badge-quote  { background: var(--orange-lt); color: var(--orange); }
.ucl-badge-college{ background: var(--green-lt);  color: var(--green); }

/* =========================================================================
 * COMBOBOX (searchable dropdown — see js/combobox.js)
 * ========================================================================= */
.combobox {
  position: relative;
  display: inline-block;
  min-width: 280px;
  font-family: inherit;
}
.combo-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 30px 8px 11px;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s;
}
.combo-input:focus {
  outline: none;
  border-color: var(--blue);
  cursor: text;
}
.combo-caret {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: auto;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
  padding: 2px 4px;
}
.combobox.open .combo-caret { transform: translateY(-50%) rotate(180deg); }
.combo-list {
  display: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 320px;
  overflow-y: auto;
  z-index: 60;
  box-shadow: 0 6px 18px rgba(0,0,0,0.10);
}
.combobox.open .combo-list { display: block; }
.combo-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--surface);
  transition: background 0.1s;
}
.combo-option:last-child { border-bottom: none; }
.combo-option:hover,
.combo-option.active {
  background: var(--blue-lt);
  color: var(--blue);
}
.combo-option .combo-label    { font-weight: 500; }
.combo-option .combo-sublabel { font-size: 11px; color: var(--muted); margin-top: 2px; }
.combo-option:hover .combo-sublabel,
.combo-option.active .combo-sublabel { color: var(--blue); opacity: 0.75; }
.combo-empty {
  padding: 14px 12px;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

/* =========================================================================
 * MANAGE DOCS modal helper
 * ========================================================================= */
.md-category { transition: box-shadow 0.15s; }
.md-category:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

/* Sidebar backdrop — hidden on desktop, only visible on mobile when the
 * sidebar is opened via the hamburger. */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 45, 94, 0.45);
  z-index: 95;
  backdrop-filter: blur(2px);
}

/* =========================================================================
 * MOBILE — tablet (≤ 768 px) baseline. Desktop layout above is untouched.
 * Focus is on LOD Manager + Clients, but global structural pieces (sidebar,
 * topbar, page padding, modals, grids) get a single consistent treatment.
 * ========================================================================= */
@media (max-width: 768px) {

  /* Sidebar slides in over content rather than pushing it. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
    z-index: 100;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  /* The desktop .collapsed mechanism is a no-op on mobile — the sidebar
   * is always off-screen unless .mobile-open is set. */
  .sidebar.collapsed { transform: translateX(-100%); width: 240px; }
  .sidebar-backdrop.show { display: block; }

  /* Main area takes the full width — no margin/padding for the sidebar. */
  .main-area, #appShell { width: 100%; }

  /* Topbar tightening. */
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar-title { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .topbar-user { display: none; } /* name is also in sidebar footer */

  /* Pages have less horizontal padding. */
  .page { padding: 12px 12px 24px; }

  /* Cards a touch tighter. */
  .card { padding: 14px 14px; margin-bottom: 12px; }

  /* Field grids stack to one column. */
  .fg2, .fg3 { grid-template-columns: 1fr; }

  /* Button rows wrap and breathe. */
  .btn-row { flex-wrap: wrap; gap: 8px; }
  .btn-row .btn { flex: 1 1 auto; min-width: 0; }

  /* ── LOD info strip (Client · File · Application · Retainer · Prepared By)
   * Stacks to two columns on tablets; one on very narrow screens via the
   * sub-breakpoint below. */
  .lod-info-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .lod-people-row { grid-template-columns: 1fr; gap: 12px; }
  .lod-people-actions { align-self: start; }
  .lod-people-actions .btn { width: 100%; }

  /* ── LOD Document Checklist file picker + action row ────────────────────
   * Currently a flex row with title + combobox + 4 buttons. On phones it
   * needs to stack and the buttons should fit. */
  #pg-cl > div:first-child {
    flex-direction: column;
    align-items: stretch;
  }
  #pg-cl > div:first-child > div:last-child {
    flex-wrap: wrap;
    gap: 6px;
  }
  #pg-cl > div:first-child .combobox { width: 100%; }

  /* ── LOD Checklist table ───────────────────────────────────────────────
   * Hide the drag handle and the "#" number columns on phones — drag-to-reorder
   * isn't a phone interaction anyway, and the row number is decorative.
   * Tighten everything else so the row fits without horizontal scroll. */
  .cl-tbl thead th:nth-child(1),
  .cl-tbl thead th:nth-child(2),
  .cl-tbl tr.doc-row td:nth-child(1),
  .cl-tbl tr.doc-row td:nth-child(2) { display: none; }
  .cl-tbl { font-size: 12px; }
  .cl-tbl td, .cl-tbl th { padding: 7px 6px; }
  /* The "Member" badge column was a fixed 100 px; let it shrink. */
  .cl-tbl th:nth-child(4) { width: auto; }
  /* Status select column was 172 px — too greedy on phones. */
  .cl-tbl th:nth-child(5) { width: 120px; }
  .cl-tbl .ssel { font-size: 11px; padding: 4px 18px 4px 6px; }
  .cl-tbl .mem-badge { font-size: 10px; padding: 2px 5px; }

  /* Stats row across the top of the checklist — tighten. */
  .stat-bar { gap: 6px; flex-wrap: wrap; }
  .stat-bar .stat { padding: 8px 6px; min-width: 0; flex: 1 1 30%; }
  .stat-bar .stat-n { font-size: 18px; }
  .stat-bar .stat-l { font-size: 10px; }

  /* ── Clients page (list + profile) ─────────────────────────────────────
   * Profile cards are already cards; just ensure they stack. The list rows
   * inside #uclListWrap render via JS — we keep them in flow. */
  #uclListView > div:first-child { flex-wrap: wrap; gap: 8px; }
  #uclListView > div:first-child > button { width: 100%; }

  /* ── Modals: every overlay modal becomes nearly full-width with margin.
   * Inline width:NNNpx attributes on individual modals are overridden. */
  .modal,
  .overlay > .modal,
  .overlay > .modal[style] {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    padding: 18px 18px !important;
    max-height: calc(100vh - 24px) !important;
  }

  /* ── Manage Documents modal — stack the two-pane vertically. */
  .md-modal {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100vh - 16px);
  }
  .md-body { grid-template-columns: 1fr; }
  .md-nav {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 38vh;
  }
  .md-nav-item { padding: 8px 14px; }
  .md-content { padding: 14px 16px; }
  .md-period-row { grid-template-columns: 1fr 1fr; }
  .md-period-present { grid-column: 1 / -1; padding-bottom: 0; }

  /* Settings: drop to one column — sidenav scrolls horizontally as a chip strip. */
  .settings-wrap { grid-template-columns: 1fr; min-height: auto; }
  .settings-sidenav {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 8px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    gap: 4px;
  }
  .settings-sidenav .settings-section-label { display: none; }
  .settings-sidenav .settings-nav-item {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 12px;
    margin-bottom: 0;
  }
  .settings-content { padding: 14px 16px; }
  .settings-tabs { gap: 0; overflow-x: auto; flex-wrap: nowrap; }
  .settings-tab { white-space: nowrap; flex-shrink: 0; }

  /* Landing + login screens — both are position:fixed with align-items:center.
   * On phones the module cards stack into a tall column that overflows the
   * viewport, but a fixed flex container can't scroll. Top-align and let
   * the container itself scroll. */
  #landingScreen,
  #loginScreen {
    align-items: flex-start !important;
    overflow-y: auto !important;
    padding: 20px 12px !important;
    -webkit-overflow-scrolling: touch;
  }
  /* The landing screen's "Clients" panel has 4 children on one row (icon,
   * label, Existing Clients btn, + New Client btn) that push past 375 px.
   * Let them wrap; buttons go full-width on a second row. */
  .land-clients-row {
    flex-wrap: wrap !important;
    justify-content: center;
    gap: 8px !important;
    padding: 16px !important;
  }
  .land-clients-row > div:first-of-type { flex: 1 1 auto; }
  .land-clients-row button { flex: 1 1 calc(50% - 4px); min-width: 130px; }
  /* Module-picker cards — full-row width on phones instead of fixed 220 px. */
  .land-card {
    width: 100% !important;
    max-width: 360px;
    padding: 22px 24px !important;
  }

  /* Settings tabs strip needs its parents to allow horizontal overflow
   * inside themselves rather than expanding to fit. min-width: 0 unlocks
   * shrinking; the strip's own overflow-x: auto then scrolls internally. */
  .settings-content,
  .settings-panel,
  .settings-panel > .settings-tabs { min-width: 0; max-width: 100%; }
  .settings-tabs {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    /* Slim horizontal scrollbar to hint that scrolling is possible. */
    scrollbar-width: thin;
  }
  .settings-tabs::-webkit-scrollbar { height: 4px; }
  .settings-tabs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
}

/* Phone-specific tightening (≤ 480 px). */
@media (max-width: 480px) {
  .lod-info-grid { grid-template-columns: 1fr; gap: 10px; }
  .lod-info-card { padding: 12px 14px; }

  /* On the smallest screens, also drop the Notes column from the checklist —
   * users can still tap to edit a note via the row, and recovering this width
   * makes Document + Member + Status + delete legible. */
  .cl-tbl thead th:nth-child(6),
  .cl-tbl tr.doc-row td:nth-child(6) { display: none; }
  .cl-tbl th:nth-child(5) { width: 110px; }

  /* Stats: two per row to keep numbers readable. */
  .stat-bar .stat { flex: 1 1 45%; }

  /* Page padding even tighter. */
  .page { padding: 10px 8px 20px; }
  .card { padding: 12px; }

  /* Buttons — full-width by default so they're easy to tap. */
  .btn { padding: 9px 12px; font-size: 13px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; }
}

/* =========================================================================
 * PRINT — preserved exactly so PDF previews keep working
 * ========================================================================= */
@media print {
  /* Page background: white, no margins on the body (the @page handles them). */
  html, body { background: white !important; margin: 0 !important; }

  /* Free the shell from height:100vh + overflow:hidden so the print-mode
     position:absolute sheets aren't clipped to one screen worth of space.
     Don't touch .page display — the per-mode rules below handle that. */
  #appShell, .main-area, .pages-wrap {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  /* Hide the new chrome + any opt-out elements before the global hide. */
  .sidebar, .topbar, .no-print, .ca-no-print, .pr-no-print { display: none !important; }

  /* Hide everything; per-mode rules below restore what's needed. */
  body * { visibility: hidden !important; }

  /* LOD Client View — print the cvSheet inside #pg-cv */
  body.print-lod #pg-cv { display: block !important; position: static !important; }
  body.print-lod #cvSheet,
  body.print-lod #cvSheet * { visibility: visible !important; }
  body.print-lod #cvSheet {
    position: absolute !important;
    top: 0 !important; left: 0 !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    padding: 22px 28px !important;
  }

  /* College Advisor — print the caPrintArea block inside #pg-ca-detail */
  body.print-college #pg-ca-detail { display: block !important; }
  body.print-college #caPrintArea,
  body.print-college #caPrintArea * { visibility: visible !important; }
  body.print-college #caPrintArea {
    position: absolute !important;
    top: 0 !important; left: 0 !important;
    width: 100% !important;
    display: block !important;
  }

  /* Pricing — print the prQuotePrint block */
  body.print-pricing #pg-pricing { display: block !important; }
  body.print-pricing #prQuotePrint,
  body.print-pricing #prQuotePrint * { visibility: visible !important; }
  body.print-pricing #prQuotePrint {
    position: absolute !important;
    top: 0 !important; left: 0 !important;
    width: 100% !important;
  }

  /* Page-break controls */
  .cv-tbl       { page-break-inside: auto; }
  .cv-tbl tr    { page-break-inside: avoid; }
  .ca-print-prog{ page-break-inside: avoid; }
}
