/* Design tokens from the Mindgrove brand guide */
:root {
    --cream: #ebe9da;
    --page: #f4f3ea;
    --white: #ffffff;
    --ink: #121713;
    --ink-soft: #3d433e;
    --muted: #63695f;
    --line: rgba(18, 23, 19, 0.15);

    --green: #4da350;
    --green-dark: #3b5a3b;
    --green-deep: #262c22;
    --green-light: #96d389;
    --green-tint: #e3f2df;
    --green-text: #2f6b33;

    --yellow: #f4c04d;
    --yellow-dark: #d4a443;
    --yellow-light: #f7cf7c;
    --yellow-tint: #fcf0d2;
    --brown: #6f5229;

    --red-text: #9b2c1f;
    --red-tint: #f8e1dc;

    --radius: 10px;
    --radius-pill: 999px;
    --font: "Mulish", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font: 400 15px/1.5 var(--font);
}

h1, h2, h3 { font-weight: 600; line-height: 1.25; margin: 0 0 16px; }
h1 { font-size: 24px; }
a { color: var(--green-text); }
.muted { color: var(--muted); }

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 24px;
    background: var(--white);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.brand-name { font-weight: 500; letter-spacing: 0.04em; }
.brand-product {
    font-size: 13px;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    background: var(--green-tint);
    color: var(--green-text);
    font-weight: 600;
}
.nav { display: flex; gap: 4px; }
.nav a {
    color: var(--ink-soft);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-weight: 500;
    white-space: nowrap;
}
.nav a:hover { background: var(--page); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--white); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.logout { margin: 0; }
.nav-toggle { display: none; }

/* Controls */
.btn {
    font: inherit;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    padding: 8px 18px;
    cursor: pointer;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--white); }
.btn-primary:not(:disabled):hover { background: var(--green-deep); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--page); }
.btn-block { width: 100%; }

input[type="password"], input[type="text"], input[type="search"] {
    font: inherit;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--ink);
}
.search { width: 240px; border-radius: var(--radius-pill); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* Content */
.page { max-width: 1280px; margin: 0 auto; padding: 24px; }
.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
}
.empty p { margin: 0 0 8px; }
.chip {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
}
.chip-green { background: var(--green-tint); color: var(--green-text); }
.chip-yellow { background: var(--yellow-tint); color: var(--brown); }
.chip-red { background: var(--red-tint); color: var(--red-text); }
.alert { background: var(--red-tint); color: var(--red-text); padding: 10px 12px; border-radius: var(--radius); }
.notice { background: var(--green-tint); color: var(--green-text); padding: 10px 12px; border-radius: var(--radius); }
.small { font-size: 13px; }
.page > .card + .card { margin-top: 16px; }
.page > .notice, .page > .alert { margin: 0 0 16px; }

/* Forms */
select {
    font: inherit;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--ink);
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
}
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
.form-grid label input, .form-grid label select { font-weight: 400; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
form.inline input[type="password"] { width: 170px; padding: 6px 10px; }
form.inline select { padding: 5px 8px; }
.btn-small { padding: 5px 12px; font-size: 13px; }

/* Tables scroll in their own box at narrow widths */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table th { font-size: 13px; font-weight: 600; color: var(--muted); }
.table tr.inactive td { color: var(--muted); }
code { font-size: 13px; background: var(--page); padding: 1px 6px; border-radius: 6px; }

/* Login */
.login-page { background: var(--cream); }
.login { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; font-size: 20px; }
.login-card { display: flex; flex-direction: column; gap: 8px; padding: 28px; }
.login-card h1 { margin: 0; }
.login-card p { margin: 0 0 8px; }
.login-card label { font-weight: 600; font-size: 14px; margin-top: 4px; }
.login-card .btn { margin-top: 12px; }

/* Phone width: nav collapses behind a Menu button */
@media (max-width: 1080px) {
    .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
    .nav-toggle { display: inline-block; margin-left: auto; font: inherit; font-weight: 600; background: none;
        border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 6px 14px; }
    .nav { display: none; flex-direction: column; width: 100%; }
    .nav.open { display: flex; }
    .topbar-actions { width: 100%; margin-left: 0; }
    .search { flex: 1; width: auto; min-width: 0; }
    .page { padding: 16px; }
}

/* Utilities */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.strong { font-weight: 600; color: var(--ink); }
.chip-outline { background: var(--white); border: 1px solid var(--line); color: var(--ink-soft); font-weight: 500; }
.chip-muted { background: var(--page); color: var(--muted); font-weight: 500; }
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--green-dark); color: var(--white); font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
}
.brand img { display: block; }

/* Page header with view toggle */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.page-head h1 { margin: 0 0 4px; font-size: 28px; }
.page-head p { margin: 0; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--white); }
.segmented a { padding: 6px 16px; border-radius: var(--radius-pill); color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: 14px; }
.segmented a[aria-current] { background: var(--ink); color: var(--white); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0 8px 0 0; }
.filter-label { float: left; margin-right: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.chip-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.chip-toggle span {
    display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: var(--radius-pill);
    background: var(--white); font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
.chip-toggle input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--white); }
.chip-toggle input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }
.select-pill select { border-radius: var(--radius-pill); padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--ink-soft); max-width: 220px; }
.clear-filters { font-size: 13px; font-weight: 600; }

