/* ==========================================================
   billWright app — design system + shell + components
   Drop-in vanilla CSS. White-label via --accent + --logo-url.
   ========================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Tenant-overridable accent (default = billWright forest green) */
  --accent: #1F7A3D;
  --accent-deep: #15532A;
  --accent-soft: #E6EFE7;
  --accent-darker: #0F3D1F;

  /* Neutrals */
  --ink: #1A1A1A;
  --ink-soft: #2D2D2A;
  --muted: #6B6862;
  --cream: #ECEAE3;
  --cream-deep: #E4E1D7;
  --surface: #FFFFFF;
  --surface-2: #FBFAF5;
  --hair: #DDD8CB;
  --hair-strong: #C7C1B0;

  /* Signal */
  --red: #B23A2F;
  --red-soft: #FCEFEE;
  --amber: #B68B1E;
  --amber-soft: #FAF1DC;
  --blue: #2A6FDB;
  --blue-soft: #E5EEFB;

  /* Type */
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  /* Geom */
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 0 rgba(20,20,20,.04), 0 14px 30px -22px rgba(20,20,20,.18);
  --shadow-pop: 0 1px 0 rgba(20,20,20,.05), 0 30px 70px -28px rgba(20,20,20,.4);

  --sidebar-w: 240px;
  --sidebar-collapsed-w: 64px;
  --topbar-h: 60px;
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--cream);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 700; letter-spacing: -0.018em; line-height: 1.18; }
p { margin: 0; }
img { max-width: 100%; display: block; }
.mono { font-family: var(--mono); }
.serif-it { font-family: var(--serif); font-style: italic; font-weight: 400; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ==========================================================
   APP SHELL — sidebar + topbar + content
   ========================================================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
  transition: grid-template-columns .25s ease;
}
.app.collapsed { grid-template-columns: var(--sidebar-collapsed-w) minmax(0, 1fr); }

/* ---------- Sidebar ---------- */
.sidebar {
  grid-area: sidebar;
  background: var(--ink);
  color: #ECEAE3;
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 20;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 14px;
  position: relative;
}
.sidebar .brand .logo {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 6px;
  background: var(--logo-url, none) center/contain no-repeat, var(--accent);
  display: grid; place-items: center;
  color: #fff; font-family: var(--serif); font-style: italic; font-size: 18px;
  text-transform: lowercase;
}
.sidebar .brand .logo[data-letter]::after {
  content: attr(data-letter);
  font-family: var(--serif); font-style: italic;
}
.sidebar .brand .biz {
  display: flex; flex-direction: column; min-width: 0;
}
.sidebar .brand .biz b {
  font-weight: 700; font-size: 14px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar .brand .biz span {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  color: #8C887E; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app.collapsed .sidebar .brand .biz { display: none; }
.app.collapsed .sidebar .brand { padding: 18px 0 14px; justify-content: center; }
.app.collapsed .sidebar .collapse-btn { justify-content: center; padding: 14px 0; }

.sidebar nav {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 12px 14px;
  /* Themed scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #3a3a37 transparent;
}
.sidebar nav::-webkit-scrollbar { width: 8px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav::-webkit-scrollbar-thumb {
  background: #2a2a27;
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.sidebar nav::-webkit-scrollbar-thumb:hover { background: #3a3a37; background-clip: padding-box; border: 2px solid transparent; }
.nav-group {
  margin-top: 18px;
}
.nav-group:first-child { margin-top: 6px; }
.nav-group .label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .14em;
  color: #6B6862; text-transform: uppercase;
  padding: 6px 12px 8px;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.nav-group .label:hover { color: #ECEAE3; background: rgba(255,255,255,.03); }
.nav-group .label::after {
  content: "";
  width: 5px; height: 5px; flex: 0 0 5px;
  margin-left: auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform .2s ease, opacity .15s;
  opacity: .55;
}
.nav-group .label:hover::after { opacity: 1; }
.nav-group.collapsed .label::after { transform: rotate(-45deg) translate(1px, 1px); }
.nav-group .nav-items {
  display: flex; flex-direction: column;
  overflow: hidden;
  max-height: 1000px;
  transition: max-height .25s ease;
}
.nav-group.collapsed .nav-items {
  max-height: 0;
}
.app.collapsed .nav-group .label { opacity: 0; pointer-events: none; height: 0; padding: 0; }
.app.collapsed .nav-group .nav-items { max-height: none; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  color: #C7C1B0;
  font-weight: 500; font-size: 13.5px;
  position: relative;
  transition: background .15s ease, color .15s ease;
  white-space: nowrap;
}
.nav-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-link:focus-visible { outline: none; background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active {
  background: rgba(31,122,61,.15);
  color: #fff;
}
.nav-link.active::before {
  content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 3px;
  background: var(--accent); border-radius: 3px;
}
.nav-link .ic {
  width: 18px; height: 18px; flex: 0 0 18px;
  stroke: currentColor; fill: none; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: .9;
}
.nav-link .badge {
  margin-left: auto;
  background: var(--accent); color: #fff;
  font-family: var(--mono); font-size: 10px; padding: 1px 6px; border-radius: 999px;
  font-weight: 600; letter-spacing: .04em;
}
.app.collapsed .nav-link .lbl,
.app.collapsed .nav-link .badge { display: none; }
.app.collapsed .nav-link { justify-content: center; }

.sidebar .collapse-btn {
  background: transparent; border: 0; color: #8C887E;
  padding: 14px 20px; text-align: left; font-size: 12px;
  font-family: var(--mono); letter-spacing: .1em; text-transform: uppercase;
  border-top: 1px solid #2a2a27;
  display: flex; align-items: center; gap: 10px;
  transition: color .15s ease;
}
.sidebar .collapse-btn:hover { color: #fff; }
.app.collapsed .collapse-btn .lbl { display: none; }
.collapse-btn svg { transition: transform .2s ease; }
.app.collapsed .collapse-btn svg { transform: rotate(180deg); }

/* ---------- Topbar ---------- */
.topbar {
  grid-area: topbar;
  background: rgba(236,234,227,0.92);
  backdrop-filter: blur(8px) saturate(1.2);
  border-bottom: 1px solid var(--hair);
  display: flex; align-items: center; gap: 18px;
  padding: 0 22px; position: sticky; top: 0; z-index: 15;
}
.topbar .crumbs {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  letter-spacing: .04em;
}
.topbar .crumbs b { color: var(--ink); font-weight: 500; }
.topbar .crumbs .sep { opacity: .4; }

.week-pill {
  display: inline-flex; align-items: center; gap: 0;
  border: 1px solid var(--hair); border-radius: 999px;
  background: var(--surface); margin-left: 14px;
  overflow: hidden;
}
.week-pill button {
  background: transparent; border: 0; padding: 6px 10px; color: var(--muted);
  transition: background .15s, color .15s;
}
.week-pill button:hover { background: var(--cream); color: var(--ink); }
.week-pill .val {
  padding: 6px 14px; font-family: var(--mono); font-size: 12px; font-weight: 500;
  color: var(--ink); border-left: 1px solid var(--hair); border-right: 1px solid var(--hair);
  cursor: pointer;
  white-space: nowrap;
}
.week-pill .val .small { color: var(--muted); font-size: 10px; margin-left: 6px; letter-spacing: .08em; }

.topbar .spacer { flex: 1; }

.topbar .search {
  position: relative;
  width: 320px; max-width: 36vw;
}
.topbar .search input {
  width: 100%; background: var(--surface); border: 1px solid var(--hair);
  border-radius: 999px; padding: 8px 14px 8px 36px;
  font-size: 13px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.topbar .search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,122,61,.12); }
.topbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar .search .kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  border: 1px solid var(--hair); border-radius: 4px; padding: 1px 5px;
  background: var(--cream);
}

.topbar .acct {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--hair); border-radius: 999px;
  background: var(--surface); padding: 4px 10px 4px 4px;
  cursor: pointer; position: relative;
  transition: border-color .15s, background .15s;
}
.topbar .acct:hover { border-color: var(--accent); }
.topbar .acct .av {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
}
.topbar .acct .nm { font-size: 13px; font-weight: 600; }
.topbar .acct .car { color: var(--muted); }

.acct-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--hair); border-radius: 12px;
  box-shadow: var(--shadow-pop);
  min-width: 220px; padding: 6px; z-index: 30;
  display: none;
}
.acct-menu.open { display: block; }
.acct-menu a, .acct-menu button {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 0; background: transparent;
  width: 100%; text-align: left; color: var(--ink); border-radius: 8px;
  font-size: 13.5px;
}
.acct-menu a:hover, .acct-menu button:hover { background: var(--cream); }
.acct-menu .sep { height: 1px; background: var(--hair); margin: 4px 6px; }
.acct-menu .who {
  padding: 8px 10px 10px; border-bottom: 1px solid var(--hair); margin-bottom: 4px;
}
.acct-menu .who b { display: block; font-weight: 700; }
.acct-menu .who span { color: var(--muted); font-size: 12px; }

/* ---------- Main ---------- */
.main {
  grid-area: main;
  padding: 26px 32px 60px;
  min-width: 0;
  overflow-x: hidden;
}
@media (max-width: 880px) {
  .main { padding: 18px 16px 60px; }
}

/* Mobile: sidebar slides over */
@media (max-width: 880px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "topbar" "main"; }
  .sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .25s ease; }
  .app.mobile-open .sidebar { transform: none; }
  .mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 19; }
  .app.mobile-open .mobile-overlay { display: block; }
  .topbar .hamb { display: inline-flex; }
}
.topbar .hamb { display: none; background: transparent; border: 0; padding: 6px; color: var(--ink); margin-right: 6px; }

/* ==========================================================
   SCREEN HEAD + COMMON
   ========================================================== */
.screen-head {
  display: flex; align-items: end; justify-content: space-between; gap: 24px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.screen-head h1 {
  font-size: 28px; letter-spacing: -0.022em;
}
.screen-head h1 .accent { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--accent-deep); }
.screen-head .sub { color: var(--muted); margin-top: 4px; font-size: 14px; max-width: 580px; }
.screen-head .head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Section card */
.card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hair);
  background: var(--surface-2);
}
.card-head h3 { font-size: 15px; font-weight: 700; letter-spacing: -0.005em; }
.card-head .meta { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .06em; }
.card-body { padding: 20px; }

/* Two-col grid helpers */
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1100px) { .row-4 { grid-template-columns: repeat(2, 1fr); } .row-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .row-2, .row-3, .row-4 { grid-template-columns: 1fr; } }

/* ==========================================================
   BUTTONS
   ========================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px;
  transition: background .15s, border-color .15s, color .15s, transform .12s;
  white-space: nowrap;
  background: transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-darker); }
.btn-primary:disabled { background: var(--hair-strong); cursor: not-allowed; }
.btn-ghost { color: var(--ink); border-color: var(--hair-strong); background: var(--surface); }
.btn-ghost:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-quiet { color: var(--ink-soft); }
.btn-quiet:hover { background: var(--cream); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #8E2C24; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-lg { padding: 11px 18px; font-size: 14.5px; }
.btn .ic { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.btn .spin {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1.6px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================
   KPI tile
   ========================================================== */
.kpi {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color .15s ease, transform .15s ease;
}
.kpi:hover { border-color: var(--hair-strong); transform: translateY(-1px); }
.kpi .lbl {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
.kpi .val {
  font-size: 30px; font-weight: 800; letter-spacing: -0.025em; margin-top: 6px;
  font-family: var(--mono); color: var(--ink);
}
.kpi .val small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.kpi .delta { margin-top: 4px; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.kpi .delta.up { color: var(--accent-deep); }
.kpi .delta.dn { color: var(--red); }
.kpi .accent-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--accent);
}
.kpi.accent-warn .accent-bar { background: var(--amber); }
.kpi.accent-red .accent-bar { background: var(--red); }

/* Job-detail linked rows (invoices / expenses) */
.jd-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; border-bottom: 1px solid var(--hair); cursor: pointer;
  transition: background .12s ease;
}
.jd-row:last-child { border-bottom: 0; }
.jd-row:hover { background: var(--surface-2); }
.jd-row > :first-child { flex: 1; min-width: 0; }
.jd-row .pill { flex: 0 0 auto; }

/* ==========================================================
   REPORTS HUB — Profit by job / Cash flow / Tax estimate
   ========================================================== */
.rep-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--hair); }

.rep-tbl { width: 100%; border-collapse: collapse; }
.rep-tbl thead th {
  text-align: left; padding: 11px 16px; font-family: var(--mono);
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--hair); font-weight: 600; white-space: nowrap;
}
.rep-tbl thead th.num { text-align: right; }
.rep-tbl tbody td { padding: 12px 16px; border-bottom: 1px solid var(--hair); font-size: 13.5px; vertical-align: top; }
.rep-tbl tbody td.num { text-align: right; vertical-align: middle; }
.rep-tbl tbody tr:hover { background: var(--surface-2); }
.rep-tbl tfoot td { padding: 13px 16px; font-size: 13.5px; border-top: 2px solid var(--hair-strong); }
.rep-tbl tfoot td.num { text-align: right; }
.rep-tbl .rep-total { background: var(--surface-2); }

/* revenue-vs-cost mini bar under each job name */
.rep-bar { display: flex; gap: 2px; margin-top: 7px; height: 5px; max-width: 220px; }
.rep-bar span { border-radius: 2px; min-width: 2px; }
.rep-bar .rep-bar-rev { background: var(--accent); }
.rep-bar .rep-bar-cost { background: var(--amber); }

/* cash-flow chart */
.cf-chart {
  display: flex; align-items: flex-end; gap: 10px; height: 200px;
  padding: 8px 4px 0; border-bottom: 1px solid var(--hair); margin-bottom: 12px;
}
.cf-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0; height: 100%; }
.cf-bars { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.cf-bars span { width: 38%; max-width: 22px; border-radius: 3px 3px 0 0; min-height: 2px; }
.cf-in { background: var(--accent); }
.cf-out { background: var(--amber); }
.cf-x { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: 8px; text-transform: uppercase; letter-spacing: .04em; }
.cf-run { font-size: 11px; font-weight: 700; margin-top: 3px; color: var(--ink); }
.cf-run.neg { color: var(--red); }
.cf-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--ink-soft); align-items: center; }
.cf-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* cash-flow trend chart (running balance, green↑ / red↓) */
.cf-trend { width: 100%; height: auto; max-height: 280px; display: block; margin-bottom: 12px; }
.cf-trend .cf-axis { font-family: var(--mono); font-size: 10.5px; fill: var(--muted); }
.cf-trend .cf-pt { font-family: var(--mono); font-size: 11px; font-weight: 700; }

/* ==========================================================
   MATERIAL TRENDS (Insights) — cards grid
   ========================================================== */
.mat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px; margin-top: 20px;
}
.mat-card {
  background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius-lg);
  padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.mat-card:hover { border-color: var(--hair-strong); box-shadow: var(--shadow-card); }
