/* Oxford's LAB — shared design system.
 *
 * Tokens, base typography and the components every tool page shares (top nav,
 * buttons, inputs, cards, KPI tiles, tables, tags, toasts). Page-specific layout
 * stays in each page's own <style> block, written against these tokens — never
 * raw hex — so the whole suite re-themes from this one file.
 *
 * The look follows Firm Prospects' public site: a light gray canvas, near-black
 * ink, ONE accent, a grotesk for reading paired with an uppercase mono for
 * labels, flat surfaces (hairlines, no shadows or glows), small radii, square
 * tags. The accent is Oxford's own green, deepened from the logo until white
 * text on it clears 4.5:1 (#1f7a33 = 5.4:1; the old #22c55e managed 2.2:1).
 *
 * Fonts are loaded by each page's <head>:
 *   Geist (400/500/600) + Geist Mono (400/500) from Google Fonts.
 */

:root {
    /* Surfaces */
    --bg: #f6f6f6;
    --surface: #ffffff;          /* cards, the top bar, popovers: pure white, as in the FP app */
    --surface-2: #efefef;          /* wells: inputs, table heads, code */
    --surface-3: #e7e7e7;          /* a well, hovered */
    --inverse: #151515;
    --on-inverse: #f6f6f6;

    /* Ink — one colour at four strengths. ink-3 is the weakest that still
       clears 4.5:1 on --bg; ink-4 is for placeholders and disabled only. */
    --ink: #151515;
    --ink-2: rgba(21, 21, 21, .72);
    --ink-3: rgba(21, 21, 21, .6);
    --ink-4: rgba(21, 21, 21, .42);

    /* Hairlines and tints */
    --line: rgba(21, 21, 21, .09);
    --line-2: rgba(21, 21, 21, .16);
    --fill: rgba(21, 21, 21, .045);
    --fill-2: rgba(21, 21, 21, .08);
    --fill-3: rgba(21, 21, 21, .12);

    /* Accent — Oxford green */
    --accent: #1f7a33;
    --accent-hover: #18642a;
    --accent-soft: rgba(31, 122, 51, .1);
    --accent-line: rgba(31, 122, 51, .38);
    --on-accent: #ffffff;

    /* Status */
    --ok: #1f7a33;
    --ok-soft: rgba(31, 122, 51, .1);
    --warn: #a8560f;
    --warn-soft: rgba(197, 106, 33, .12);
    --err: #b93232;
    --err-soft: rgba(201, 64, 64, .1);
    --info: #1268a3;
    --info-soft: rgba(19, 121, 183, .1);

    /* Vector basemap (labBasemap in lab.js): the flat gray-on-white of the reference map */
    --map-sea: #ffffff;
    --map-land: #ececec;
    --map-border: #a6a6a6;
    --map-state: #d2d2d2;

    /* Top bar size -- see the SIZE note on .lab-nav. On :root, not .lab-nav, because
       other things measure against the bar (Firm Screener's pinned rail and results card). */
    --bar-h: 76px;
    --bar-font: 19px;          /* tool labels */
    --bar-icon: 27px;          /* tool icons */
    --bar-link-pad: 18px;
    --bar-brand: 23px;         /* "Oxford's LAB" */
    --bar-mark: 40px;          /* logo mark height */
    --bar-find-w: 300px;
    --bar-ctl: 46px;           /* find box + account button height */

    /* Type */
    --font-sans: 'Geist', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Geist Mono', ui-monospace, 'Cascadia Mono', 'SF Mono', Consolas, monospace;

    /* Shape */
    --r-xs: 2px;
    --r-sm: 4px;
    --r: 6px;
    --r-lg: 10px;
    --r-xl: 16px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    color: var(--ink);
    font-weight: 500;
    letter-spacing: -.02em;
    line-height: 1.15;
}

a { color: inherit; }

::selection { background: rgba(31, 122, 51, .2); }

:focus-visible {
    outline: 2px solid var(--accent-line);
    outline-offset: 2px;
}

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--line-2);
    border: 3px solid transparent;
    border-radius: 8px;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--ink-4); }

input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

.hidden { display: none !important; }

/* The label voice: uppercase mono, tracked. Used for nav buttons, field
   labels, table heads, KPI captions, tags — anything that names data. */