/* Board */
.board { display: flex; gap: 12px; align-items: stretch; overflow-x: auto; padding-bottom: 12px; }
.phase { flex: 0 0 auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.phase-pre_sales { background: var(--cream); }
.phase-sales { background: var(--white); }
.phase-head { display: flex; align-items: baseline; gap: 10px; margin: 0 4px 10px; }
.phase-head h2 { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.phase-head .muted { font-size: 13px; }
.columns { display: flex; gap: 12px; }
.column { width: 248px; display: flex; flex-direction: column; gap: 8px; border-radius: 8px; transition: background 0.15s; }
.column.drop-target { background: var(--green-tint); outline: 2px dashed var(--green); outline-offset: 2px; }
.column-head { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px; }
.column-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.deal-card {
    display: flex; flex-direction: column; gap: 6px; padding: 12px;
    background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); cursor: grab;
}
.deal-card[draggable="false"] { cursor: default; }
.deal-card.dragging { opacity: 0.5; }
.deal-name { font-weight: 600; color: var(--ink); text-decoration: none; line-height: 1.35; }
.deal-name:hover { text-decoration: underline; }
.deal-account { font-size: 13px; color: var(--muted); }
.deal-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.deal-tags .chip { font-size: 11px; padding: 2px 8px; }
.deal-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 6px; border-top: 1px solid rgba(18, 23, 19, 0.06); font-size: 13px; }
.deal-value { font-weight: 600; color: var(--ink); }
.deal-actions { display: inline-flex; align-items: center; gap: 6px; }
.deal-actions .btn-small { padding: 3px 10px; font-size: 12px; }
.column-empty { margin: 0; padding: 16px 12px; border: 1px dashed rgba(18, 23, 19, 0.25); border-radius: var(--radius); font-size: 13px; color: var(--muted); line-height: 1.5; }
.gate-marker { flex: 0 0 auto; display: flex; align-items: center; }
.gate-marker span {
    writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--brown); background: var(--yellow-tint); border: 1px solid var(--yellow-dark);
    border-radius: var(--radius-pill); padding: 12px 4px;
}
.board-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.pill-link { padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--white); color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 600; }
.pill-link:hover { background: var(--page); }
.board-hint { margin-left: auto; }

/* Stage tiles (table view) */
.tiles { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.tile-group { flex: 1 1 480px; min-width: 0; padding: 14px; background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius); }
.tile-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tile {
    display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; background: var(--white);
    border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-decoration: none;
}
.tile:hover { border-color: var(--ink-soft); }
.tile-on { outline: 2px solid var(--ink); outline-offset: -1px; }
.tile-name { font-size: 13px; color: var(--ink-soft); min-height: 34px; line-height: 1.3; }
.tile-count { font-size: 22px; font-weight: 700; }
progress.bar { width: 100%; height: 6px; border: 0; border-radius: 3px; background: rgba(18, 23, 19, 0.06); overflow: hidden; appearance: none; }
progress.bar::-webkit-progress-bar { background: rgba(18, 23, 19, 0.06); border-radius: 3px; }
progress.bar::-webkit-progress-value { background: var(--green); border-radius: 3px; }
progress.bar::-moz-progress-bar { background: var(--green); border-radius: 3px; }

/* Deals table */
.table-card { padding: 0; overflow: hidden; }
.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table-card .filters { padding: 12px 16px 0; margin: 0 0 4px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs a { padding: 6px 12px; border-radius: var(--radius-pill); color: var(--ink-soft); text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tabs a:hover { background: var(--page); }
.tabs a[aria-current] { background: var(--ink); color: var(--white); }
.stage-filter { margin: 8px 16px 0; font-size: 13px; }
.deals-table { min-width: 1100px; font-size: 14px; }
.deals-table th a { color: var(--muted); text-decoration: none; }
.deals-table th a:hover { color: var(--ink); }
.deals-table th a[aria-sort] { color: var(--ink); }
.deals-table td { white-space: normal; }
.deal-cell a { display: flex; flex-direction: column; gap: 2px; text-decoration: none; }
.deal-cell .muted { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.num { text-align: right; }
.phase-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-right: 4px; }
.flags-cell { display: flex; flex-wrap: wrap; gap: 4px; }
.flags-cell .chip { font-size: 11px; padding: 2px 8px; }
.empty-row { text-align: center; padding: 32px; }
.table-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 12px 16px; font-size: 13px; }
.pager { display: flex; gap: 12px; align-items: center; }

/* Move dialog */
.dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(480px, calc(100vw - 32px)); color: var(--ink); }
.dialog::backdrop { background: rgba(18, 23, 19, 0.45); }
.dialog-body { display: flex; flex-direction: column; gap: 12px; padding: 24px; margin: 0; }
.dialog-body h2 { margin: 0; font-size: 20px; }
.dialog-body > p { margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
.field textarea { font: inherit; font-weight: 400; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); resize: vertical; }
.small-head { margin: 4px 0 6px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.checklist li::before { display: inline-block; width: 20px; font-weight: 700; }
.checklist li.met::before { content: "✓"; color: var(--green-text); }
.checklist li.unmet::before { content: "✗"; color: var(--red-text); }
.checklist li.manual::before { content: "?"; color: var(--brown); }
.gate { padding: 12px; background: var(--yellow-tint); border: 1px solid var(--yellow-dark); border-radius: var(--radius); }
.gate .small-head { margin-top: 0; color: var(--brown); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Interim deal page */
.crumbs { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.stepper { list-style: none; margin: 16px 0 20px; padding: 0; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.stepper li { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: var(--muted); line-height: 1.3; }
.step-bar { display: block; height: 6px; border-radius: 3px; background: rgba(18, 23, 19, 0.08); }
.stepper li.done .step-bar { background: var(--green-light); }
.stepper li.current .step-bar { background: var(--green); }
.stepper li.current { color: var(--ink); font-weight: 700; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.summary-grid h2 { font-size: 16px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.history li { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }

@media (max-width: 700px) {
    .tile-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .board-hint { margin-left: 0; }
    .stepper { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.deals-table td.num { white-space: nowrap; }