.mat-card.watched { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,122,61,.08); }
.mat-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.mat-name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.mat-spec { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.mat-watch { background: none; border: 0; cursor: pointer; color: var(--hair-strong); padding: 2px; line-height: 0; flex: 0 0 auto; transition: color .12s, transform .12s; }
.mat-watch svg { width: 18px; height: 18px; }
.mat-watch:hover { color: var(--amber); transform: scale(1.1); }
.mat-watch.on { color: var(--amber); }

.mat-price-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.mat-price { font-family: var(--mono); font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.mat-delta { font-size: 12px; margin-top: 3px; }
.mat-delta .mono { font-weight: 700; }
.mat-delta.up .mono { color: var(--amber); }
.mat-delta.down .mono { color: var(--accent-deep); }
.mat-delta.flat .mono { color: var(--muted); }
.mat-lean { flex: 0 0 auto; margin-top: 4px; }

.mat-chart { width: 100%; height: auto; display: block; }

.mat-reason { font-size: 12.5px; line-height: 1.5; color: var(--ink-soft); }

.mat-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 1px solid var(--hair); flex-wrap: wrap; }
.mat-conf { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.mat-conf-bar { display: inline-block; width: 46px; height: 5px; border-radius: 3px; background: var(--cream); overflow: hidden; }
.mat-conf-bar > span { display: block; height: 100%; border-radius: 3px; }
.mat-meta { font-size: 10.5px; color: var(--muted); text-align: right; }

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

/* ==========================================================
   ESTIMATING — runner + builder
   ========================================================== */
/* runner */
.est-pickrow { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.est-pick-lbl { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.est-pick { background: var(--surface); border: 1px solid var(--hair); border-radius: 8px; padding: 9px 12px; font-size: 14px; font-weight: 600; min-width: 240px; }
.est-pick:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,122,61,.12); }

.est-grid { display: grid; grid-template-columns: 1fr 400px; gap: 24px; align-items: start; }
.est-out { position: sticky; top: 16px; }

.est-break .est-sub-h { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 4px 0 8px; }
.est-break .est-sub-h:not(:first-child) { margin-top: 16px; }
.est-rows { display: grid; gap: 0; }
.est-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--hair); font-size: 13.5px; }
.est-row:last-child { border-bottom: 0; }
.est-row.qty { color: var(--muted); }
.est-row.qty .est-row-v { font-size: 12.5px; }
.est-row.err .est-row-v { color: var(--red); font-size: 12px; font-family: var(--mono); text-align: right; }
.est-row-l { min-width: 0; }
.est-u { color: var(--muted); font-size: 11px; }
.est-totals { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hair); display: grid; gap: 8px; }
.est-trow { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; }
.est-trow.muted { color: var(--muted); font-size: 12.5px; }
.est-trow.est-total { padding-top: 10px; margin-top: 2px; border-top: 1px solid var(--hair); font-size: 16px; font-weight: 700; }
.est-trow.est-total .mono { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.est-calib { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--hair); line-height: 1.5; }
.est-actions { margin-top: 16px; }
.est-toggle { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.est-toggle input { width: 16px; height: 16px; accent-color: var(--accent); }

/* builder */
.cb-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--hair); cursor: pointer; transition: background .12s; }
.cb-row:last-child { border-bottom: 0; }
.cb-row:hover { background: var(--surface-2); }
.cb-row > :first-child { flex: 1; min-width: 0; }
.cb-row-meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.cb-row-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.cb-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.cb-template { text-align: left; background: var(--surface-2); border: 1px solid var(--hair); border-radius: var(--radius); padding: 14px; cursor: pointer; transition: border-color .12s, transform .12s; }
.cb-template:hover { border-color: var(--accent); transform: translateY(-1px); }
.cb-template-name { font-weight: 700; font-size: 13.5px; }
.cb-template-desc { color: var(--muted); font-size: 12px; margin: 4px 0 8px; line-height: 1.4; }
.cb-template-meta { font-size: 10.5px; color: var(--muted); }

.cb-grid { display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start; }
.cb-preview { position: sticky; top: 16px; }
.cb-preview-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }

.cb-item { position: relative; padding: 12px 14px; border: 1px solid var(--hair); border-radius: var(--radius); margin-bottom: 10px; background: var(--surface); }
.cb-item:last-child { margin-bottom: 0; }
.cb-item.has-err { border-color: var(--red); background: var(--red-soft); }
.cb-item-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr .8fr .8fr; gap: 10px; }
.cb-formula-grid { display: grid; grid-template-columns: 1.4fr 1fr auto auto; gap: 10px; align-items: end; }
.cb-item .field { margin-bottom: 0; }
.cb-item .field label { font-size: 10.5px; }
.cb-item .field input, .cb-item .field select {
  background: var(--surface-2); border: 1px solid var(--hair); border-radius: 8px;
}
.cb-item .field input:focus, .cb-item .field select:focus {
  border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px rgba(31,122,61,.12);
}
.cb-item .field input, .cb-item .field select { padding: 7px 9px; font-size: 12.5px; }
.cb-expr-field { margin-top: 10px; }
.cb-expr { font-size: 13px !important; }
.cb-rm { position: absolute; top: 8px; right: 8px; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 5px; line-height: 0; }
.cb-rm:hover:not(:disabled) { color: var(--red); background: var(--surface); }
.cb-rm:disabled { opacity: .3; cursor: not-allowed; }
.cb-rm.sm { position: static; padding: 2px; }
.cb-row-tools { display: flex; gap: 4px; position: absolute; top: 8px; right: 8px; }
.cb-mv { background: none; border: 1px solid var(--hair); color: var(--muted); cursor: pointer; width: 22px; height: 22px; border-radius: 5px; font-size: 12px; line-height: 1; }
.cb-mv:hover:not(:disabled) { color: var(--ink); border-color: var(--hair-strong); }
.cb-mv:disabled { opacity: .3; cursor: not-allowed; }
.cb-row-tools + .cb-err { margin-right: 70px; }

.cb-opts { margin-top: 10px; padding: 10px; background: var(--surface); border: 1px solid var(--hair); border-radius: 8px; }
.cb-opts-h { font-size: 11px; color: var(--ink-soft); font-weight: 600; margin-bottom: 8px; }
.cb-opt-row { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; margin-bottom: 6px; align-items: center; }
.cb-opt-row input { padding: 6px 9px; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--hair); border-radius: 6px; }

.cb-err { color: var(--red); font-size: 11.5px; font-family: var(--mono); margin-top: 6px; line-height: 1.4; }
.cb-err:empty { display: none; }
.cb-err-block { padding: 0 18px 14px; margin-top: -4px; }
.cb-err-list { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.cb-err-list li { font-size: 12.5px; }

.seg-sm button { padding: 6px 12px; font-size: 12px; }

/* ---- price book ---- */
.pb-grid { display: grid; grid-template-columns: 1fr 360px; gap: 24px; align-items: start; }
.pb-cart { position: sticky; top: 16px; }
.pb-search { flex: 1; min-width: 160px; background: var(--surface-2); border: 1px solid var(--hair); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.pb-search:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px rgba(31,122,61,.12); }

.pb-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--hair); }
.pb-row:last-child { border-bottom: 0; }
.pb-row-main { flex: 1; min-width: 0; cursor: pointer; }
.pb-price { font-weight: 700; font-size: 14px; white-space: nowrap; }
.pb-unit { color: var(--muted); font-weight: 400; font-size: 11px; }
.pb-row-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.pb-cart-card .card-body { padding-top: 14px; }
.pb-cart-lines { display: grid; gap: 10px; }
.pb-cart-line { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding-bottom: 10px; border-bottom: 1px dashed var(--hair); }
.pb-cl-main { min-width: 0; }
.pb-cl-main b { font-size: 12.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-cl-amt { font-size: 13px; min-width: 56px; text-align: right; }
.pb-qty { display: flex; align-items: center; gap: 2px; }
.pb-qty button { width: 22px; height: 26px; border: 1px solid var(--hair); background: var(--surface-2); cursor: pointer; font-size: 14px; color: var(--ink-soft); }
.pb-qty button:first-child { border-radius: 6px 0 0 6px; }
.pb-qty button:last-child { border-radius: 0 6px 6px 0; }
.pb-qty button:hover { background: var(--cream); }
.pb-qty input { width: 42px; height: 26px; border: 1px solid var(--hair); border-left: 0; border-right: 0; text-align: center; font-family: var(--mono); font-size: 12px; background: var(--surface); }
.pb-totals { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hair); display: grid; gap: 7px; }
.pb-trow { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.pb-trow.muted { color: var(--muted); font-size: 12px; }
.pb-trow.pb-total { padding-top: 9px; margin-top: 2px; border-top: 1px solid var(--hair); font-size: 15px; font-weight: 700; }
.pb-trow.pb-total .mono { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }

@media (max-width: 1000px) {
  .pb-grid { grid-template-columns: 1fr; }
  .pb-cart { position: static; }
}

/* ---- service agreements ---- */
.ag-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--hair); cursor: pointer; transition: background .12s; }
.ag-row:last-child { border-bottom: 0; }
.ag-row:hover { background: var(--surface-2); }
.ag-row.lapsed { opacity: .6; }
.ag-row > :first-child { flex: 1; min-width: 0; }
.ag-chip { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-deep); white-space: nowrap; flex: 0 0 auto; }
.ag-chip.ghost { background: var(--surface-2); color: var(--muted); border: 1px solid var(--hair); }
.ag-val { text-align: right; min-width: 88px; flex: 0 0 auto; }
.ag-val b { font-size: 14px; }
.ag-next { font-size: 11.5px; color: var(--muted); min-width: 96px; text-align: right; flex: 0 0 auto; }
.ag-active { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; font-weight: 600; margin-top: 6px; }
.ag-active input { width: 16px; height: 16px; accent-color: var(--accent); }

.ag-preview { background: var(--surface-2); border: 1px solid var(--hair); border-radius: var(--radius-lg); padding: 16px; position: sticky; top: 0; }
.ag-pv-value { display: flex; flex-direction: column; gap: 2px; padding-bottom: 14px; margin-bottom: 12px; border-bottom: 1px solid var(--hair); }
.ag-pv-value .lbl { font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ag-pv-value b { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.ag-pv-value b small { font-size: 13px; color: var(--muted); font-weight: 500; }
.ag-pv-sec { margin-top: 12px; }
.ag-pv-h { font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 6px; }
.ag-pv-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; padding: 4px 0; border-bottom: 1px dashed var(--hair); }
.ag-pv-row:last-child { border-bottom: 0; }

@media (max-width: 760px) {
  .ag-row { flex-wrap: wrap; }
  .ag-preview { position: static; }
}

/* ---- lien waivers (legal-gated) ---- */
.lw-gate .ic { background: var(--red); }
.lw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.lw-side { position: sticky; top: 16px; }
.lw-preview-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.lw-draft-tag { font-family: var(--mono); font-size: 10px; font-weight: 800; letter-spacing: .14em; color: var(--red); border: 1.5px solid var(--red); border-radius: 5px; padding: 3px 8px; }
.lw-paper { position: relative; background: #fff; border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 32px 34px; overflow: hidden; }
.lw-watermark { position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%) rotate(-24deg); font-family: var(--mono); font-size: 84px; font-weight: 800; letter-spacing: .1em; color: rgba(178,58,47,.07); pointer-events: none; user-select: none; }
.lw-doc { font-family: var(--serif, Georgia), serif; color: var(--ink); position: relative; }
.lw-doc-title { font-size: 16px; font-weight: 700; text-align: center; text-transform: uppercase; letter-spacing: .02em; margin-bottom: 18px; line-height: 1.3; }
.lw-kv { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--hair); padding: 6px 0; font-family: var(--sans); font-size: 12.5px; }
.lw-kv span { color: var(--muted); }
.lw-kv b { text-align: right; }
.lw-p { font-size: 13.5px; margin: 12px 0; line-height: 1.6; }
.lw-p.lw-muted { color: var(--muted); font-size: 12px; }
.lw-sign { display: flex; gap: 30px; margin-top: 30px; font-family: var(--sans); font-size: 11px; color: var(--muted); }
.lw-sign > div { flex: 1; }
.lw-sign-line { border-bottom: 1px solid var(--ink); height: 30px; margin-bottom: 5px; }

@media (max-width: 1000px) {
  .lw-grid { grid-template-columns: 1fr; }
  .lw-side { position: static; }
}

/* ---- field media gallery + lightbox ---- */
.fm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.fm-tile { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.fm-thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--hair); }
.fm-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fm-ph { width: 100%; height: 100%; display: grid; place-items: center; background: color-mix(in srgb, var(--sw) 22%, var(--surface-2)); color: color-mix(in srgb, var(--sw) 70%, #000); }
.fm-ph svg { width: 34px; height: 34px; }
.fm-tile:hover .fm-thumb { border-color: var(--accent); }
.fm-badge { position: absolute; inset: 0; margin: auto; width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; font-size: 13px; }
.fm-geo { position: absolute; top: 5px; right: 5px; font-size: 12px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.fm-meta { display: flex; flex-direction: column; line-height: 1.3; }
.fm-meta b { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-meta .muted { font-size: 10.5px; }
.fm-empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 13px; }

.fm-lb { display: grid; grid-template-columns: 1fr 280px; gap: 22px; align-items: start; }
.fm-lb-media { display: grid; place-items: center; min-height: 240px; }
.fm-ph-lg { aspect-ratio: 4/3; width: 100%; border-radius: 10px; flex-direction: column; gap: 12px; }
.fm-ph-lg svg { width: 64px; height: 64px; }
.fm-ph-name { font-family: var(--mono); font-size: 11px; color: color-mix(in srgb, var(--sw) 80%, #000); }
.fm-lb-note { font-size: 14px; line-height: 1.5; margin-bottom: 14px; }
.fm-kv { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--hair); font-size: 12.5px; }
.fm-kv > span:first-child { color: var(--muted); flex: 0 0 auto; }
.fm-kv > span:last-child { text-align: right; }
@media (max-width: 720px) { .fm-lb { grid-template-columns: 1fr; } }

/* ---- crew locations (privacy-gated) ---- */
.cl-notice .ic { background: var(--blue); }
.cl-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.cl-filter button { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border: 1px solid var(--hair); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.cl-filter button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.cl-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.cl-grid { display: grid; grid-template-columns: 1fr 360px; gap: 24px; align-items: start; }
.cl-map { width: 100%; height: auto; display: block; border-radius: 12px; }
.cl-grid line { opacity: .5; }
.cl-pin circle { transition: r .1s; }
.cl-pin:hover circle:last-child { r: 7; }
.cl-maplegend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; align-items: center; }
.cl-maplegend span { display: inline-flex; align-items: center; gap: 6px; }
.cl-empty { padding: 28px 14px; text-align: center; color: var(--muted); font-size: 13px; }

.cl-last { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--hair); }
.cl-last:last-child { border-bottom: 0; }
.cl-av { width: 30px; height: 30px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; font-family: var(--mono); flex: 0 0 auto; }
.cl-last b { font-size: 13.5px; }
.cl-last-meta { font-size: 11.5px; color: var(--muted); }
.cl-badge { font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto; }
.cl-badge.on { background: var(--accent-soft); color: var(--accent-deep); }
.cl-badge.off { background: var(--surface-2); color: var(--muted); border: 1px solid var(--hair); }
.cl-maplink { color: var(--accent-deep); font-weight: 700; text-decoration: none; padding: 2px 6px; flex: 0 0 auto; }
.cl-hrow { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--hair); }
.cl-hrow:last-child { border-bottom: 0; }
.cl-kind { font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 5px; flex: 0 0 auto; text-transform: uppercase; letter-spacing: .04em; }
.cl-clock_in { background: var(--accent-soft); color: var(--accent-deep); }
.cl-clock_out { background: #E6EEF8; color: var(--blue); }
.cl-media { background: #F1ECF6; color: #7B4A99; }
@media (max-width: 1000px) { .cl-grid { grid-template-columns: 1fr; } }

@media (max-width: 1000px) {
  .est-grid, .cb-grid { grid-template-columns: 1fr; }
  .est-out, .cb-preview { position: static; }
  .cb-item-grid { grid-template-columns: 1fr 1fr; }
  .cb-formula-grid { grid-template-columns: 1fr 1fr; }
}

/* ==========================================================
   BACKUPS & EXPORT (Settings)
   ========================================================== */
.bk-promise .ic { background: var(--accent); }
.bk-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.bk-action .card-body { padding: 22px; }
.bk-action-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-deep); display: grid; place-items: center; margin-bottom: 14px; }
.bk-action-ic svg { width: 22px; height: 22px; }
.bk-action h3 { font-size: 16px; margin-bottom: 6px; }
.bk-action p { color: var(--muted); font-size: 13px; line-height: 1.5; margin-bottom: 16px; }

.bk-runline { display: flex; flex-wrap: wrap; gap: 18px; font-size: 13px; padding: 12px 0; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); margin: 4px 0 16px; }
.bk-offsite { display: grid; gap: 8px; }
.bk-toggle { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; font-weight: 600; }
.bk-toggle input { width: 16px; height: 16px; accent-color: var(--accent); }
.bk-offsite input[type=text] { width: 100%; background: var(--surface-2); border: 1px solid var(--hair); border-radius: 8px; padding: 9px 12px; font-size: 13px; font-family: var(--mono); }
.bk-offsite input[type=text]:disabled { opacity: .5; }
.bk-offsite input[type=text]:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px rgba(31,122,61,.12); }