.mono-label {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .07em;
    text-transform: uppercase;
}

/* ---------- Top bar (written in place by lab.js) ----------
   Modelled on the bar in Firm Prospects' app: a full-width white strip, a line
   icon beside every tool, the current tool marked by a full-height tinted
   block, a find box and an account menu on the right. It scrolls away with the
   page rather than sticking — these are long, dense pages, and a static bar
   never has to win a z-index fight with Leaflet or a page's own overlays.

   SIZE. Every dimension of the bar hangs off the --bar-* tokens in :root, so it scales
   from one place (the breakpoints at the end of this block only re-set tokens).
   The numbers come from the reference, proportionally: FP's bar and ours were the
   same raw size (56px, ~14.5px labels), but FP's page text is 13px, so its bar
   labels are ~10% LARGER than the page's own tabs and the bar reads as the main
   strip -- while on Firm View, whose tabs are 20px, ours read ~25% SMALLER than the
   tabs under it. 19px labels / 76px restores FP's relationship there (and is about
   what Firm View's old nav was: ~74px with a 35px brand). */
.lab-nav {
    display: flex;
    align-items: stretch;
    height: var(--bar-h);
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.lab-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: none;
    margin-right: 24px;
    color: var(--ink);
    font-size: var(--bar-brand);
    font-weight: 600;
    letter-spacing: -.02em;
    text-decoration: none;
    white-space: nowrap;
}
/* Logo.png is the full "Oxford Strategic Legal Advisors" lockup; at bar height
   its small print is mush, so show only the sunburst mark (its left third). */
.lab-brand-mark {
    width: calc(var(--bar-mark) * .9);      /* the mark is 27:30 */
    height: var(--bar-mark);
    flex: none;
    background: url('/static/Logo.png') left center / auto 100% no-repeat;
}
.lab-nav-links {
    position: relative;            /* offsetParent for lab.js's scroll-to-current */
    display: flex;
    align-items: stretch;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.lab-nav-links::-webkit-scrollbar { display: none; }
.lab-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
    padding: 0 var(--bar-link-pad);
    color: var(--ink-2);
    font-size: var(--bar-font);
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.lab-nav-link:hover { background: var(--fill); color: var(--ink); }
.lab-nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.lab-icon { width: var(--bar-icon); height: var(--bar-icon); flex: none; }
/* Tool icons step through the logo's own green-to-blue sweep, each deepened
   until a 1.5px stroke holds up on white. */
.lab-icon-firmview { color: hsl(105 58% 29%); }
.lab-icon-merger   { color: hsl(125 58% 28%); }
.lab-icon-laterals { color: hsl(148 62% 27%); }
.lab-icon-chambers { color: hsl(168 68% 26%); }
.lab-icon-location { color: hsl(186 70% 28%); }
.lab-icon-mapgen   { color: hsl(198 72% 31%); }
.lab-icon-profile  { color: hsl(208 70% 36%); }

.lab-nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: none;
    margin-left: 16px;
}

/* Popovers are the one place a shadow is allowed: they float over content. */
.lab-pop {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 1200;                  /* above Leaflet's controls (1000) */
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: var(--r-lg);
    box-shadow: 0 10px 28px rgba(21, 21, 21, .1);
    overflow: hidden;
}

.lab-find { position: relative; color: var(--ink-3); }
.lab-find .lab-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
    pointer-events: none;
}
/* `.lab-nav X` rather than bare `.X` throughout the bar's controls: some pages style naked
   input/button elements (0,1,1), and the bar has to out-rank that. */
.lab-nav .lab-find-input {
    width: var(--bar-find-w);
    height: var(--bar-ctl);
    padding: 0 14px 0 44px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 16.5px;
    transition: border-color .15s, box-shadow .15s;
}
.lab-nav .lab-find-input::placeholder { color: var(--ink-4); }
.lab-nav .lab-find-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* Right-anchored (from .lab-pop): the box sits at the bar's right end, so the
   list has to grow leftwards or it pushes the page wider than the window. */
.lab-find-list { min-width: 100%; width: 420px; padding: 6px; }
.lab-find-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    color: var(--ink);
    font-size: 15.5px;
    cursor: pointer;
}
.lab-find-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lab-find-item .tag { flex: none; font-size: 10.5px; }
.lab-find-item.on, .lab-find-item:hover { background: var(--accent-soft); color: var(--accent); }
.lab-find-empty { padding: 10px 12px; color: var(--ink-3); font-size: 14.5px; }

.lab-user { position: relative; }
.lab-nav .lab-user-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--bar-ctl);
    height: var(--bar-ctl);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.lab-user-btn .lab-icon { width: 36px; height: 36px; stroke-width: 1.2; }
.lab-nav .lab-user-btn:hover, .lab-nav .lab-user-btn[aria-expanded="true"] { background: var(--fill-2); color: var(--ink); }
.lab-menu { min-width: 210px; padding: 6px; }
.lab-menu-who { padding: 8px 10px 9px; margin-bottom: 4px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.lab-nav .lab-menu-item {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--ink);
    font-family: inherit;
    font-size: 15.5px;
    font-weight: 400;
    letter-spacing: normal;
    line-height: 1.4;
    text-align: left;
    text-transform: none;
    white-space: nowrap;
    cursor: pointer;
}
.lab-nav .lab-menu-item:hover { background: var(--fill-2); }

/* At full size the bar needs ~1670px. Each step below buys room by re-setting tokens;
   past the last one the link strip scrolls sideways (lab.js centres the current tool). */
@media (max-width: 1760px) { :root { --bar-find-w: 220px; } }
@media (max-width: 1600px) { .lab-brand-name { display: none; } .lab-brand { margin-right: 12px; } }
@media (max-width: 1440px) { :root { --bar-h: 68px; --bar-font: 17px; --bar-icon: 24px; --bar-link-pad: 14px; --bar-mark: 36px; --bar-ctl: 42px; } }
@media (max-width: 1300px) { .lab-find { display: none; } }
@media (max-width: 1060px) {
    /* The strip scrolls here; fade its edge so it reads as "more this way". */
    .lab-nav-links {
        -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
        mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    }
}
@media (max-width: 720px) {
    :root { --bar-h: 60px; --bar-font: 16px; --bar-icon: 22px; --bar-link-pad: 12px; --bar-mark: 32px; --bar-ctl: 40px; }
    .lab-nav { padding: 0 8px; }
    .lab-user-btn .lab-icon { width: 30px; height: 30px; }
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--r);
    background: var(--fill-2);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: .07em;
    line-height: 1;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--fill-3); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border-color: var(--line-2); }
.btn-outline:hover { background: var(--fill); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--fill); color: var(--ink); }
.btn-danger { background: var(--err-soft); color: var(--err); }
.btn-danger:hover { background: rgba(201, 64, 64, .18); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 10.5px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary:disabled:hover { background: var(--accent); }

.button-group { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Form fields ---------- */
.label {
    display: block;
    margin-bottom: 8px;
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .07em;
    text-transform: uppercase;
}
.input, .select, .textarea {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: var(--r);
    background-color: var(--surface-2);
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 10px 12px; line-height: 1.5; }
/* background-color, not the shorthand, in every state: the shorthand would wipe the select's chevron. */
.select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23151515' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .select:hover, .textarea:hover { background-color: var(--surface-3); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    background-color: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.hint { color: var(--ink-3); font-size: 12.5px; line-height: 1.5; }

.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-2);
    font-size: 13.5px;
    cursor: pointer;
    user-select: none;
}
.check input { width: 15px; height: 15px; margin: 0; }

/* ---------- Page scaffolding ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px 56px; }

.page-head { margin: 8px 0 24px; }
.page-head h1 { font-size: 32px; letter-spacing: -.035em; margin: 12px 0 0; }
.page-head p { max-width: 640px; margin: 10px 0 0; color: var(--ink-2); font-size: 15px; }

/* Eyebrow: FP's tag-with-a-square, in our green. */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.eyebrow::before { content: ''; width: 7px; height: 7px; flex: none; background: var(--accent); }

.card, .section {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 24px;
    margin-bottom: 16px;
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-bottom: 16px;
}
.card-title { margin: 0; font-size: 17px; font-weight: 500; letter-spacing: -.02em; }