.bk-cron { margin-top: 14px; padding: 14px; background: var(--ink); border-radius: var(--radius); }
.bk-cron .hint { color: rgba(255,255,255,.6); }
.bk-cron-row { display: flex; align-items: center; gap: 10px; }
.bk-cron-cmd { color: #E6EFE7; font-size: 12px; white-space: pre-wrap; flex: 1; line-height: 1.5; }
.bk-cron-row .mono { color: #E6EFE7; font-size: 12px; }

.bk-arch { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--hair); }
.bk-arch:last-child { border-bottom: 0; }
.bk-arch > :nth-child(2) { flex: 1; }
.bk-arch-ic { width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; flex: 0 0 auto; }
.bk-arch-ic svg { width: 16px; height: 16px; }
.bk-arch-ic.backup { background: var(--accent-soft); color: var(--accent-deep); }
.bk-arch-ic.export { background: #E6EEF8; color: var(--blue); }
.bk-arch-name { font-size: 12.5px; }
.bk-arch-actions { display: flex; gap: 6px; flex: 0 0 auto; }

@media (max-width: 720px) {
  .bk-actions { grid-template-columns: 1fr; }
  .bk-arch { flex-wrap: wrap; }
}

/* ==========================================================
   SCHEDULE & DISPATCH BOARD
   ========================================================== */
.sch-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 16px; font-size: 12px; }
.sch-legend-h { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.sch-legend-item { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-soft); }
.sch-legend-sw { width: 11px; height: 11px; border-radius: 3px; }

/* week grid */
.sch-week { display: grid; border: 1px solid var(--hair); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.sch-corner { background: var(--surface-2); border-bottom: 1px solid var(--hair); }
.sch-dayhead { background: var(--surface-2); border-bottom: 1px solid var(--hair); border-left: 1px solid var(--hair); padding: 9px 10px; display: flex; flex-direction: column; gap: 1px; }
.sch-dayhead .dn { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sch-dayhead .dd { font-size: 13px; font-weight: 700; }
.sch-dayhead.today { background: var(--accent-soft); }
.sch-dayhead.today .dd { color: var(--accent-deep); }

.sch-lanehead { display: flex; align-items: center; gap: 9px; padding: 10px; border-bottom: 1px solid var(--hair); background: var(--surface-2); }
.sch-lane-name { display: flex; flex-direction: column; line-height: 1.2; font-weight: 600; font-size: 13px; min-width: 0; }
.sch-lane-name small { font-weight: 400; color: var(--muted); font-size: 10.5px; }
.sch-lane-hrs { margin-left: auto; font-size: 11px; color: var(--muted); }
.sch-av { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 700; font-family: var(--mono); flex: 0 0 auto; }
.sch-av.sm { width: 20px; height: 20px; font-size: 8.5px; }

.sch-cell { border-bottom: 1px solid var(--hair); border-left: 1px solid var(--hair); padding: 5px; min-height: 62px; min-width: 0; display: flex; flex-direction: column; gap: 5px; cursor: pointer; transition: background .12s; }
.sch-cell:hover { background: var(--surface-2); }
.sch-cell.today { background: rgba(31,122,61,.035); }
.sch-cell.drop-hover { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }

/* block */
.sch-block { background: color-mix(in srgb, var(--c) 12%, white); border-left: 3px solid var(--c); border-radius: 6px; padding: 5px 8px; cursor: grab; transition: transform .1s, box-shadow .1s; }
.sch-block:hover { box-shadow: var(--shadow-card); transform: translateY(-1px); }
.sch-block.dragging { opacity: .4; }
.sch-block.conflict { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); background: color-mix(in srgb, var(--red) 9%, white); }
.sch-block-t { font-family: var(--mono); font-size: 10px; color: var(--ink-soft); font-weight: 600; }
.sch-block-job { font-size: 12px; font-weight: 700; line-height: 1.25; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sch-block-note { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sch-block-crew { font-family: var(--mono); font-size: 9.5px; color: var(--muted); margin-top: 2px; }
.sch-block.big { padding: 9px 12px; border-left-width: 4px; }
.sch-block.big .sch-block-t { font-size: 11.5px; }
.sch-block.big .sch-block-job { font-size: 14px; white-space: normal; }
.sch-block.big .sch-block-note { font-size: 12px; white-space: normal; }
.sch-bang { display: inline-grid; place-items: center; width: 13px; height: 13px; border-radius: 50%; background: var(--red); color: #fff; font-size: 9px; font-weight: 800; vertical-align: -1px; }

/* day view */
.sch-daypick { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.sch-daypill { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 14px; border: 1px solid var(--hair); border-radius: 10px; background: var(--surface); cursor: pointer; min-width: 52px; }
.sch-daypill span { font-family: var(--mono); font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sch-daypill b { font-size: 16px; }
.sch-daypill.on { background: var(--ink); border-color: var(--ink); }
.sch-daypill.on span { color: rgba(255,255,255,.6); }
.sch-daypill.on b { color: #fff; }
.sch-daypill.today:not(.on) { border-color: var(--accent); }
.sch-daypill.today:not(.on) b { color: var(--accent-deep); }

.sch-day { display: grid; gap: 12px; }
.sch-daylane { border: 1px solid var(--hair); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.sch-daylane-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--hair); }
.sch-daycell { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; min-height: 48px; cursor: pointer; }
.sch-daycell:hover { background: var(--surface-2); }
.sch-daycell.drop-hover { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.sch-empty { color: var(--muted); font-size: 12.5px; padding: 4px 0; }

/* editor modal */
.sch-form .field { margin-bottom: 14px; }
.sch-crew { display: flex; flex-wrap: wrap; gap: 8px; }
.sch-crew-opt { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px 6px 8px; border: 1px solid var(--hair); border-radius: 999px; cursor: pointer; font-size: 13px; background: var(--surface-2); }
.sch-crew-opt input { accent-color: var(--accent); }
.sch-crew-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.sch-times { display: flex; align-items: center; gap: 8px; }
.sch-times input { flex: 1; }
.sch-conflict-list { margin: 6px 0 6px; padding-left: 16px; display: grid; gap: 3px; }
.sch-conflict-list li { font-size: 12.5px; }
.sch-ok { display: flex; align-items: center; gap: 7px; color: var(--accent-deep); font-size: 12.5px; font-weight: 600; margin-top: 4px; }

@media (max-width: 900px) {
  .sch-legend { display: none; }
}

/* month view */
.sch-monthbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sch-mo-title { font-size: 17px; font-weight: 700; min-width: 150px; }
.sch-mo-nav { width: 30px; height: 30px; border: 1px solid var(--hair); background: var(--surface); border-radius: 8px; cursor: pointer; font-size: 17px; line-height: 1; color: var(--ink-soft); }
.sch-mo-nav:hover { border-color: var(--hair-strong); background: var(--surface-2); }
.sch-month { display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: 30px; grid-auto-rows: minmax(88px, 1fr); height: clamp(560px, calc(100vh - 130px), 1120px); border: 1px solid var(--hair); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.sch-mhead { background: var(--surface-2); border-bottom: 1px solid var(--hair); padding: 8px 10px; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sch-mcell { min-height: 0; min-width: 0; overflow: hidden; border-top: 1px solid var(--hair); border-left: 1px solid var(--hair); padding: 5px 6px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; transition: background .12s; }
.sch-mcell:nth-child(7n+1) { border-left: 0; }
.sch-mcell:hover { background: var(--surface-2); }
.sch-mcell.dim { background: var(--cream); }
.sch-mcell.dim .sch-mnum { color: var(--muted); opacity: .6; }
.sch-mcell.today { background: rgba(31,122,61,.04); }
.sch-mcell.today .sch-mnum { background: var(--accent); color: #fff; }
.sch-mcell.drop-hover { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.sch-mnum { font-size: 12px; font-weight: 700; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; font-family: var(--mono); }
.sch-mchips { display: flex; flex-direction: column; gap: 3px; min-height: 0; flex: 1; overflow: hidden; }
.sch-mchip { display: flex; align-items: baseline; gap: 5px; background: color-mix(in srgb, var(--c) 13%, white); border-left: 3px solid var(--c); border-radius: 4px; padding: 2px 6px; cursor: grab; overflow: hidden; }
.sch-mchip:hover { background: color-mix(in srgb, var(--c) 22%, white); }
.sch-mchip.dragging { opacity: .4; }
.sch-mchip-t { font-family: var(--mono); font-size: 9.5px; font-weight: 700; color: var(--ink-soft); flex: 0 0 auto; }
.sch-mchip-j { font-size: 11px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sch-mmore { font-size: 10.5px; color: var(--muted); font-weight: 600; padding: 1px 6px; }

@media (max-width: 900px) {
  .sch-legend { display: none; }
  .sch-mcell { min-height: 64px; padding: 4px; }
  .sch-mchip-j { display: none; }
  .sch-mchip { justify-content: center; padding: 3px; }
}

@media (max-width: 640px) {
  .cf-bars span { max-width: 14px; }
  .cf-run { font-size: 9.5px; }
}

/* ==========================================================
   TABLE
   ========================================================== */
.tbl {
  width: 100%;
  border-collapse: separate; border-spacing: 0;
  font-size: 13.5px;
}
.tbl thead th {
  text-align: left;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); font-weight: 500;
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hair);
  white-space: nowrap;
}
.tbl thead th.sortable { cursor: pointer; }
.tbl thead th.sortable:hover { color: var(--ink); }
.tbl tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--hair);
  vertical-align: middle;
}
.tbl tbody tr { transition: background .15s ease; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--mono); }
.tbl td .row-actions {
  display: inline-flex; gap: 4px;
  opacity: 0; transition: opacity .15s ease;
}
.tbl tr:hover .row-actions { opacity: 1; }
.tbl td .row-actions button {
  background: transparent; border: 0; padding: 5px;
  border-radius: 6px; color: var(--muted);
}
.tbl td .row-actions button:hover { color: var(--ink); background: var(--cream); }

.tbl-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hair);
  background: var(--surface);
  flex-wrap: wrap;
}
.tbl-toolbar .filters { display: flex; gap: 6px; flex-wrap: wrap; }
.tbl-toolbar .spacer { flex: 1; }

/* Segmented tabs */
.seg {
  display: inline-flex; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--hair);
  border-radius: 8px;
  gap: 2px;
}
.seg button {
  background: transparent; border: 0; padding: 5px 10px;
  border-radius: 6px; color: var(--muted);
  font-size: 12.5px; font-weight: 500;
}
.seg button.on { background: var(--ink); color: #fff; }
.seg button:hover:not(.on) { color: var(--ink); }

/* Status pill */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 999px;
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .08em; text-transform: uppercase; font-weight: 500;
  background: var(--cream); color: var(--ink-soft);
  border: 1px solid var(--hair);
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.pill.ok { background: var(--accent-soft); color: var(--accent-deep); border-color: rgba(31,122,61,.3); }
.pill.ok::before { background: var(--accent); }
.pill.warn { background: var(--amber-soft); color: #6E5314; border-color: rgba(182,139,30,.35); }
.pill.warn::before { background: var(--amber); }
.pill.bad { background: var(--red-soft); color: #7B2920; border-color: rgba(178,58,47,.35); }
.pill.bad::before { background: var(--red); }
.pill.info { background: var(--blue-soft); color: #1D4F9A; border-color: rgba(42,111,219,.3); }
.pill.info::before { background: var(--blue); }
.pill.draft { background: var(--cream); color: var(--muted); }
.pill.draft::before { background: var(--muted); }

/* ==========================================================
   FORMS
   ========================================================== */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label {
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  display: flex; justify-content: space-between; align-items: center;
}
.field label .opt {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  letter-spacing: .08em; text-transform: uppercase; font-weight: 500;
}
.field input[type=text], .field input[type=email], .field input[type=tel],
.field input[type=password], .field input[type=number], .field input[type=date],
.field input[type=time], .field input[type=month], .field input[type=week],
.field input[type=url], .field select, .field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--ink);
  font-size: 13.5px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px rgba(31,122,61,.12);
}
.field textarea { resize: vertical; min-height: 80px; }
.field .err { display: none; color: var(--red); font-family: var(--mono); font-size: 11.5px; }
.field.error .err { display: block; }
.field.error input, .field.error select, .field.error textarea { border-color: var(--red); background: var(--red-soft); }
.field .hint { color: var(--muted); font-size: 12px; }

/* ==========================================================
   SCHEDULE C OVERRIDE — nested in expense verify / edit drawers
   The line is normally DERIVED from the category; this lets a
   reviewer override it. COGS vs Part II is derived from the line,
   shown as a badge — never a separate toggle.
   ========================================================== */
.scl-row { display: flex; align-items: center; gap: 10px; }
.scl-row .scl-select { flex: 1; min-width: 0; }
.scl-select {
  background: var(--surface-2); border: 1px solid var(--hair); border-radius: 8px;
  padding: 9px 12px; color: var(--ink); font-size: 13.5px; font-family: var(--sans);
  transition: border-color .15s, background .15s, box-shadow .15s; max-width: 100%;
}
.scl-select:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px rgba(31,122,61,.12); }
.scl-select.overridden { border-color: var(--accent); background: var(--surface); }
.scl-hint .scl-flag { color: var(--accent-deep); font-weight: 600; }

/* derived COGS vs Part-II badge */
.scl-badge {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  padding: 5px 9px 5px 6px; border-radius: 8px; font-size: 11.5px; font-weight: 600;
  border: 1px solid var(--hair); background: var(--surface-2); color: var(--ink-soft); white-space: nowrap;
}
.scl-badge .scl-badge-part {
  font-family: var(--mono); font-size: 9px; letter-spacing: .07em; text-transform: uppercase;
  padding: 2px 5px; border-radius: 5px; background: var(--hair-strong); color: var(--surface); font-weight: 700;
}
.scl-badge .scl-badge-line { font-family: var(--mono); font-weight: 700; }
.scl-badge .scl-badge-lbl { color: var(--muted); font-weight: 500; }
.scl-badge.cogs { background: var(--accent-soft); border-color: rgba(31,122,61,.3); color: var(--accent-deep); }
.scl-badge.cogs .scl-badge-part { background: var(--accent); color: #fff; }
.scl-badge.partii .scl-badge-part { background: var(--blue); color: #fff; }
.scl-badge.none { background: var(--cream); color: var(--muted); border-style: dashed; }

/* per-line-item rows with their own Schedule C picker */
.li-row { padding: 13px 14px; border-bottom: 1px solid var(--hair); display: grid; gap: 10px; }
.li-row:last-child { border-bottom: 0; }
.li-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.li-desc { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.li-desc b { font-size: 13.5px; }
.li-desc .muted { font-size: 12px; }
.li-amt { font-weight: 700; flex: 0 0 auto; }
.li-bottom { display: flex; align-items: center; gap: 9px; }
.li-bottom .li-scl-label {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); flex: 0 0 auto;
}
.li-bottom .scl-select { flex: 1; min-width: 0; font-size: 12.5px; padding: 7px 10px; }
.li-bottom.dimmed { opacity: .4; pointer-events: none; }
@media (max-width: 640px) {
  .scl-row { flex-direction: column; align-items: stretch; }
  .scl-row .scl-badge { align-self: flex-start; }
  .li-bottom { flex-wrap: wrap; }
}


  position: relative;
}
.money::before {
  content: "$"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-family: var(--mono); font-size: 13px; pointer-events: none;
}
.money input { padding-left: 24px !important; font-family: var(--mono); }

/* ==========================================================
   TOAST
   ========================================================== */
.toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #ECEAE3;
  padding: 10px 16px; border-radius: 999px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .04em;
  display: flex; align-items: center; gap: 10px;
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s ease, transform .25s cubic-bezier(.2,.7,.2,1);
  box-shadow: 0 20px 40px -20px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok .ck { background: var(--accent); }
.toast.err .ck { background: var(--red); }
.toast .ck {
  width: 14px; height: 14px; border-radius: 50%;
  display: grid; place-items: center; flex: 0 0 14px;
}
.toast .ck svg { width: 8px; height: 8px; stroke: #fff; stroke-width: 2.5; fill: none; }

/* ==========================================================
   MODAL / DRAWER
   ========================================================== */
.modal-host {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  background: rgba(20,20,20,.45);
  padding: 24px;
}
.modal-host.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  width: 560px; max-width: 100%;
  max-height: calc(100vh - 48px);
  overflow: auto;
  animation: pop .25s cubic-bezier(.2,.7,.2,1);
}
.modal.wide { width: 920px; }
.modal.xwide { width: 1160px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--hair);
}
.modal-head h3 { font-size: 17px; }
.modal-head .x {
  background: transparent; border: 0; padding: 6px;
  border-radius: 6px; color: var(--muted);
}
.modal-head .x:hover { color: var(--ink); background: var(--cream); }
.modal-body { padding: 22px; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 22px; border-top: 1px solid var(--hair);
  background: var(--surface-2);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* Drawer variant (right-edge) */
.drawer-host {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(20,20,20,.35);
  display: none;
}
.drawer-host.open { display: block; }
.drawer-pane {
  position: absolute; top: 0; bottom: 0; right: 0;
  width: 560px; max-width: 100%;
  background: var(--surface);
  box-shadow: -30px 0 60px -30px rgba(0,0,0,.4);
  display: flex; flex-direction: column;
  animation: drwrIn .25s cubic-bezier(.2,.7,.2,1);
}
.drawer-pane.wide { width: 760px; }
@keyframes drwrIn { from { transform: translateX(20px); opacity: .8; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 16px 20px; border-bottom: 1px solid var(--hair);
}
.drawer-body { flex: 1; overflow: auto; padding: 20px; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--hair); background: var(--surface-2); display: flex; gap: 10px; justify-content: flex-end; }

/* ==========================================================
   DROPZONE
   ========================================================== */
.dropzone {
  border: 1.5px dashed var(--hair-strong);
  border-radius: 12px;
  padding: 22px;
  background: var(--surface-2);
  display: grid; place-items: center; gap: 8px; text-align: center;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { color: var(--accent-deep); }
.dropzone .ttl { font-weight: 600; }
.dropzone .hint { color: var(--muted); font-size: 12.5px; }

/* ==========================================================
   EMPTY / LOADING / ERROR
   ========================================================== */
.empty {
  text-align: center; padding: 60px 30px;
}
.empty .truss { width: 80px; height: 80px; margin: 0 auto 14px; opacity: .45; }
.empty .truss path, .empty .truss line { stroke: var(--ink); stroke-width: 1.2; fill: none; }
.empty h3 { font-size: 18px; margin-bottom: 6px; }
.empty h3 .accent { font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--accent-deep); }
.empty p { color: var(--muted); max-width: 380px; margin: 0 auto 14px; font-size: 13.5px; }

.loading-row {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  padding: 16px;
}
.skel {
  height: 12px; border-radius: 4px;
  background: linear-gradient(90deg, var(--hair) 0%, var(--hair-strong) 50%, var(--hair) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: 10px;
  font-size: 13.5px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert .ic {
  width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 11px; flex: 0 0 18px;
}
.alert.err { background: var(--red-soft); color: #7B2920; border-color: rgba(178,58,47,.35); }
.alert.err .ic { background: var(--red); color: #fff; }
.alert.info { background: var(--accent-soft); color: var(--accent-deep); border-color: rgba(31,122,61,.3); }
.alert.info .ic { background: var(--accent); color: #fff; }
.alert.warn { background: var(--amber-soft); color: #6E5314; border-color: rgba(182,139,30,.35); }
.alert.warn .ic { background: var(--amber); color: #fff; }

/* ==========================================================
   PIPELINE / KANBAN (Work view)
   ========================================================== */
.pipeline {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px; align-items: start;
}
@media (max-width: 1200px) { .pipeline { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) { .pipeline { grid-template-columns: 1fr; } }
.pipeline .col {
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: 12px;
  min-height: 200px;
  padding: 10px;
}
.pipeline .col-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 6px 10px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
.pipeline .col-head b { font-weight: 600; color: var(--ink); }
.pipeline .ticket {
  background: var(--surface); border: 1px solid var(--hair); border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  position: relative;
}
.pipeline .ticket:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-card); }
.pipeline .ticket .id {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  letter-spacing: .08em; text-transform: uppercase;
}
.pipeline .ticket .ttl { font-weight: 600; margin: 4px 0 8px; font-size: 13.5px; }
.pipeline .ticket .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.pipeline .ticket .amt { font-family: var(--mono); font-weight: 600; color: var(--ink); margin-left: auto; }

/* ==========================================================
   Misc utilities
   ========================================================== */
.hr-dash { border: 0; border-top: 1px dashed var(--hair-strong); margin: 16px 0; }
.muted { color: var(--muted); }
.accent-text { color: var(--accent-deep); }
.tag {
  display: inline-flex; padding: 2px 7px;
  background: var(--cream); border: 1px solid var(--hair); border-radius: 4px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em;
  color: var(--ink-soft);
}
.tag.accent { background: var(--accent-soft); color: var(--accent-deep); border-color: rgba(31,122,61,.3); }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-r { text-align: right; }

/* Truss decorative SVG glyph */
.truss-glyph path, .truss-glyph line { stroke: currentColor; stroke-width: 1.2; fill: none; }

/* ==========================================================
   MOBILE — phone-grade refinements
   Existing breakpoints already do basic stacking. These rules
   add: tighter spacing, scrollable tables, full-bleed modals,
   horizontal-swipe kanban, condensed topbar.
   ========================================================== */

/* Hide the week-date label below 1000px so the topbar stays clean */
@media (max-width: 1000px) {
  .topbar .week-pill .val { display: none; }
  .topbar .week-pill { padding: 2px; }
}

/* Larger tap target for nav links */
@media (max-width: 880px) {
  .nav-link { padding: 11px 12px; font-size: 14.5px; }
  .nav-group .label { padding: 8px 12px 6px; font-size: 11px; }
  .sidebar { width: min(86vw, 320px); }
  .sidebar .brand img,
  .sidebar .brand .logo { width: 36px; height: 36px; flex: 0 0 36px; }
  .sidebar .brand .biz b { font-size: 15px; }

  /* Topbar: condense everything */
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .crumbs { display: none; }   /* breadcrumbs hidden — h1 carries it */
  .topbar .week-pill { margin-left: 0; }
  .topbar .week-pill .val { padding: 6px 10px; font-size: 11.5px; }
  .topbar .week-pill .val .small { display: none; }
  .topbar .search { display: none; }   /* hide search input on phone — use icon */
  .topbar .acct .nm { display: none; } /* avatar-only menu trigger */

  /* Compact heading */
  .screen-head { gap: 14px; margin-bottom: 18px; }
  .screen-head h1 { font-size: 22px; }
  .screen-head .sub { font-size: 13px; }
  .screen-head .head-actions { width: 100%; }
  .screen-head .head-actions .btn { flex: 1; justify-content: center; }
}

/* Phone — go tighter */
@media (max-width: 560px) {
  :root { --topbar-h: 56px; }
  .main { padding: 14px 12px 60px; }
  .card-body { padding: 16px; }
  .card-head { padding: 12px 14px; gap: 10px; }
  .card-head h3 { font-size: 14px; }
  .card-head .meta { display: none; }
  .kpi { padding: 14px 16px; }
  .kpi .val { font-size: 24px; }

  /* Filter toolbars stack */
  .tbl-toolbar { padding: 10px 12px; gap: 8px; }
  .tbl-toolbar .seg { width: 100%; flex-wrap: wrap; }
  .tbl-toolbar .seg button { flex: 1; min-width: 0; padding: 6px 8px; }
  .tbl-toolbar .spacer { display: none; }
}

/* ---------- Tables: scroll horizontally on tight screens ---------- */
@media (max-width: 880px) {
  .card > table.tbl,
  .card > div > table.tbl {
    /* Wrap the table in an implicit scroll container via display:block on wrapper */
  }
  /* Where data-tables render directly into a .card child div, make that div scroll */
  .card > div:has(> table.tbl) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tbl { min-width: 540px; }   /* preserve column widths inside the scrollable wrapper */
  .tbl thead th, .tbl tbody td { padding: 10px 12px; font-size: 12.5px; }
  /* Row-actions always visible on touch */
  .tbl td .row-actions { opacity: 1; }
}

/* ---------- Modal + Drawer: full-bleed on phones ---------- */
@media (max-width: 640px) {
  .modal-host { padding: 0; align-items: stretch; }
  .modal,
  .modal.wide,
  .modal.xwide {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
    display: flex; flex-direction: column;
  }
  .modal-body { padding: 18px; flex: 1; overflow: auto; }
  .modal-head, .modal-foot { padding: 14px 18px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; justify-content: center; }

  .drawer-pane,
  .drawer-pane.wide { width: 100%; max-width: 100%; }
  .drawer-body { padding: 16px; }
  .drawer-foot { padding: 14px 16px; flex-wrap: wrap; }
  .drawer-foot .btn { flex: 1; justify-content: center; }
}

/* Receipt-viewer body grid stacks on phone */
@media (max-width: 720px) {
  .modal-body > div[style*="grid-template-columns:1fr 360px"],
  .modal-body > div[style*="grid-template-columns: 1fr 360px"],
  .modal-body > div[style*="grid-template-columns:300px 1fr"],
  .modal-body > div[style*="grid-template-columns: 300px 1fr"] {
    display: block !important;
  }
  .modal-body > div[style*="grid-template-columns"] > * { margin-bottom: 16px; }
}

/* ---------- Pipeline (kanban) → horizontal swipe on phone ---------- */
@media (max-width: 760px) {
  .pipeline {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
    margin: 0 -12px;
    padding-left: 12px; padding-right: 12px;
    gap: 10px;
  }
  .pipeline .col {
    flex: 0 0 80vw;
    max-width: 320px;
    scroll-snap-align: start;
  }
}

/* ---------- Doc-themed preview (Settings → Client-facing docs) ---------- */
@media (max-width: 1100px) {
  /* The settings/documents screen lays controls + preview in a 2-col grid via inline style.
     Force it to stack at this breakpoint by overriding the inline-styled grid container. */
  .main > div[style*="grid-template-columns: 1fr 560px"],
  .main > div[style*="grid-template-columns:1fr 560px"],
  .main > div[style*="grid-template-columns: 1fr 380px"],
  .main > div[style*="grid-template-columns:1fr 380px"] {
    grid-template-columns: 1fr !important;
  }
  .doc-preview-wrap { position: static !important; padding: 14px; }
}

/* ---------- Opt-cards (theme/header/table pickers) ---------- */
@media (max-width: 640px) {
  .opt-cards.three,
  .opt-cards.four,
  .opt-cards.five { grid-template-columns: repeat(2, 1fr) !important; }
  .opt-card .swatch { height: 44px; }
  .opt-card .nm { font-size: 12px; }
  .opt-card .ds { display: none; }
}

/* ---------- Pricing weld estimator: stack the quote sidebar ---------- */
@media (max-width: 1100px) {
  .main > div[style*="grid-template-columns: 1fr 380px"] { grid-template-columns: 1fr !important; }
}

/* ---------- Doc detail pages stack on tablet/phone ---------- */
@media (max-width: 1000px) {
  /* Quote / invoice / proposal detail: 1fr 380px sidebar → stack */
  .main > div.row-2[style*="grid-template-columns: 1fr 380px"],
  .main > div.row-2[style*="grid-template-columns:1fr 380px"] {
    grid-template-columns: 1fr !important;
  }
}

/* ---------- Dashboard: stack 2-col rows ---------- */
@media (max-width: 720px) {
  .row-2 { grid-template-columns: 1fr !important; }
}

/* ---------- Forms: comfortable touch sizes on phone ---------- */
@media (max-width: 640px) {
  .field input[type=text], .field input[type=email], .field input[type=tel],
  .field input[type=password], .field input[type=number], .field input[type=date],
  .field input[type=time], .field input[type=month], .field input[type=week],
  .field input[type=url], .field select, .field textarea {
    font-size: 16px;     /* iOS — prevent autofocus zoom */
    padding: 11px 14px;
  }
  .btn { padding: 10px 16px; font-size: 14px; }
  .btn-sm { padding: 7px 12px; font-size: 13px; }
}

/* ---------- Reduce shadows + animations slightly on phones ---------- */
@media (max-width: 640px) {
  .card { box-shadow: 0 1px 0 rgba(20,20,20,.04), 0 8px 20px -16px rgba(20,20,20,.18); }
}

/* ==========================================================
   SCROLLBARS — themed across the app (Firefox + WebKit)
   ========================================================== */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--hair-strong) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--hair-strong);
  border-radius: 999px;
  border: 2px solid var(--cream);
  background-clip: padding-box;
  transition: background .15s;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
  background-clip: padding-box;
}
*::-webkit-scrollbar-corner { background: transparent; }

/* Surfaces with their own background use that color as the track padding */
.card *::-webkit-scrollbar-thumb,
.modal *::-webkit-scrollbar-thumb,
.drawer-pane *::-webkit-scrollbar-thumb {
  border-color: var(--surface);
}
.modal-body::-webkit-scrollbar-thumb,
.drawer-body::-webkit-scrollbar-thumb { border-color: var(--surface); }

/* Dark surfaces (sidebar already overrides; this covers code blocks, ink panels) */
.sidebar nav *::-webkit-scrollbar-thumb,
[style*="background:#15171A"] *::-webkit-scrollbar-thumb,
[style*="background:#0E0F11"] *::-webkit-scrollbar-thumb {
  background: #3a3a37;
  border-color: #15171A;
}

/* ==========================================================
   FEEDBACK FAB — floating Report button (bottom-right)
   ========================================================== */
.fab-feedback {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 80;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 16px 11px 14px;
  background: var(--ink); color: #ECEAE3;
  border: 0; border-radius: 999px;
  font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0,0,0,.06), 0 14px 32px -14px rgba(0,0,0,.55);
  transition: background .15s, transform .15s, color .15s;
}
.fab-feedback:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-2px);
}
.fab-feedback:active { transform: translateY(0); }
.fab-feedback svg { color: currentColor; }
@media (max-width: 640px) {
  .fab-feedback {
    right: 14px; bottom: 14px;
    padding: 11px;
  }
  .fab-feedback .lbl { display: none; }
}

/* ==========================================================
   REPORT MODAL — themed inputs + screenshot uploads
   ========================================================== */
.rep-form { display: grid; gap: 14px; }
.rep-field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.rep-field label .opt {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  letter-spacing: .08em; text-transform: uppercase; font-weight: 500;
  margin-left: 6px;
}

/* Big "title" input — visually elevated, more pronounced rounding */
.rep-field-title input {
  font-size: 16px !important;
  padding: 13px 16px !important;
  font-weight: 600;
  letter-spacing: -0.005em;
  border-radius: 12px !important;
}

/* Related-record + area + textarea match with a softer rounding + cream fill */
.rep-field input,
.rep-field select,
.rep-field textarea {
  border-radius: 10px !important;
  padding: 11px 14px !important;
  background: var(--cream) !important;
  border: 1px solid var(--hair) !important;
}
.rep-field input:focus,
.rep-field select:focus,
.rep-field textarea:focus {
  background: var(--surface) !important;
  border-color: var(--accent) !important;
}
.rep-field textarea { padding: 12px 14px !important; }

/* Title field — same cream fill, bigger rounding */
.rep-field-title input { background: var(--cream) !important; }
.rep-field-title input:focus { background: var(--surface) !important; }

/* Kind-picker cards */
.rep-kind-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 2px;
}
@media (max-width: 560px) { .rep-kind-row { grid-template-columns: 1fr; } }
.rep-kind-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--hair);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color .15s, background .15s, transform .12s, box-shadow .15s;
}
.rep-kind-card:hover { border-color: var(--hair-strong); transform: translateY(-1px); }
.rep-kind-card.on {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.rep-kind-ic {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  font-size: 18px;
  flex: 0 0 34px;
}
.rep-kind-ttl { font-weight: 700; font-size: 14px; line-height: 1.2; }
.rep-kind-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Priority segmented */
.rep-priority {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: 8px;
}
.rep-priority button {
  flex: 1; min-width: 60px;
  background: transparent; border: 0;
  padding: 7px 10px;
  border-radius: 6px; color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 500;
  cursor: pointer; transition: background .15s, color .15s;
}
.rep-priority button:hover:not(.on) { color: var(--ink); }
.rep-priority button.on { color: #fff; }
.rep-priority button[data-v="low"].on    { background: var(--muted); }
.rep-priority button[data-v="medium"].on { background: var(--amber); }
.rep-priority button[data-v="high"].on   { background: var(--red); }

/* Screenshot dropzone */
.rep-drop {
  border: 1.5px dashed var(--hair-strong);
  border-radius: 12px;
  padding: 22px 18px;
  background: var(--surface-2);
  display: grid; place-items: center; gap: 6px; text-align: center;
  cursor: pointer;
  color: var(--ink-soft);
  transition: border-color .15s, background .15s;
}
.rep-drop:hover { border-color: var(--accent); }
.rep-drop.dragover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep); }
.rep-drop svg { color: var(--accent-deep); margin-bottom: 2px; }
.rep-drop-ttl { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.rep-drop-sub { font-size: 12px; color: var(--muted); max-width: 460px; line-height: 1.45; }

.rep-thumbs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-top: 8px;
}
@media (max-width: 640px) { .rep-thumbs { grid-template-columns: repeat(2, 1fr); } }
.rep-thumb {
  position: relative;
  border: 1px solid var(--hair);
  background: var(--surface-2);
  border-radius: 8px;
  overflow: hidden;
  display: block;
  text-decoration: none; color: inherit;
}
.rep-thumb img {
  width: 100%; height: 90px;
  object-fit: cover;
  display: block;
  background: #FAF8F2;
}
.rep-thumb-x {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(20,20,20,.78); color: #fff;
  border: 0; border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  opacity: 0; transition: opacity .15s, background .15s;
}
.rep-thumb:hover .rep-thumb-x { opacity: 1; }
.rep-thumb-x:hover { background: var(--red); }
.rep-thumb-meta {
  display: flex; justify-content: space-between; gap: 6px;
  padding: 5px 8px;
  font-size: 10.5px;
  color: var(--muted);
  border-top: 1px solid var(--hair);
  background: var(--surface);
}
.rep-thumb-meta span:first-child {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--ink-soft);
}
  background: #fff; border: 1px solid var(--hair); border-radius: 10px;
  padding: 36px;
  font-size: 13px; color: var(--ink);
  box-shadow: 0 20px 60px -30px rgba(0,0,0,.2);
}
.doc .doc-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 32px; gap: 24px; }
.doc .doc-head .biz b { display: block; font-size: 20px; }
.doc .doc-head .biz span { color: var(--muted); font-size: 12px; line-height: 1.5; display: block; }
.doc .doc-head .doc-meta {
  text-align: right;
}
.doc .doc-head .doc-meta .nm {
  font-family: var(--serif); font-style: italic; font-size: 28px;
  color: var(--accent-deep);
}
.doc .doc-head .doc-meta .nbr { font-family: var(--mono); color: var(--muted); margin-top: 6px; font-size: 12px; }
.doc .to { margin-bottom: 24px; }
.doc .to .lbl { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.doc .to b { font-size: 14px; display: block; margin-top: 4px; }
.doc .lines { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.doc .lines th, .doc .lines td { padding: 10px 8px; border-bottom: 1px solid var(--hair); text-align: left; font-size: 12.5px; }
.doc .lines th { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border-bottom-color: var(--ink); }
.doc .lines td.num, .doc .lines th.num { text-align: right; font-family: var(--mono); }
.doc .totals { margin-left: auto; width: 280px; }
.doc .totals .ln { display: flex; justify-content: space-between; padding: 6px 0; font-family: var(--mono); font-size: 12.5px; }
.doc .totals .ln.total { border-top: 1px solid var(--ink); font-weight: 700; font-size: 15px; padding-top: 10px; }
.doc .stripe { height: 4px; background: var(--accent); border-radius: 2px; margin: -36px -36px 28px; }

/* ============================================================
   APP — PIPELINE SCREEN
   Drop into app/styles.css. Uses existing app tokens only.
   ============================================================ */

.pipeline-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 14px;
  box-shadow: 0 1px 0 rgba(20,20,20,.04), 0 14px 30px -22px rgba(20,20,20,.18);
  overflow: hidden;
}

/* ---------- Header strip + overview ---------- */
.pl-head {
  padding: 22px 24px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hair);
}
.pl-head h3 {
  font-size: 19px; letter-spacing: -0.012em;
  display: flex; align-items: baseline; gap: 12px;
}
.pl-head h3 .serif-it {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  color: var(--accent-deep);
}
.pl-head h3 .meta {
  font-family: var(--mono); font-size: 11.5px;
  letter-spacing: .04em; color: var(--muted); font-weight: 400;
}
.pl-overview {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-top: 14px;
}
@media (max-width: 720px) { .pl-overview { grid-template-columns: repeat(2, 1fr); } }
.pl-tile {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 10px;
  position: relative;
}
.pl-tile .lbl {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.pl-tile .val {
  font-family: var(--mono); font-size: 22px;
  font-weight: 700; letter-spacing: -0.015em; color: var(--ink);
}
.pl-tile .val.bad { color: var(--red); }
.pl-tile .delta { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.pl-tile .stripe {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); border-radius: 10px 0 0 10px;
}
.pl-tile.warn .stripe { background: var(--amber); }
.pl-tile.red  .stripe { background: var(--red); }

/* ---------- Filter / group toolbar ---------- */
.pl-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px 24px;
  border-bottom: 1px solid var(--hair);
  background: var(--surface);
}
.pl-toolbar .seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--hair);
  border-radius: 8px;
}
.pl-toolbar .seg button {
  background: transparent; border: 0; padding: 5px 12px;
  border-radius: 6px; color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.pl-toolbar .seg button.on { background: var(--ink); color: #fff; }
.pl-toolbar .seg button:hover:not(.on) { color: var(--ink); }
.pl-toolbar .seg button .count {
  margin-left: 6px; font-family: var(--mono);
  font-size: 10.5px; opacity: .8;
}
.pl-toolbar .spacer { flex: 1; }
.pl-toolbar .search-mini {
  padding: 5px 10px;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: 6px;
  font: inherit; font-size: 12.5px;
  width: 200px;
}

/* ---------- Deal row ---------- */
.deals { display: flex; flex-direction: column; }
.deals .group-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px 10px;
  background: var(--cream);
  border-bottom: 1px solid var(--hair);
  font-family: var(--mono); font-size: 11px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.deals .group-head b { color: var(--ink); font-weight: 500; }
.deals .group-head .group-total { margin-left: auto; color: var(--ink); font-weight: 500; }

.deal {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 280px;
  gap: 24px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--hair);
  align-items: center;
  position: relative;
  transition: background .15s ease;
}
.deal:hover { background: var(--surface-2); }
.deal:last-child { border-bottom: 0; }

/* Left identity column */
.deal-id .title { font-weight: 700; font-size: 15px; line-height: 1.25; letter-spacing: -0.008em; margin-bottom: 4px; }
.deal-id .client {
  font-size: 13px; color: var(--ink-soft);
  display: flex; align-items: center; gap: 8px;
}
.deal-id .client::before {
  content: ""; width: 6px; height: 6px; background: var(--accent);
  border-radius: 50%; display: inline-block;
}
.deal-id .refs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.deal-id .ref {
  font-family: var(--mono); font-size: 10.5px;
  background: var(--surface-2); border: 1px solid var(--hair);
  padding: 2px 8px; border-radius: 4px; color: var(--ink-soft);
}
.deal-id .ref.accent { background: var(--accent-soft); color: var(--accent-deep); border-color: var(--accent); }
.deal-id .ref.muted { color: var(--muted); border-style: dashed; }

/* Center: progress flow */
.flow {
  display: grid; grid-template-columns: repeat(6, 1fr);
  position: relative; padding: 6px 0 10px;
}
.flow::before {
  content: ""; position: absolute; left: 0; right: 0; top: 16px;
  height: 2px; background: var(--hair); z-index: 0;
}
.flow.p-1::before { background: linear-gradient(to right, var(--accent) 10%, var(--hair) 10%); }
.flow.p-2::before { background: linear-gradient(to right, var(--accent) 30%, var(--hair) 30%); }
.flow.p-3::before { background: linear-gradient(to right, var(--accent) 50%, var(--hair) 50%); }
.flow.p-4::before { background: linear-gradient(to right, var(--accent) 70%, var(--hair) 70%); }
.flow.p-5::before { background: linear-gradient(to right, var(--accent) 90%, var(--hair) 90%); }
.flow.p-6::before { background: var(--accent); }
.flow.lost::before { background: linear-gradient(to right, var(--accent) var(--lost-pct, 30%), var(--red) var(--lost-pct, 30%), var(--red) 100%); }

.flow .step {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; position: relative; z-index: 1; min-width: 0;
}
.flow .dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--hair-strong);
  position: relative; transition: all .2s ease;
}
.flow .step .lbl {
  font-family: var(--mono); font-size: 9.5px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  text-align: center; line-height: 1.3;
  max-width: 70px; word-wrap: break-word;
}
.flow .step .sub {
  font-family: var(--mono); font-size: 9.5px; color: var(--muted);
  text-align: center; line-height: 1.2;
}
.flow .step.done .dot { background: var(--accent); border-color: var(--accent); }
.flow .step.done .dot::after {
  content: ""; position: absolute; inset: 3px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12"><path d="M2 6l2.5 2.5L10 3" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>') center/contain no-repeat;
}
.flow .step.done .lbl { color: var(--accent-deep); }
.flow .step.current .dot {
  background: var(--surface);
  border: 3px solid var(--accent);
  width: 18px; height: 18px;
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: pl-pulse 2.2s ease-in-out infinite;
}
.flow .step.current .lbl { color: var(--accent-deep); font-weight: 600; }
@keyframes pl-pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent-soft); }
  50%      { box-shadow: 0 0 0 6px rgba(31,122,61,.12); }
}
.flow .step.skipped .dot { background: var(--surface); border-style: dashed; border-color: var(--hair-strong); }
.flow .step.skipped .lbl { color: var(--hair-strong); text-decoration: line-through; }
.flow .step.lost .dot { background: var(--red); border-color: var(--red); }
.flow .step.lost .dot::after {
  content: ""; position: absolute; inset: 3px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12"><path d="M3 3l6 6M9 3l-6 6" fill="none" stroke="white" stroke-width="2" stroke-linecap="round"/></svg>') center/contain no-repeat;
}
.flow .step.lost .lbl { color: var(--red); font-weight: 600; }
.flow .step.stalled .dot { background: var(--amber); border-color: var(--amber); }
.flow .step.stalled .lbl { color: #6E5314; font-weight: 600; }

/* Right: money + actions */
.deal-right { display: grid; gap: 10px; }
.deal-money {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--hair);
  border: 1px solid var(--hair);
  border-radius: 8px; overflow: hidden;
}
.deal-money .ln { background: var(--surface-2); padding: 6px 10px; text-align: center; }
.deal-money .ln .l {
  font-family: var(--mono); font-size: 9px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 2px;
}
.deal-money .ln .v {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  color: var(--ink);
}
.deal-money .ln.out .v { color: var(--red); }
.deal-money .ln.paid .v { color: var(--accent-deep); }
.deal-action { display: flex; gap: 6px; }
.btn-action {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 12px;
  background: var(--accent); color: #fff;
  border: 0; border-radius: 8px;
  font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer;
  transition: background .15s, transform .12s;
}
.btn-action:hover { background: var(--accent-darker); transform: translateY(-1px); }
.btn-action.secondary {
  background: transparent; color: var(--ink);
  border: 1px solid var(--hair-strong);
}
.btn-action.secondary:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-action.muted {
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--hair); cursor: default;
}
.btn-action.muted:hover { background: var(--surface-2); transform: none; }
.btn-action .ic { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; }
.btn-expand {
  background: transparent; border: 0; color: var(--muted);
  width: 32px; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  border-radius: 6px;
  transition: color .15s, background .15s, transform .15s;
}
.btn-expand:hover { color: var(--ink); background: var(--cream); }
.deal.open .btn-expand { transform: rotate(180deg); color: var(--accent-deep); }

/* Expanded timeline */
.deal-timeline {
  grid-column: 1 / -1;
  display: none;
  padding-top: 16px;
  margin-top: 12px;
  border-top: 1px dashed var(--hair-strong);
}
.deal.open .deal-timeline { display: block; }
.timeline {
  display: grid; position: relative; padding: 0 0 0 20px;
}
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 1px; background: var(--hair);
}
.tl-evt {
  display: grid; grid-template-columns: 110px 1fr auto;
  gap: 14px; padding: 7px 0;
  position: relative; align-items: center;
}
.tl-evt::before {
  content: ""; position: absolute; left: -19px; top: 13px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--hair-strong);
}
.tl-evt.ok::before  { background: var(--accent); border-color: var(--accent); }
.tl-evt.bad::before { background: var(--red);   border-color: var(--red); }
.tl-evt .date {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  letter-spacing: .04em;
}
.tl-evt .desc { color: var(--ink); font-size: 13px; }
.tl-evt .amt { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink); }
.tl-evt .amt.pos { color: var(--accent-deep); }
.tl-evt .amt.neg { color: var(--red); }
.tl-actions {
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--hair);
  display: flex; gap: 8px; flex-wrap: wrap;
}
.tl-actions button {
  background: var(--surface); border: 1px solid var(--hair-strong);
  padding: 6px 12px; border-radius: 6px;
  font: inherit; font-size: 12.5px; color: var(--ink-soft); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.tl-actions button:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Stalled tag */
.deal .stalled-tag {
  position: absolute; top: 12px; right: 12px;
  background: var(--amber-soft); color: #6E5314;
  border: 1px solid var(--amber);
  font-family: var(--mono); font-size: 9.5px;
  letter-spacing: .12em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px;
  font-weight: 500;
}

/* Responsive */
@media (max-width: 1100px) {
  .deal { grid-template-columns: 1fr; gap: 14px; padding: 18px 20px; }
  .deal-id { padding-bottom: 6px; border-bottom: 1px dashed var(--hair); }
}
@media (max-width: 640px) {
  .pl-toolbar { padding: 10px 14px; }
  .pl-toolbar .seg { width: 100%; flex-wrap: wrap; }
  .pl-toolbar .seg button { flex: 1; }
  .pl-toolbar .search-mini { width: 100%; }
  .deal { padding: 16px 14px; }
  .deal-money { grid-template-columns: 1fr 1fr 1fr; }
  .flow .step .lbl { font-size: 9px; }
}

/* ============================================================
   QUOTES — proposal funnel board
   Reuses tile language from Pipeline but the cards & lanes
   are specific to the proposal phase.
   ============================================================ */
.quotes-board {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 12px;
  overflow: hidden;
}
.qb-head {
  padding: 22px 24px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hair);
}
.qb-head h3 {
  font-size: 19px; letter-spacing: -0.012em;
  display: flex; align-items: baseline; gap: 12px;
  margin: 0;
}
.qb-head h3 .serif-it {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  color: var(--accent-deep);
}
.qb-head h3 .meta {
  font-family: var(--mono); font-size: 11.5px;
  letter-spacing: .04em; color: var(--muted); font-weight: 400;
}
.qb-overview {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-top: 14px;
}
@media (max-width: 900px) { .qb-overview { grid-template-columns: repeat(2, 1fr); } }
.qb-tile {
  position: relative;
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 8px;
}
.qb-tile .stripe {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); border-radius: 8px 0 0 8px;
}
.qb-tile.warn .stripe { background: var(--amber); }
.qb-tile .lbl {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.qb-tile .val {
  font-family: var(--mono); font-size: 22px;
  font-weight: 700; letter-spacing: -0.015em; color: var(--ink);
}
.qb-tile .delta { font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* ---------- Lanes ---------- */
.qb-lanes {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  background: var(--surface);
}
.q-lane {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--hair);
  min-width: 0;
}
.q-lane:last-child { border-right: 0; }
.qln-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hair);
}
.qln-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.qln-title b {
  font-size: 13px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.005em;
}
.qln-title .qln-hint {
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .04em; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qln-count {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--hair);
  padding: 1px 8px; border-radius: 10px;
}
.qln-banner {
  margin: 10px 14px 0;
  padding: 8px 12px;
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  color: #6E5314;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
}
.qln-body {
  flex: 1;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 120px;
}
.qln-empty {
  color: var(--muted); font-size: 12.5px;
  padding: 24px 6px; text-align: center;
}
.qln-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--hair);
  background: var(--surface-2);
  font-family: var(--mono); font-size: 11px;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.qln-foot .mono { color: var(--ink); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: 13px; }