/* ---------- KPI tiles ---------- */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}
.kpi-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 18px 20px 20px;
    text-align: left;
}
.kpi-label {
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .07em;
    text-transform: uppercase;
}
.kpi-value {
    margin-top: 12px;
    color: var(--ink);
    font-size: 36px;
    font-weight: 500;
    letter-spacing: -.035em;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line-2);
    background: var(--surface);
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: .07em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
    user-select: none;
}
.tbl th[onclick], .tbl th.sortable { cursor: pointer; transition: color .15s; }
.tbl th[onclick]:hover, .tbl th.sortable:hover { color: var(--ink); }
.tbl td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    vertical-align: top;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--fill); }
/* Totals row: ruled off in ink, the way a ledger does it. */
.tbl tfoot td {
    border-top: 1px solid var(--ink);
    border-bottom: 0;
    background: var(--fill);
    font-weight: 600;
}
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Sort indicator: the markup carries a legacy "▲▼" pair; hide it and draw one
   arrow that says which way the column is actually sorted. */
.sort-arrow { margin-left: 6px; font-size: 0; }
.sort-arrow::after { content: '\2195'; font-size: 11px; opacity: .35; }
.sort-asc .sort-arrow::after { content: '\2191'; opacity: 1; color: var(--accent); }
.sort-desc .sort-arrow::after { content: '\2193'; opacity: 1; color: var(--accent); }

/* ---------- Tags ---------- */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 7px;
    border-radius: var(--r-xs);
    background: var(--fill-2);
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: .07em;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
}
.tag-accent { background: var(--accent); color: var(--on-accent); }
.tag-soft { background: var(--accent-soft); color: var(--accent); }
.tag-inverse { background: var(--inverse); color: var(--on-inverse); }

/* ---------- Feedback ---------- */
.error, .warning {
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: var(--r);
    font-size: 13.5px;
}
.error { background: var(--err-soft); border-color: rgba(201, 64, 64, .22); color: var(--err); }
.warning { background: var(--warn-soft); border-color: rgba(197, 106, 33, .25); color: var(--warn); }