/* ---------- Quote card ---------- */
.q-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 10px 12px 10px 14px;
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
  display: flex; flex-direction: column; gap: 4px;
}
.q-card::before {
  content: ""; position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  background: transparent;
  border-radius: 8px 0 0 8px;
}
.q-card.win::before { background: var(--accent); }
.q-card.loss::before { background: var(--red); opacity: .55; }
.q-card.loss { background: var(--surface-2); }
.q-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}
.qc-top { display: flex; align-items: center; gap: 6px; }

/* Doc-type micro-badge */
.qc-doctype {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 3px;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  background: var(--cream); color: var(--ink-soft);
  border: 1px solid var(--hair);
  letter-spacing: 0;
  flex-shrink: 0;
}
.qc-doctype.proposal {
  background: var(--accent-soft);
  border-color: rgba(31,122,61,.3);
  color: var(--accent-deep);
  font-family: var(--serif); font-style: italic;
  font-size: 12px; font-weight: 400;
}

.qc-num {
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.qc-dot {
  width: 3px; height: 3px; background: var(--hair-strong);
  border-radius: 50%;
}
.qc-age {
  font-family: var(--mono); font-size: 10.5px;
  color: var(--muted); letter-spacing: .04em;
}
.qc-amt {
  margin-left: auto;
  font-family: var(--mono); font-size: 13px;
  font-weight: 700; color: var(--ink);
  letter-spacing: -0.005em;
}
.qc-ttl {
  font-weight: 600; font-size: 13.5px;
  line-height: 1.3; color: var(--ink);
  letter-spacing: -0.005em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.qc-client {
  font-size: 12.5px; color: var(--ink-soft);
  display: flex; align-items: center; gap: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qc-client::before {
  content: ""; width: 5px; height: 5px;
  background: var(--accent);
  border-radius: 50%; display: inline-block;
  flex-shrink: 0;
}
.q-card.loss .qc-client::before { background: var(--muted); }
.qc-foot {
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px dashed var(--hair);
}
.qc-sig {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--ink-soft);
  font-family: var(--mono); letter-spacing: .01em;
}
.qc-sig.muted { color: var(--muted); }
.qc-sig.warn  { color: #8A6510; }
.qc-sig.win   { color: var(--accent-deep); font-weight: 600; }
.qc-sig.loss  { color: var(--muted); }

@media (max-width: 1100px) {
  .qb-lanes { grid-template-columns: 1fr; }
  .q-lane { border-right: 0; border-bottom: 1px solid var(--hair); }
  .q-lane:last-child { border-bottom: 0; }
}

/* ==========================================================
   TIMESHEETS — verify / approved / crew tabs
   ========================================================== */
.ts-tabs {
  display: flex; align-items: stretch;
  flex: 1;
}
.ts-tab {
  position: relative;
  background: transparent; border: 0;
  padding: 16px 22px;
  font-size: 14px; font-weight: 600;
  color: var(--muted);
  letter-spacing: -0.005em;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 8px;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.ts-tab:hover { color: var(--ink); }
.ts-tab.on { color: var(--accent-deep); border-bottom-color: var(--accent); }
.ts-tab-badge {
  background: var(--red);
  color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  letter-spacing: .04em;
  animation: ts-badge-pulse 2s ease-in-out infinite;
}
@keyframes ts-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(178,58,47,.5); }
  50%      { box-shadow: 0 0 0 6px rgba(178,58,47,0); }
}
.ts-tab-count {
  background: var(--cream);
  color: var(--muted);
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--hair);
}
.ts-tab.on .ts-tab-count {
  background: var(--accent-soft); color: var(--accent-deep); border-color: rgba(31,122,61,.25);
}

.ts-week-group { padding: 0; }
.ts-week-hd {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 16px 20px 10px;
  border-top: 1px solid var(--hair);
  background: var(--surface-2);
}
.ts-week-group:first-child .ts-week-hd { border-top: 0; }
.ts-week-hd h4 {
  font-size: 13px; font-weight: 700; letter-spacing: -0.005em;
  margin: 0;
}
.ts-week-hd .meta { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .04em; }

.ts-sub {
  border-top: 1px solid var(--hair);
  padding: 16px 20px;
  background: var(--surface);
}
.ts-sub.changes { background: var(--amber-soft); border-left: 3px solid var(--amber); }
.ts-sub:first-of-type { border-top: 0; }
.ts-sub-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.ts-sub-hd > div:first-child {
  display: flex; align-items: center; gap: 12px;
  flex: 1 1 240px; min-width: 0;
}
.ts-sub-hd > div:first-child > div:first-child { flex: 0 0 36px; }  /* avatar */
.ts-sub-hd > div:first-child > div:last-child  { min-width: 0; flex: 1; }
.ts-sub-hd > div:first-child b {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.ts-note {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.ts-note.warn { background: var(--amber-soft); color: #6E5314; }
.ts-chev { transition: transform .2s ease; }
.ts-sub-body {
  margin-top: 14px;
  border: 1px solid var(--hair);
  border-radius: 10px;
  overflow: hidden;
}
.ts-sub-body[hidden] { display: none; }
.ts-days-tbl { font-size: 13px; }
.ts-days-tbl tbody td { padding: 10px 14px; vertical-align: top; }
.ts-shift {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; margin: 2px 6px 2px 0;
  background: var(--surface-2);
  border: 1px solid var(--hair); border-radius: 999px;
  font-size: 12px;
}
.ts-shift .ts-arrow { color: var(--muted); }
.ts-shift-note { color: var(--muted); margin-left: 6px; font-size: 11.5px; font-style: italic; }
.ts-sub-foot {
  margin-top: 14px;
  display: flex; align-items: center; gap: 8px;
}

/* ==========================================================
   WEEK PICKER popover (anchored to .week-pill .val)
   ========================================================== */
.week-pill { position: relative; }
.week-pill .val {
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.week-pill .val::after {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  margin-left: 2px;
  transition: transform .15s ease;
}
.week-pill.open .val::after { transform: rotate(-135deg) translateY(0); }
.week-pill .val:hover { background: var(--cream); }

.week-pop {
  position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  width: 320px;
  z-index: 30;
  overflow: hidden;
  display: none;
}
.week-pop.open { display: block; }
.week-pop .wp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hair);
  background: var(--surface-2);
}
.week-pop .wp-head b { font-size: 13px; font-weight: 700; }
.week-pop .wp-head button {
  background: transparent; border: 1px solid var(--hair);
  width: 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center;
  color: var(--ink-soft);
}
.week-pop .wp-head button:hover { background: var(--cream); color: var(--ink); }
.week-pop .wp-body { padding: 6px; max-height: 360px; overflow-y: auto; }
.week-pop .wp-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background .12s;
}
.week-pop .wp-row:hover { background: var(--cream); }
.week-pop .wp-row.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.week-pop .wp-row.active .wp-when { color: var(--accent-deep); font-weight: 700; }
.week-pop .wp-row.this { font-weight: 700; }
.week-pop .wp-row .wp-when { font-family: var(--mono); font-size: 13px; }
.week-pop .wp-row .wp-range { color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.week-pop .wp-row .wp-tag {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em;
  text-transform: uppercase; font-weight: 600;
  background: var(--cream); color: var(--muted);
  padding: 2px 6px; border-radius: 4px;
}
.week-pop .wp-row.this .wp-tag { background: var(--accent); color: #fff; }
.week-pop .wp-foot {
  display: flex; gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--hair);
  background: var(--surface-2);
}
.week-pop .wp-foot button {
  flex: 1; background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12px; font-weight: 600;
  color: var(--ink-soft);
  font-family: var(--mono); letter-spacing: .04em;
}
.week-pop .wp-foot button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ==========================================================
   CONNECTED BANKS (Teller-style) — institution cards + accounts
   ========================================================== */
.bk-empty {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  padding: 48px 32px 40px;
  text-align: center;
  max-width: 640px; margin: 24px auto 0;
}
.bk-empty .ic-wrap {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent-deep);
  display: grid; place-items: center;
  margin: 0 auto 18px;
}
.bk-empty .ic-wrap svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.bk-empty h2 {
  font-size: 22px; letter-spacing: -0.018em; margin-bottom: 8px;
}
.bk-empty h2 .accent {
  font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--accent-deep);
}
.bk-empty p {
  color: var(--ink-soft); font-size: 14.5px; line-height: 1.55; max-width: 480px; margin: 0 auto;
}
.bk-trust {
  margin-top: 22px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--hair); border-radius: 999px;
  font-size: 12.5px; color: var(--ink-soft);
}
.bk-trust svg { width: 12px; height: 12px; stroke: var(--accent-deep); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bk-trust b { font-weight: 700; }

/* Institution card */
.bk-inst {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  margin-top: 14px;
  overflow: hidden;
}
.bk-inst-head {
  display: grid; grid-template-columns: 44px 1fr auto auto; gap: 14px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hair);
  background: var(--surface-2);
}
.bk-inst-mark {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--inst-accent, var(--accent-deep));
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--serif); font-style: italic; font-size: 18px; font-weight: 400;
  letter-spacing: -0.02em;
}
.bk-inst-id b {
  font-size: 15px; font-weight: 700; letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 10px;
}
.bk-inst-id .sub {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  letter-spacing: .04em; margin-top: 3px;
}
.bk-inst-id .sub b { display: inline; font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.bk-inst-actions {
  display: flex; gap: 8px; align-items: center;
}
.bk-sync-btn {
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: 8px; padding: 6px 12px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
}
.bk-sync-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); }
.bk-sync-btn[disabled] { opacity: .6; cursor: not-allowed; }
.bk-sync-btn .spin {
  width: 11px; height: 11px; border-radius: 50%;
  border: 1.5px solid currentColor; border-top-color: transparent;
  animation: bk-spin .7s linear infinite;
}
@keyframes bk-spin { to { transform: rotate(360deg); } }

.bk-inst-menu {
  background: transparent; border: 0; cursor: pointer;
  padding: 6px 8px; border-radius: 6px;
  color: var(--muted);
}
.bk-inst-menu:hover { background: var(--cream); color: var(--ink); }

/* Account rows inside an institution */
.bk-accts { padding: 0; }
.bk-acct {
  display: grid; grid-template-columns: 32px 1fr auto auto;
  gap: 14px; align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--hair);
  transition: background .15s;
}
.bk-acct:hover { background: var(--surface-2); }
.bk-acct:last-child { border-bottom: 0; }
.bk-acct.orphaned { opacity: .55; }
.bk-acct .type-ic {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--cream); color: var(--ink-soft);
  display: grid; place-items: center;
}
.bk-acct .type-ic.credit { background: #2D2D2A; color: #fff; }
.bk-acct .type-ic.savings { background: var(--accent-soft); color: var(--accent-deep); }
.bk-acct .type-ic svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bk-acct .nm { font-weight: 600; font-size: 14px; }
.bk-acct .nm .last4 { color: var(--muted); font-family: var(--mono); font-size: 12px; margin-left: 6px; font-weight: 500; letter-spacing: .04em; }
.bk-acct .sub-line {
  color: var(--muted); font-size: 11.5px; font-family: var(--mono);
  letter-spacing: .04em; margin-top: 2px;
  display: flex; gap: 8px; align-items: center;
}
.bk-acct .sub-line .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--hair-strong); }
.bk-acct .bal {
  text-align: right;
}
.bk-acct .bal .v {
  font-family: var(--mono); font-size: 15px; font-weight: 700;
  letter-spacing: -0.005em;
}
.bk-acct .bal .v.negative { color: var(--red); }
.bk-acct .bal .avail {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  letter-spacing: .04em;
}