.loading {
    padding: 56px 24px;
    text-align: center;
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: .07em;
    text-transform: uppercase;
}
.spinner {
    width: 28px;
    height: 28px;
    margin: 0 auto 16px;
    border: 2px solid var(--line-2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: lab-spin .8s linear infinite;
}
@keyframes lab-spin { to { transform: rotate(360deg); } }

.success-toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2000;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--r);
    background: var(--inverse);
    color: var(--on-inverse);
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: .06em;
    text-transform: uppercase;
    animation: lab-rise .25s ease-out;
}
.success-toast::before { content: ''; width: 7px; height: 7px; flex: none; background: #2ad87f; }
.success-toast.show { display: flex; }
@keyframes lab-rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Paste grid (Merger, Map Generator) ----------
   The spreadsheet-style Location / Lawyers / Partners input. Cells are bare
   inputs; selection classes are toggled by each page's own grid code. */
.spreadsheet {
    position: relative;
    margin-top: 20px;
    border: 1px solid var(--line-2);
    border-radius: var(--r) var(--r) 0 0;
    background: var(--surface);
    overflow: hidden;
}
.spreadsheet table { width: 100%; border-collapse: collapse; }
.spreadsheet th {
    padding: 9px 10px;
    border-bottom: 1px solid var(--line-2);
    background: var(--surface-2);
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: .07em;
    text-align: left;
    text-transform: uppercase;
    cursor: default;
    user-select: none;
}
.spreadsheet th:not(:last-child) { border-right: 1px solid var(--line-2); }
.spreadsheet td { padding: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.spreadsheet td:last-child { border-right: none; }
.spreadsheet tr:last-child td { border-bottom: none; }
.spreadsheet td input {
    width: 100%;
    padding: 8px 10px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
}
.spreadsheet td input::placeholder { color: var(--ink-4); opacity: .7; }
.spreadsheet td input:focus { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.spreadsheet td input.cell-selected { background: rgba(31, 122, 51, .16); }
.spreadsheet.dragging, .spreadsheet.dragging input { user-select: none; }
/* Location | Lawyers | Partners sheets: everything after the first column is a number. */
.spreadsheet.sheet-numeric th:not(:first-child) { text-align: right; }
.spreadsheet.sheet-numeric td input:not([data-col="0"]) { text-align: right; font-variant-numeric: tabular-nums; }
.spreadsheet col.col-number { width: 22%; }

.add-row-btn {
    display: block;
    width: 100%;
    margin-top: -1px;
    padding: 8px 16px;
    border: 1px dashed var(--line-2);
    border-radius: 0 0 var(--r) var(--r);
    background: none;
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .07em;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.add-row-btn:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ---------- Saved-items popover (Saved Mergers, Saved Lists) ---------- */
.head-actions { display: flex; align-items: center; gap: 8px; }
.saved-dropdown { position: relative; }
.saved-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 1200;
    min-width: 300px;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--line-2);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: 0 10px 28px rgba(21, 21, 21, .1);
}
.saved-panel.open { display: block; }
.saved-panel-header {
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--line);
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: .07em;
    text-transform: uppercase;
}
.saved-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background .1s;
}
.saved-item:last-child { border-bottom: none; }
.saved-item:hover { background: var(--fill); }
.saved-item-info { flex: 1; min-width: 0; }
.saved-item-name {
    display: block;
    color: var(--ink);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.saved-item-date { color: var(--ink-3); font-size: 11.5px; }
.saved-item-delete {
    flex-shrink: 0;
    padding: 4px;
    border: none;
    background: none;
    color: var(--err);
    font-size: 18px;
    line-height: 1;
    opacity: .45;
    cursor: pointer;
}
.saved-item-delete:hover { opacity: 1; }
.saved-empty { padding: 18px 14px; color: var(--ink-3); font-size: 13px; text-align: center; }

/* ---------- Map card (Leaflet) ---------- */
.lab-map {
    height: 500px;
    border: 1px solid var(--line-2);
    border-radius: var(--r);
    background: var(--map-sea);
}
/* Only matters when labBasemap falls back to raster tiles: tiles land on fractional
   pixel offsets (zoomSnap 0.5, HiDPI screens), which leaves hairline seams between
   them - overlap each tile by half a pixel. The vector basemap has no tiles. */
.leaflet-tile { width: 256.5px !important; height: 256.5px !important; }
.leaflet-container { font-family: var(--font-sans); }
/* The reference's plain white +/- box: Leaflet's default has a heavy drop shadow. */
.leaflet-container .leaflet-bar { border: 1px solid var(--line-2); border-radius: var(--r-sm); box-shadow: none; }
.leaflet-container .leaflet-bar a { color: var(--ink-2); border-bottom-color: var(--line); }
.leaflet-container .leaflet-bar a:hover { background: var(--surface-2); color: var(--ink); }
.leaflet-container .leaflet-control-attribution { background: rgba(255, 255, 255, .8); color: var(--ink-3); font-size: 10.5px; }
.map-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line-2); }
.map-tab {
    margin-bottom: -1px;
    padding: 10px 18px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--ink-3);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.map-tab:hover { color: var(--ink); }
.map-tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.map-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 14px; color: var(--ink-2); font-size: 13px; }
.map-legend-item { display: flex; align-items: center; gap: 7px; }
.map-legend-item.note { color: var(--ink-3); }
.map-legend-dot { width: 12px; height: 12px; border-radius: 50%; opacity: .75; }
.map-loading {
    padding: 18px;
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: .07em;
    text-align: center;
    text-transform: uppercase;
}

/* ---------- Dither motif (drawn by labDither in lab.js) ---------- */
.dither { display: block; pointer-events: none; user-select: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
    .spinner { animation-duration: 1.6s !important; }
}

/* ---- Account menu extras: a separator, and the Change-password modal (the
   second place a shadow is allowed: it floats over the page). ---- */
.lab-menu-sep { height: 1px; margin: 4px 0; background: var(--line); }
.lab-modal-back {
    position: fixed;
    inset: 0;
    z-index: 1300;                  /* above the bar's popovers (1200) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(21, 21, 21, .35);
}
.lab-modal {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: var(--r-xl);
    box-shadow: 0 16px 40px rgba(21, 21, 21, .16);
}
.lab-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 24px 0; }
.lab-modal-head h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.lab-modal .lab-modal-x {
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: var(--ink-3);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}
.lab-modal .lab-modal-x:hover { color: var(--ink); }
.lab-modal-body { padding: 18px 24px 24px; }
.lab-modal-body .input { margin-bottom: 14px; }
.lab-modal-body .hint { margin: -8px 0 14px; }
.lab-modal-error { margin-top: 4px; }
.lab-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