/* Sync toggle */
.bk-toggle {
  display: inline-flex; align-items: center; gap: 8px;
}
.bk-toggle .lbl {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  color: var(--muted); text-transform: uppercase; font-weight: 600;
}
.bk-switch {
  width: 36px; height: 20px; border-radius: 999px;
  background: var(--hair-strong); position: relative;
  cursor: pointer; transition: background .15s;
  border: 0;
}
.bk-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
  transition: transform .18s cubic-bezier(.2,.7,.2,1);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.bk-switch.on { background: var(--accent); }
.bk-switch.on::after { transform: translateX(16px); }

/* Status pills (extend base .pill colors) */
.pill.reconnect {
  background: var(--amber-soft); color: #6E5314;
  border-color: rgba(182,139,30,.4);
}
.pill.reconnect::before { background: var(--amber); }
.pill.disconnected {
  background: var(--cream); color: var(--muted);
  border-color: var(--hair-strong);
}

/* Reconnect banner inside institution card */
.bk-reconnect {
  padding: 12px 20px;
  background: var(--amber-soft);
  border-bottom: 1px solid rgba(182,139,30,.3);
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: #6E5314;
}
.bk-reconnect svg { width: 16px; height: 16px; stroke: #6E5314; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 16px; }
.bk-reconnect b { font-weight: 700; }
.bk-reconnect button {
  margin-left: auto;
  background: #6E5314; color: #fff; border: 0;
  padding: 5px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.bk-reconnect button:hover { background: #5a4310; }

/* Teller Connect modal (simulated) */
.teller-modal {
  background: #1A1A1A; color: #ECEAE3;
  border-radius: 14px; max-width: 420px; width: 100%;
  padding: 0; overflow: hidden;
}
.teller-modal .tm-head {
  padding: 18px 22px; border-bottom: 1px solid #2a2a27;
  display: flex; align-items: center; gap: 10px;
}
.teller-modal .tm-head .tm-lock {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(31,122,61,.2); color: #5fbe7f;
  display: grid; place-items: center;
}
.teller-modal .tm-head .tm-lock svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.teller-modal .tm-head b { font-size: 15px; font-weight: 700; color: #fff; }
.teller-modal .tm-head .tm-sub {
  font-family: var(--mono); font-size: 10.5px; color: #8C887E;
  letter-spacing: .08em; text-transform: uppercase; margin-top: 2px;
}
.teller-modal .tm-body { padding: 18px 22px 6px; }
.teller-modal .tm-body p { color: #C7C1B0; font-size: 13.5px; line-height: 1.55; }
.teller-modal .tm-banks {
  margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.teller-modal .tm-bank {
  background: #232320; border: 1px solid #2a2a27;
  border-radius: 8px; padding: 10px 12px;
  text-align: left; color: #ECEAE3;
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  transition: border-color .15s, background .15s;
}
.teller-modal .tm-bank:hover { border-color: #4a4a47; background: #2a2a27; }
.teller-modal .tm-bank .mark {
  width: 26px; height: 26px; border-radius: 6px;
  display: grid; place-items: center;
  color: #fff; font-family: var(--serif); font-style: italic; font-size: 12px;
}
.teller-modal .tm-foot {
  padding: 14px 22px;
  border-top: 1px solid #2a2a27;
  display: flex; gap: 10px; justify-content: flex-end;
}
.teller-modal .tm-foot .tm-btn {
  background: transparent; color: #8C887E;
  border: 1px solid #2a2a27; border-radius: 7px;
  padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.teller-modal .tm-foot .tm-btn:hover { color: #fff; border-color: #4a4a47; }

/* ==========================================================
   TRANSACTIONS — Teller-imported ledger
   ========================================================== */
.bk-tx-summary {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.bk-tx-summary .stat {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 12px 16px;
}
.bk-tx-summary .stat .lbl {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  color: var(--muted); text-transform: uppercase; font-weight: 600;
}
.bk-tx-summary .stat .v {
  font-family: var(--mono); font-size: 22px; font-weight: 700;
  letter-spacing: -0.015em; margin-top: 4px; line-height: 1;
}
.bk-tx-summary .stat.in .v  { color: var(--accent-deep); }
.bk-tx-summary .stat.out .v { color: var(--ink); }
.bk-tx-summary .stat.net .v.up { color: var(--accent-deep); }
.bk-tx-summary .stat.net .v.dn { color: var(--red); }
.bk-tx-summary .stat .delta {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  margin-top: 2px;
}

.bk-tx-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.bk-tx-controls .search-wrap {
  position: relative; flex: 1; min-width: 200px;
}
.bk-tx-controls .search-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; stroke: var(--muted); fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.bk-tx-controls input[type=search] {
  width: 100%;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--hair); border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  min-height: 32px;
}
.bk-tx-controls input[type=search]:focus { outline: none; border-color: var(--accent); }
.bk-tx-controls select {
  border: 1px solid var(--hair); border-radius: 8px;
  background: var(--surface);
  padding: 7px 28px 7px 12px;
  font-size: 13px;
  font-weight: 500; color: var(--ink-soft);
  min-height: 32px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='%236B6862' stroke-width='1.5' stroke-linecap='round'><path d='M3 5l4 4 4-4'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 12px;
}
.bk-tx-controls select:focus { outline: none; border-color: var(--accent); }
.bk-tx-controls .meta-chip {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em;
  color: var(--muted); text-transform: uppercase;
  margin-left: auto;
}

.bk-tx-ledger {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-top: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: hidden;
}

/* Date group header */
.bk-tx-date {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 20px 8px;
  background: var(--surface-2);
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
}
.bk-tx-date:first-child { border-top: 0; }
.bk-tx-date h4 {
  font-size: 13px; font-weight: 700; letter-spacing: -0.005em;
}
.bk-tx-date h4 .day {
  color: var(--muted); font-weight: 500; margin-left: 6px;
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
}
.bk-tx-date .day-net {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  letter-spacing: .04em;
}
.bk-tx-date .day-net.in  { color: var(--accent-deep); }
.bk-tx-date .day-net.out { color: var(--ink-soft); }

/* Transaction row */
.bk-tx {
  display: grid;
  grid-template-columns: 36px 1fr 140px 140px 110px 140px;
  gap: 14px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--hair);
  transition: background .12s;
  cursor: pointer;
}
.bk-tx:last-child { border-bottom: 0; }
.bk-tx:hover { background: var(--surface-2); }
.bk-tx.pending { background: rgba(250, 241, 220, .25); }
.bk-tx.pending:hover { background: rgba(250, 241, 220, .5); }

.bk-tx-catic {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--accent-soft);
  display: grid; place-items: center;
  color: var(--accent-deep);
  flex: 0 0 30px;
  --cat-hue: var(--accent);
}
.bk-tx-catic svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bk-tx-catic.pending {
  background: var(--surface-2);
  color: var(--muted);
}
.bk-tx-catic.income { background: rgba(31,122,61,.15); color: var(--accent-deep); }

.bk-tx-merchant b {
  font-size: 14px; font-weight: 600; letter-spacing: -0.005em;
  display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bk-tx-merchant b.pending {
  font-style: italic; color: var(--ink-soft); font-weight: 500;
}
.bk-tx-merchant .desc {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  letter-spacing: .02em; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.bk-tx-cat {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft);
  border: 1px solid var(--hair);
  font-size: 11.5px; font-weight: 500;
}
.bk-tx-cat .swatch {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cat-hue, var(--muted));
}
.bk-tx-cat.uncategorized { color: var(--muted); font-style: italic; }

.bk-tx-acct {
  font-family: var(--mono); font-size: 11.5px;
  color: var(--ink-soft);
}
.bk-tx-acct .lbl { display: block; font-weight: 600; }
.bk-tx-acct .l4 { color: var(--muted); font-size: 10.5px; letter-spacing: .04em; }

.bk-tx-match {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 4px;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
  border: 1px solid var(--hair);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.bk-tx-match.matched {
  background: var(--accent-soft); color: var(--accent-deep);
  border-color: rgba(31,122,61,.3);
}
.bk-tx-match.unmatched {
  background: var(--amber-soft); color: #6E5314;
  border-color: rgba(182,139,30,.4);
}
.bk-tx-match.unmatched:hover { background: var(--amber); color: #fff; }
.bk-tx-match svg { width: 9px; height: 9px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.bk-tx-amt {
  font-family: var(--mono); font-size: 15px; font-weight: 700;
  text-align: right;
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.bk-tx-amt.in  { color: var(--accent-deep); }
.bk-tx-amt.out { color: var(--ink); }
.bk-tx-amt.pending { color: var(--muted); font-style: italic; }
.bk-tx-amt .bal {
  display: block;
  font-size: 10.5px; color: var(--muted); font-weight: 500;
  letter-spacing: .02em; margin-top: 2px;
}

/* Pending chip */
.bk-pending-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: 4px;
  background: var(--amber-soft); color: #6E5314;
  border: 1px solid rgba(182,139,30,.35);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em;
  text-transform: uppercase; font-weight: 600;
  margin-left: 8px; vertical-align: 1px;
}
.bk-pending-chip svg { width: 8px; height: 8px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; animation: bk-spin 1.6s linear infinite; }

/* Skeleton loader for transactions */
.bk-tx-skel {
  display: grid; grid-template-columns: 36px 1fr 140px 110px 100px;
  gap: 14px; align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--hair);
}
.bk-tx-skel .sk {
  height: 14px; border-radius: 4px;
  background: linear-gradient(90deg, var(--hair) 0%, var(--cream-deep) 50%, var(--hair) 100%);
  background-size: 200% 100%;
  animation: bk-shimmer 1.4s ease-in-out infinite;
}
@keyframes bk-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.bk-tx-skel .sk.av { width: 30px; height: 30px; border-radius: 7px; }
.bk-tx-skel .sk.bar1 { width: 60%; }
.bk-tx-skel .sk.bar2 { width: 40%; height: 10px; margin-top: 6px; }

/* Empty state for txn ledger */
.bk-tx-empty {
  padding: 60px 24px; text-align: center;
}
.bk-tx-empty .ic-wrap {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-deep);
  display: grid; place-items: center; margin: 0 auto 16px;
}
.bk-tx-empty h3 { font-size: 17px; }
.bk-tx-empty p { color: var(--muted); font-size: 13.5px; margin-top: 6px; max-width: 320px; margin-inline: auto; }

/* Tab structure (reuse ts-tabs pattern) ---- already in styles.css */

/* Mobile collapse */
@media (max-width: 1100px) {
  .bk-tx { grid-template-columns: 36px 1fr 110px 100px; }
  .bk-tx-cat, .bk-tx-match { display: none; }
  .bk-tx-summary { grid-template-columns: 1fr; }
}

/* ==========================================================
   IMPORTS — data-import pipeline (Upload / Working / Preview / Result)
   Decision semantics reuse the app status-pill palette:
     create → .pill.ok (green) · update → .pill.info (blue)
     skip   → .pill.draft (gray) · conflict → .pill.warn (amber)
     error  → .pill.bad (red)
   ========================================================== */

/* ---- Source picker ---- */
.imp-sources {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 4px;
}
.imp-source {
  text-align: left; background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--radius-lg); padding: 18px; cursor: pointer;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
  display: flex; flex-direction: column; gap: 10px; min-height: 132px;
}
.imp-source:hover { border-color: var(--hair-strong); transform: translateY(-1px); box-shadow: var(--shadow-card); }
.imp-source.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,122,61,.12); }
.imp-source.dead { cursor: pointer; opacity: .72; }
.imp-source.dead:hover { opacity: 1; transform: none; }
.imp-source-mark {
  width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--hair); color: var(--ink-soft);
}
.imp-source-mark.qb { background: #2CA01C; color: #fff; border-color: #2CA01C; }
.imp-source-mark svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.imp-source-name { font-weight: 700; font-size: 14.5px; }
.imp-source-desc { color: var(--muted); font-size: 12.5px; line-height: 1.45; }

/* ---- "What this imports" scope card ---- */
.imp-scope {
  margin-top: 16px; background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--radius-lg); padding: 18px 20px;
}
.imp-scope h4 { font-size: 13px; font-weight: 700; margin-bottom: 12px; }
.imp-scope ul { list-style: none; display: grid; gap: 7px; }
.imp-scope li { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; color: var(--ink-soft); }
.imp-scope li .ck { flex: 0 0 16px; width: 16px; height: 16px; margin-top: 1px; }
.imp-scope li.yes .ck { color: var(--accent); }
.imp-scope li.no { color: var(--muted); }
.imp-scope li.no .ck { color: var(--red); }
.imp-scope .imp-scope-foot {
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--hair-strong);
  font-size: 12.5px; color: var(--accent-deep); font-weight: 600;
}

/* ---- History list ---- */
.imp-hist-row {
  display: grid; grid-template-columns: 34px 1fr auto auto auto; gap: 16px;
  align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--hair);
}
.imp-hist-row:last-child { border-bottom: 0; }
.imp-hist-mark {
  width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--hair); color: var(--muted);
}
.imp-hist-mark svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.imp-hist-counts { font-family: var(--mono); font-size: 11.5px; color: var(--muted); display: flex; gap: 10px; }
.imp-hist-counts b { color: var(--ink); }

/* ---- Working mode ---- */
.imp-working {
  max-width: 460px; margin: 40px auto; text-align: center;
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--radius-lg); padding: 48px 40px; box-shadow: var(--shadow-card);
}
.imp-spinner {
  width: 40px; height: 40px; border-radius: 50%; margin: 0 auto 22px;
  border: 3px solid var(--hair); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.imp-working h2 { font-size: 20px; letter-spacing: -0.02em; }
.imp-working p { color: var(--muted); font-size: 13.5px; margin-top: 8px; line-height: 1.5; }
.imp-working .imp-working-file {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft);
  background: var(--surface-2); border: 1px solid var(--hair); border-radius: 7px;
  padding: 6px 12px; display: inline-block; margin-top: 18px;
}
.imp-working .imp-cancel { margin-top: 22px; }

/* ---- Result mode ---- */
.imp-result {
  max-width: 560px; margin: 32px auto; background: var(--surface);
  border: 1px solid var(--hair); border-radius: var(--radius-lg);
  padding: 40px; box-shadow: var(--shadow-card);
}
.imp-result-icon {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 20px;
}
.imp-result-icon svg { width: 30px; height: 30px; stroke: #fff; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.imp-result-icon.ok { background: var(--accent); }
.imp-result-icon.fail { background: var(--red); }
.imp-result h2 { font-size: 23px; letter-spacing: -0.025em; }
.imp-result .imp-result-list { list-style: none; margin: 20px 0; display: grid; gap: 10px; }
.imp-result .imp-result-list li {
  display: flex; align-items: baseline; gap: 10px; font-size: 14.5px;
  padding-bottom: 10px; border-bottom: 1px dashed var(--hair);
}
.imp-result .imp-result-list li .n { font-family: var(--mono); font-weight: 700; font-size: 18px; color: var(--ink); min-width: 52px; }
.imp-result .imp-fail-line {
  font-size: 16px; font-weight: 700; color: var(--accent-deep);
  background: var(--accent-soft); border: 1px solid rgba(31,122,61,.3);
  border-radius: 10px; padding: 14px 16px; margin: 18px 0;
}
.imp-result .imp-err-list { list-style: none; display: grid; gap: 6px; margin: 14px 0; }
.imp-result .imp-err-list li { font-family: var(--mono); font-size: 12px; color: #7B2920; }
.imp-result .imp-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.imp-undo {
  margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--hair);
  font-size: 13px; color: var(--muted); line-height: 1.5;
}
.imp-undo .imp-undo-link {
  background: none; border: 0; color: var(--accent-deep); font: inherit; font-weight: 700;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; margin-top: 6px;
}
.imp-undo .imp-undo-link:hover { color: var(--accent-darker); }
.imp-undo-count { font-family: var(--mono); color: var(--ink-soft); font-weight: 600; }

/* ---- Preview: sticky header bar ---- */
.imp-bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius-lg);
  padding: 16px 20px; box-shadow: var(--shadow-card); margin-bottom: 16px;
}
.imp-bar-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.imp-bar-file { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 9px; min-width: 0; }
.imp-bar-file .fn { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-bar-actions { margin-left: auto; display: flex; gap: 10px; }
.imp-counts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.imp-count {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px;
  font-weight: 600; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--hair);
  background: var(--surface-2); color: var(--ink-soft);
}
.imp-count .dot { width: 8px; height: 8px; border-radius: 50%; }
.imp-count .n { font-family: var(--mono); font-weight: 700; }
.imp-count.create .dot { background: var(--accent); }
.imp-count.update .dot { background: var(--blue); }
.imp-count.skip   .dot { background: var(--muted); }
.imp-count.conflict .dot { background: var(--amber); }
.imp-count.error  .dot { background: var(--red); }
.imp-count.total { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---- Warning banner ---- */
.imp-warnbar {
  background: var(--amber-soft); border: 1px solid rgba(182,139,30,.4);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
  display: flex; gap: 12px; align-items: flex-start;
}
.imp-warnbar .ic { flex: 0 0 18px; width: 18px; height: 18px; border-radius: 50%; background: var(--amber); color: #fff; display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 11px; margin-top: 1px; }
.imp-warnbar-body { flex: 1; }
.imp-warnbar-body b { color: #6E5314; font-size: 13.5px; }
.imp-warnbar ul { list-style: none; margin-top: 7px; display: grid; gap: 5px; }
.imp-warnbar li { font-size: 13px; color: #6E5314; display: flex; align-items: center; gap: 8px; }
.imp-warnbar li::before { content: "•"; color: var(--amber); }
.imp-warnbar .imp-warn-link {
  background: none; border: 0; color: var(--accent-deep); font: inherit; font-weight: 700;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer; padding: 0;
}
.imp-warnbar .imp-warn-x { background: none; border: 0; color: #6E5314; cursor: pointer; padding: 4px; opacity: .7; align-self: flex-start; }
.imp-warnbar .imp-warn-x:hover { opacity: 1; }

/* ---- Bulk action toolbar ---- */
.imp-bulk {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--hair); background: var(--surface-2);
}
.imp-bulk .imp-bulk-sel { font-size: 12.5px; color: var(--muted); font-family: var(--mono); }
.imp-bulk .imp-bulk-sel b { color: var(--ink); }
.imp-bulk-group { display: flex; align-items: center; gap: 6px; }
.imp-bulk-group .lbl { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-family: var(--mono); }
.imp-bulk .spacer { flex: 1; }

/* ---- Decision table ---- */
.imp-tbl { width: 100%; border-collapse: collapse; }
.imp-tbl thead th {
  text-align: left; padding: 10px 14px; font-family: var(--mono);
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--hair); white-space: nowrap; font-weight: 600;
}
.imp-tbl thead th.num { text-align: right; }
.imp-tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--hair); font-size: 13.5px; vertical-align: middle; }
.imp-tbl tbody tr.imp-data-row { cursor: pointer; transition: background .12s; }
.imp-tbl tbody tr.imp-data-row:hover { background: var(--surface-2); }
.imp-tbl tbody tr.imp-data-row.expanded { background: var(--accent-soft); }
.imp-tbl .imp-chk { width: 30px; }
.imp-tbl .num { text-align: right; font-family: var(--mono); }
.imp-tbl .imp-match-cell { color: var(--ink-soft); }
.imp-tbl .imp-match-cell .conf { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.imp-tbl .imp-note-cell { color: var(--muted); font-size: 12.5px; }
.imp-decide {
  font-family: var(--sans); font-size: 12px; font-weight: 600; padding: 4px 8px;
  border-radius: 7px; border: 1px solid var(--hair); background: var(--surface-2);
  color: var(--ink-soft); cursor: pointer;
}
.imp-decide:focus { outline: none; border-color: var(--accent); }
.imp-caret { color: var(--muted); transition: transform .15s; display: inline-block; }
tr.expanded .imp-caret { transform: rotate(90deg); }

/* expanded detail row */
.imp-detail-row > td { padding: 0 !important; background: var(--surface-2); border-bottom: 1px solid var(--hair); }
.imp-detail {
  padding: 18px 22px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 22px;
}
.imp-detail h5 {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
.imp-kv { display: grid; gap: 7px; }
.imp-kv .kv { display: grid; grid-template-columns: 130px 1fr; gap: 12px; font-size: 13px; padding-bottom: 7px; border-bottom: 1px dashed var(--hair); }
.imp-kv .kv .k { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.imp-kv .kv .v { font-weight: 500; word-break: break-word; }
.imp-kv .kv .v.mono { font-family: var(--mono); }

/* conflict resolution panel */
.imp-conflict {
  grid-column: 1 / -1; background: var(--surface); border: 1px solid var(--amber);
  border-radius: var(--radius); padding: 18px 20px;
}
.imp-conflict h4 { font-size: 14.5px; margin-bottom: 4px; }
.imp-conflict .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.imp-conflict-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.imp-conflict-col h5 { margin-bottom: 8px; }
.imp-conflict-card {
  background: var(--surface-2); border: 1px solid var(--hair); border-radius: 9px;
  padding: 12px 14px; font-size: 13px; display: grid; gap: 4px;
}
.imp-cand { display: block; margin-bottom: 8px; }
.imp-cand label {
  display: flex; align-items: center; gap: 11px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--hair); border-radius: 9px; padding: 11px 14px;
  transition: border-color .12s, background .12s;
}
.imp-cand label:hover { border-color: var(--hair-strong); }
.imp-cand input:checked + .imp-cand-body { color: var(--ink); }
.imp-cand input { accent-color: var(--accent); width: 16px; height: 16px; flex: 0 0 16px; }
.imp-cand-body { flex: 1; }
.imp-cand-body .nm { font-weight: 600; }
.imp-cand-body .meta { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 2px; }
.imp-cand-conf { font-family: var(--mono); font-size: 11.5px; font-weight: 700; color: var(--accent-deep); }
.imp-conflict-foot { margin-top: 14px; display: flex; gap: 10px; }

/* mapping editor cell */
.imp-map-cell { display: flex; align-items: center; gap: 8px; }
.imp-map-cell .map-val { font-size: 12.5px; }
.imp-map-cell .map-val.unmapped { color: var(--red); font-weight: 600; }
.imp-map-edit { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 3px; border-radius: 5px; }
.imp-map-edit:hover { color: var(--accent-deep); background: var(--accent-soft); }
.imp-map-edit svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.imp-map-select { font-family: var(--sans); font-size: 12.5px; padding: 5px 8px; border-radius: 7px; border: 1px solid var(--accent); background: var(--surface); max-width: 280px; }

/* desktop-only block for narrow viewports */
.imp-mobile-block { display: none; }
@media (max-width: 900px) {
  .imp-preview-wrap { display: none; }
  .imp-mobile-block {
    display: block; max-width: 420px; margin: 40px auto; text-align: center;
    background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius-lg); padding: 40px 28px;
  }
  .imp-mobile-block svg { width: 40px; height: 40px; color: var(--muted); margin-bottom: 16px; }
  .imp-mobile-block h2 { font-size: 19px; }
  .imp-mobile-block p { color: var(--muted); font-size: 13.5px; margin-top: 8px; line-height: 1.5; }
}

/* responsive */
@media (max-width: 1100px) { .imp-sources { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) {
  .imp-sources { grid-template-columns: 1fr; }
  .imp-detail { grid-template-columns: 1fr; }
  .imp-conflict-grid { grid-template-columns: 1fr; }
  .imp-hist-row { grid-template-columns: 34px 1fr auto; }
  .imp-hist-counts { display: none; }
}

/* ==========================================================
   SOFTWARE UPDATES (O.15) — changelog typography
   ========================================================== */
.up-changelog { font-size: 13.5px; color: var(--ink-soft); line-height: 1.6; }
.up-changelog .up-h4 { font-size: 15px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; margin: 4px 0 8px; }
.up-changelog .up-h5 { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--red); margin: 16px 0 6px; }
.up-changelog .up-p { margin: 0 0 10px; }
.up-changelog .up-ul { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 5px; }
.up-changelog .up-ul li { padding-left: 2px; }
.up-changelog code { font-family: var(--mono); font-size: 12px; background: var(--cream); border: 1px solid var(--hair); border-radius: 4px; padding: 1px 5px; }
.up-changelog strong { font-weight: 700; color: var(--ink); }
.up-changelog em { font-style: italic; color: var(--muted); }

/* ==========================================================
   RECEIPTS — Active | Trash switch + soft-delete recovery bin
   ========================================================== */
.rcpt-switch { margin: 16px 0 0; }
.seg-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 5px; margin-left: 2px;
  background: var(--red); color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  border-radius: 999px; letter-spacing: .02em;
}
.seg button.on .seg-badge { background: rgba(255,255,255,.24); }

.rcpt-trash-note {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted);
}
.rcpt-trash-note svg { color: var(--muted); flex: none; }

.rcpt-glyph {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  border: 1px solid var(--hair); border-radius: 7px;
  background: var(--surface-2); color: var(--muted);
}

.rcpt-actions { display: inline-flex; gap: 6px; justify-content: flex-end; }
.rcpt-actions .btn-sm svg { margin-right: 1px; vertical-align: -2px; }
.rcpt-del:not(:disabled):hover { color: var(--red); border-color: rgba(178,58,47,.4); background: rgba(178,58,47,.06); }
#trashTbl .tbl td:last-child { width: 1%; white-space: nowrap; }

/* Mobile: collapse trash rows into stacked cards */
@media (max-width: 640px) {
  #trashTbl .tbl, #trashTbl .tbl tbody, #trashTbl .tbl tr, #trashTbl .tbl td { display: block; width: auto; }
  #trashTbl .tbl thead { display: none; }
  #trashTbl .tbl tr {
    border: 1px solid var(--hair); border-radius: 12px;
    background: var(--surface); padding: 12px 14px; margin-bottom: 12px;
  }
  #trashTbl .tbl td {
    border: 0; padding: 5px 0; text-align: right;
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
  }
  #trashTbl .tbl td::before {
    content: attr(data-label);
    font-family: var(--mono); font-size: 10px; letter-spacing: .05em;
    text-transform: uppercase; color: var(--muted); text-align: left; flex: none;
  }
  #trashTbl .tbl td[data-key="glyph"] { display: none; }
  #trashTbl .tbl td[data-key="vendor"] { padding-top: 0; }
  #trashTbl .tbl td[data-key="vendor"]::before { content: none; }
  #trashTbl .tbl td.num { text-align: right; }
  #trashTbl .tbl td[data-key="act"] { padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--hair); }
  #trashTbl .tbl td[data-key="act"]::before { content: none; }
  #trashTbl .rcpt-actions { width: 100%; gap: 8px; }
  #trashTbl .rcpt-actions .btn { flex: 1; justify-content: center; }
}

