/* ====================================================================
   SOOFI STUDIO — V4
   One stylesheet. Replaces 37 files.

   Design note: the countdown numeral is the spine of this interface.
   A label's work orients to one immovable date — the release date, the
   signing deadline, the contract expiry. Everything counts backwards to
   it. So days-remaining is set large, in tabular figures, and shifts
   colour as the date closes in. Everything else stays quiet.
   ==================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:ital,wght@0,400..700;1,400..700&display=swap');

/* --------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------- */
:root {
    /* Surfaces — cool paper, not cream */
    --paper:        #FAFAF8;
    --surface:      #FFFFFF;
    --surface-sunk: #F2F3F0;
    --line:         #E2E4DF;
    --line-strong:  #C9CDC5;

    /* Ink — deep pine-black */
    --ink:          #14211C;
    --ink-soft:     #4A564F;
    --ink-faint:    #7C867F;

    /* Pine — primary */
    --pine:         #1F3D34;
    --pine-hover:   #2A5245;
    --pine-wash:    #EDF2EF;

    /* Moss — healthy, on track */
    --moss:         #3F7A61;
    --moss-wash:    #E8F2EC;

    /* Brass — time is passing */
    --brass:        #9A6B24;
    --brass-wash:   #FBF2E3;

    /* Clay — late, expired, destructive */
    --clay:         #9C3B2E;
    --clay-wash:    #FBECE9;

    /* Slate — neutral info */
    --slate:        #3C5468;
    --slate-wash:   #ECF1F5;

    /* Type */
    --font: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

    --t-xs:   0.75rem;    /* 12 */
    --t-sm:   0.8125rem;  /* 13 */
    --t-base: 0.9375rem;  /* 15 */
    --t-md:   1.0625rem;  /* 17 */
    --t-lg:   1.375rem;   /* 22 */
    --t-xl:   1.875rem;   /* 30 */
    --t-2xl:  2.5rem;     /* 40 */

    /* Space — 4px base */
    --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
    --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

    --r-sm: 6px;
    --r:    10px;
    --r-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(20, 33, 28, .06);
    --shadow:    0 2px 8px rgba(20, 33, 28, .07);
    --shadow-lg: 0 12px 32px rgba(20, 33, 28, .13);

    --nav-w: 230px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper:        #10140F;
        --surface:      #181D18;
        --surface-sunk: #1F2520;
        --line:         #2C342D;
        --line-strong:  #3E4840;

        --ink:          #E8EBE6;
        --ink-soft:     #A8B2A9;
        --ink-faint:    #78827A;

        --pine:         #7FB89F;
        --pine-hover:   #96C9B1;
        --pine-wash:    #1B2822;

        --moss:         #6FB592;
        --moss-wash:    #182720;

        --brass:        #D6A45C;
        --brass-wash:   #2A2217;

        --clay:         #E08270;
        --clay-wash:    #2B1B18;

        --slate:        #8FB0C9;
        --slate-wash:   #1A2229;

        --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
        --shadow:    0 2px 8px rgba(0,0,0,.35);
        --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
    }
}

:root[data-theme="dark"] {
    --paper:        #10140F;
    --surface:      #181D18;
    --surface-sunk: #1F2520;
    --line:         #2C342D;
    --line-strong:  #3E4840;
    --ink:          #E8EBE6;
    --ink-soft:     #A8B2A9;
    --ink-faint:    #78827A;
    --pine:         #7FB89F;
    --pine-hover:   #96C9B1;
    --pine-wash:    #1B2822;
    --moss:         #6FB592;
    --moss-wash:    #182720;
    --brass:        #D6A45C;
    --brass-wash:   #2A2217;
    --clay:         #E08270;
    --clay-wash:    #2B1B18;
    --slate:        #8FB0C9;
    --slate-wash:   #1A2229;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow:    0 2px 8px rgba(0,0,0,.35);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
}

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

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

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: var(--t-base);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv05' 1, 'ss01' 1;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; letter-spacing: -0.015em; }
h1 { font-size: var(--t-xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); }
h4 { font-size: var(--t-base); }

p { margin: 0 0 var(--s3); }
p:last-child { margin-bottom: 0; }

a { color: var(--pine); text-decoration: none; }
a:hover { color: var(--pine-hover); }

small { font-size: var(--t-sm); }

code, .mono {
    font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, monospace;
    font-size: 0.9em;
    font-variant-ligatures: none;
}

img { max-width: 100%; display: block; }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--s5) 0; }

:focus-visible {
    outline: 2px solid var(--pine);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

::selection { background: var(--pine-wash); color: var(--ink); }

/* --------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

.skip {
    position: absolute; left: -9999px; top: 0; z-index: 999;
    background: var(--pine); color: #fff;
    padding: var(--s3) var(--s5); border-radius: 0 0 var(--r) 0;
    font-weight: 600;
}
.skip:focus { left: 0; color: #fff; }

/* --- Sidebar --- */
.nav {
    width: var(--nav-w);
    flex: 0 0 var(--nav-w);
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex; align-items: center; gap: var(--s3);
    padding: var(--s5) var(--s4) var(--s4);
    color: var(--ink);
}
.brand:hover { color: var(--ink); }
.brand-mark {
    width: 32px; height: 32px; flex: 0 0 32px;
    background: var(--pine); color: var(--paper);
    border-radius: 8px;
    display: grid; place-items: center;
    font-weight: 700; font-size: 15px;
    letter-spacing: -0.03em;
}
:root[data-theme="dark"] .brand-mark,
.brand-mark { color: #FAFAF8; }
.brand-name { font-weight: 600; font-size: var(--t-base); line-height: 1.15; }
.brand-sub { font-size: var(--t-xs); color: var(--ink-faint); line-height: 1.2; }

.nav-scroll { flex: 1 1 auto; overflow-y: auto; padding: 0 var(--s3) var(--s4); }

.nav-sep {
    height: 1px; background: var(--line);
    margin: var(--s3) var(--s2);
}

.nav-link {
    display: flex; align-items: center; gap: var(--s3);
    padding: var(--s2) var(--s3);
    border-radius: var(--r-sm);
    color: var(--ink-soft);
    font-size: var(--t-sm);
    font-weight: 500;
    margin-bottom: 1px;
}
.nav-link:hover { background: var(--surface-sunk); color: var(--ink); }
.nav-link[aria-current="page"] {
    background: var(--pine-wash);
    color: var(--pine);
    font-weight: 600;
}
.nav-link svg { width: 17px; height: 17px; flex: 0 0 17px; stroke-width: 1.6; }
.nav-badge {
    margin-left: auto;
    background: var(--clay); color: #fff;
    font-size: 10px; font-weight: 700;
    min-width: 17px; height: 17px; padding: 0 5px;
    border-radius: 9px;
    display: grid; place-items: center;
}

.nav-foot { border-top: 1px solid var(--line); padding: var(--s3); }
.nav-me {
    display: flex; align-items: center; gap: var(--s3);
    padding: var(--s2) var(--s3); border-radius: var(--r-sm);
    color: var(--ink);
}
.nav-me:hover { background: var(--surface-sunk); color: var(--ink); }
.nav-me-name { font-size: var(--t-sm); font-weight: 600; line-height: 1.2; }
.nav-me-role { font-size: var(--t-xs); color: var(--ink-faint); }

/* --- Main --- */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: var(--s4);
    padding: var(--s3) var(--s5);
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    position: sticky; top: 0; z-index: 20;
}

.menu-btn {
    display: none;
    background: none; border: 1px solid var(--line);
    border-radius: var(--r-sm);
    width: 34px; height: 34px;
    place-items: center; cursor: pointer; color: var(--ink);
}

.search {
    flex: 1 1 auto; max-width: 420px;
    display: flex; align-items: center; gap: var(--s2);
    background: var(--surface-sunk);
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    padding: 0 var(--s3);
}
.search:focus-within { border-color: var(--line-strong); background: var(--surface); }
.search svg { width: 15px; height: 15px; color: var(--ink-faint); flex: 0 0 15px; }
.search input {
    flex: 1 1 auto; min-width: 0;
    border: 0; background: none; outline: none;
    padding: var(--s2) 0;
    font: inherit; font-size: var(--t-sm); color: var(--ink);
}
.search input::placeholder { color: var(--ink-faint); }
.search kbd {
    font-family: var(--font); font-size: 11px; font-weight: 500;
    color: var(--ink-faint); border: 1px solid var(--line);
    border-radius: 4px; padding: 1px 5px; background: var(--surface);
}

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }

.icon-btn {
    position: relative;
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    color: var(--ink-soft);
    border: 0; background: none; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-sunk); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
    position: absolute; top: 6px; right: 6px;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--clay); border: 2px solid var(--surface);
}

.page {
    flex: 1 1 auto;
    padding: var(--s6) var(--s5) var(--s8);
    max-width: 1280px; width: 100%;
    margin: 0 auto;
}
.page:focus { outline: none; }
/* Set by pages that lay out two columns and need the room. */
.page-wide { max-width: 1600px; }

/* --------------------------------------------------------------------
   Page header
   -------------------------------------------------------------------- */
.head {
    display: flex; flex-wrap: wrap; gap: var(--s4);
    align-items: flex-end; justify-content: space-between;
    margin-bottom: var(--s6);
}
.head-date { font-size: var(--t-sm); color: var(--ink-faint); margin-bottom: var(--s1); }
.head h1 { margin-bottom: var(--s2); }
.head-sub { color: var(--ink-soft); font-size: var(--t-base); max-width: 62ch; margin: 0; }
.head-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }

/* --------------------------------------------------------------------
   Countdown — the spine
   -------------------------------------------------------------------- */
.count {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 62px;
    font-variant-numeric: tabular-nums lining-nums;
}
.count-n {
    font-size: 1.75rem; font-weight: 700; line-height: 1;
    letter-spacing: -0.045em;
    color: var(--moss);
}
.count-u {
    font-size: 10.5px; font-weight: 600;
    letter-spacing: 0.06em; text-transform: lowercase;
    color: var(--ink-faint); margin-top: 3px;
}
.count.soon  .count-n { color: var(--brass); }
.count.now   .count-n { color: var(--clay); }
.count.past  .count-n { color: var(--clay); }
.count.none  .count-n { color: var(--ink-faint); font-size: 1.25rem; }

.count-lg .count-n { font-size: 2.75rem; }
.count-sm .count-n { font-size: 1.25rem; }
.count-sm { min-width: 46px; }

/* --------------------------------------------------------------------
   Cards & panels
   -------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: var(--s5);
}
.card-flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: var(--s4); }

.card-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: var(--s3); margin-bottom: var(--s4);
}
.card-head h2, .card-head h3 { margin: 0; font-size: var(--t-md); }
.card-note { color: var(--ink-soft); font-size: var(--t-sm); margin: calc(var(--s1) * -1) 0 var(--s4); max-width: 68ch; }

.stack { display: grid; gap: var(--s4); }
.stack-sm { display: grid; gap: var(--s2); }
.grid-2 { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.split { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); align-items: start; }

/* A grid or flex child defaults to min-width:auto, which means it refuses
   to be narrower than its widest unbreakable thing — one IPv6 address in
   a table cell is enough to push a whole column over the sidebar next to
   it. Every layout container here opts its children out of that, so a
   wide child scrolls or wraps inside its own box instead of shoving the
   page sideways. */
.stack > *, .stack-sm > *, .split > *, .grid-2 > *, .form-grid > * { min-width: 0; }
.table-wrap { min-width: 0; }

/* --------------------------------------------------------------------
   Rows — the universal list item
   -------------------------------------------------------------------- */
.rows { display: flex; flex-direction: column; }
.row {
    display: flex; align-items: center; gap: var(--s4);
    padding: var(--s3) var(--s5);
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}
.rows .row:last-child { border-bottom: 0; }
a.row:hover { background: var(--surface-sunk); color: var(--ink); }

.row-main { flex: 1 1 auto; min-width: 0; }
.row-title { font-weight: 600; font-size: var(--t-base); line-height: 1.3; }
.row-meta { font-size: var(--t-sm); color: var(--ink-faint); margin-top: 1px; }
.row-end { flex: 0 0 auto; display: flex; align-items: center; gap: var(--s3); }
.row-chevron { color: var(--ink-faint); flex: 0 0 auto; }
.row-chevron svg { width: 16px; height: 16px; }

/* --------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
thead th {
    text-align: left; font-weight: 600; font-size: var(--t-xs);
    color: var(--ink-faint);
    padding: var(--s3) var(--s4);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
tbody td {
    padding: var(--s3) var(--s4);
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-sunk); }
td b { font-weight: 600; display: block; }
td small { display: block; color: var(--ink-faint); margin-top: 1px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--s2);
    padding: 7px var(--s4);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit; font-size: var(--t-sm); font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--surface-sunk); color: var(--ink); border-color: var(--ink-faint); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.btn-primary {
    background: var(--pine); border-color: var(--pine); color: #FAFAF8;
}
.btn-primary:hover { background: var(--pine-hover); border-color: var(--pine-hover); color: #FAFAF8; }
.btn-danger { color: var(--clay); border-color: var(--clay); background: var(--surface); }
.btn-danger:hover { background: var(--clay); border-color: var(--clay); color: #fff; }
.btn-ghost { border-color: transparent; background: none; }
.btn-ghost:hover { background: var(--surface-sunk); border-color: transparent; }
.btn-sm { padding: 4px var(--s3); font-size: var(--t-xs); }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; }

/* --------------------------------------------------------------------
   Pills, tags, status
   -------------------------------------------------------------------- */
.pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px; border-radius: 99px;
    font-size: var(--t-xs); font-weight: 600;
    background: var(--surface-sunk); color: var(--ink-soft);
    white-space: nowrap;
}
.pill::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; opacity: .7; flex: 0 0 6px;
}
.pill-plain::before { display: none; }

.pill-moss  { background: var(--moss-wash);  color: var(--moss); }
.pill-brass { background: var(--brass-wash); color: var(--brass); }
.pill-clay  { background: var(--clay-wash);  color: var(--clay); }
.pill-slate { background: var(--slate-wash); color: var(--slate); }
.pill-pine  { background: var(--pine-wash);  color: var(--pine); }

/* Priority marker */
.prio { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; background: var(--ink-faint); }
.prio-urgent { background: var(--clay); }
.prio-high   { background: var(--brass); }
.prio-medium { background: var(--slate); }
.prio-low    { background: var(--line-strong); }

/* --------------------------------------------------------------------
   Progress
   -------------------------------------------------------------------- */
.bar {
    height: 5px; border-radius: 99px;
    background: var(--surface-sunk);
    overflow: hidden;
}
.bar > span {
    display: block; height: 100%; border-radius: 99px;
    background: var(--moss);
    transition: width .3s ease;
}
.bar.soon  > span { background: var(--brass); }
.bar.past  > span { background: var(--clay); }

/* --------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------- */
.field { display: grid; gap: 5px; margin-bottom: var(--s4); }
.field > span, label > span.label { font-size: var(--t-sm); font-weight: 600; }
.field-hint { font-size: var(--t-xs); color: var(--ink-faint); line-height: 1.45; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=search], input[type=tel], input[type=url],
select, textarea {
    width: 100%;
    padding: 7px var(--s3);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit; font-size: var(--t-sm);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--pine);
    box-shadow: 0 0 0 3px var(--pine-wash);
}
input:disabled, select:disabled, textarea:disabled {
    background: var(--surface-sunk); color: var(--ink-faint); cursor: not-allowed;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 8l3-3.5' fill='none' stroke='%237C867F' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    padding-right: 30px;
}
input[type=file] { font-size: var(--t-sm); padding: 6px 0; border: 0; }

.check {
    display: flex; align-items: flex-start; gap: var(--s2);
    font-size: var(--t-sm); cursor: pointer;
}
.check input { width: auto; margin-top: 2px; flex: 0 0 auto; }

.form-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid .field { margin-bottom: 0; }

.form-foot {
    display: flex; gap: var(--s2); justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: var(--s5); padding-top: var(--s5);
    border-top: 1px solid var(--line);
}

/* --------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------- */
.alert {
    position: relative;
    padding: var(--s3) var(--s7) var(--s3) var(--s4);
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: var(--t-sm);
    margin-bottom: var(--s4);
}
.alert strong { display: block; margin-bottom: 2px; }
.alert-ok    { background: var(--moss-wash);  border-color: var(--moss);  color: var(--moss); }
.alert-warn  { background: var(--brass-wash); border-color: var(--brass); color: var(--brass); }
.alert-error { background: var(--clay-wash);  border-color: var(--clay);  color: var(--clay); }
.alert-info  { background: var(--slate-wash); border-color: var(--slate); color: var(--slate); }
.alert-close {
    position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
    width: 24px; height: 24px; border: 0; background: none;
    color: inherit; opacity: .6; cursor: pointer; border-radius: 4px;
    font-size: 17px; line-height: 1; display: grid; place-items: center;
}
.alert-close:hover { opacity: 1; background: rgba(0,0,0,.06); }

/* Attention banner — bigger, for things that block work */
.notice {
    display: flex; flex-wrap: wrap; gap: var(--s4);
    align-items: center; justify-content: space-between;
    padding: var(--s4) var(--s5);
    border-radius: var(--r);
    border: 1px solid var(--brass);
    background: var(--brass-wash);
    color: var(--brass);
    margin-bottom: var(--s4);
}
.notice-clay { border-color: var(--clay); background: var(--clay-wash); color: var(--clay); }
.notice-info { border-color: var(--slate); background: var(--slate-wash); color: var(--slate); }
.notice strong { display: block; font-size: var(--t-base); }
.notice p { margin: 2px 0 0; font-size: var(--t-sm); opacity: .9; }

/* --------------------------------------------------------------------
   Empty states
   -------------------------------------------------------------------- */
.empty {
    text-align: center;
    padding: var(--s7) var(--s5);
    color: var(--ink-soft);
}
.empty strong { display: block; font-size: var(--t-md); color: var(--ink); margin-bottom: var(--s2); }
.empty p { max-width: 44ch; margin: 0 auto var(--s4); font-size: var(--t-sm); }

/* --------------------------------------------------------------------
   Filters
   -------------------------------------------------------------------- */
.filters {
    display: flex; flex-wrap: wrap; gap: var(--s2);
    align-items: center;
    margin-bottom: var(--s4);
}
.chip {
    padding: 4px var(--s3);
    border: 1px solid var(--line-strong);
    border-radius: 99px;
    font-size: var(--t-sm); font-weight: 500;
    color: var(--ink-soft);
    background: var(--surface);
    white-space: nowrap;
}
.chip:hover { border-color: var(--ink-faint); color: var(--ink); }
.chip[aria-current="true"] {
    background: var(--pine); border-color: var(--pine); color: #FAFAF8;
    font-weight: 600;
}
.chip-count { opacity: .65; font-variant-numeric: tabular-nums; }
/* The trailing group sits right on a wide screen, but it is a flex row
   of its own and will not wrap — on a phone that pushes the page 2px
   sideways, which is enough for a horizontal scrollbar. */
.filters-end {
    margin-left: auto; display: flex; gap: var(--s2);
    align-items: center; flex-wrap: wrap; min-width: 0;
}
@media (max-width: 640px) {
    .filters-end { margin-left: 0; }
}

/* --------------------------------------------------------------------
   Timeline / chain (signing, renewals)
   -------------------------------------------------------------------- */
.chain { list-style: none; margin: 0; padding: 0; }
.chain li { position: relative; padding-left: var(--s6); padding-bottom: var(--s4); }
.chain li:last-child { padding-bottom: 0; }
.chain li::before {
    content: ''; position: absolute; left: 7px; top: 5px;
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--line-strong);
    z-index: 1;
}
.chain li::after {
    content: ''; position: absolute; left: 12px; top: 18px; bottom: -3px;
    width: 1px; background: var(--line);
}
.chain li:last-child::after { display: none; }
.chain li.done::before { background: var(--moss); border-color: var(--moss); }
.chain li.active::before { border-color: var(--brass); background: var(--brass-wash); }
.chain-title { font-weight: 600; font-size: var(--t-sm); }
.chain-meta { font-size: var(--t-xs); color: var(--ink-faint); }

/* --------------------------------------------------------------------
   Conversation feed — comments on a task or an agreement
   -------------------------------------------------------------------- */
.feed { list-style: none; margin: 0 0 var(--s4); padding: 0; display: grid; gap: var(--s4); }
.feed > li { display: flex; gap: var(--s3); align-items: flex-start; }
.feed > li > div { min-width: 0; flex: 1; }
.feed-head {
    display: flex; align-items: baseline; gap: var(--s2);
    flex-wrap: wrap; margin-bottom: 2px;
}
.feed-head strong { font-size: var(--t-sm); }
.feed-head time { font-size: var(--t-xs); color: var(--ink-faint); }
.feed p {
    margin: 0; font-size: var(--t-sm); line-height: 1.6;
    overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------
   Avatars
   -------------------------------------------------------------------- */
.avatar {
    width: 30px; height: 30px; flex: 0 0 30px;
    border-radius: 50%;
    background: var(--pine-wash); color: var(--pine);
    display: grid; place-items: center;
    font-size: var(--t-xs); font-weight: 700;
    overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 56px; height: 56px; flex-basis: 56px; font-size: var(--t-md); }
.avatar-sm { width: 24px; height: 24px; flex-basis: 24px; font-size: 10px; }

.people { display: flex; align-items: center; }
.people .avatar { margin-right: -7px; border: 2px solid var(--surface); }

/* --------------------------------------------------------------------
   Detail meta list
   -------------------------------------------------------------------- */
.meta { display: grid; gap: 0; }
.meta > div {
    display: flex; gap: var(--s4); justify-content: space-between;
    padding: var(--s3) 0;
    border-bottom: 1px solid var(--line);
    font-size: var(--t-sm);
}
.meta > div:last-child { border-bottom: 0; }
.meta dt, .meta .k { color: var(--ink-faint); flex: 0 0 auto; }
.meta dd, .meta .v { margin: 0; font-weight: 600; text-align: right; }

/* --------------------------------------------------------------------
   Pager
   -------------------------------------------------------------------- */
.pager {
    display: flex; flex-wrap: wrap; align-items: center;
    justify-content: space-between; gap: var(--s3);
    padding: var(--s3) var(--s5);
    border-top: 1px solid var(--line);
    font-size: var(--t-sm); color: var(--ink-faint);
}
.pager-links { display: flex; gap: 3px; align-items: center; }
.pager-link {
    min-width: 30px; height: 30px; padding: 0 var(--s2);
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    color: var(--ink-soft); font-size: var(--t-sm);
    font-variant-numeric: tabular-nums;
}
.pager-link:hover { border-color: var(--ink-faint); color: var(--ink); }
.pager-link[aria-current="page"] {
    background: var(--pine); border-color: var(--pine); color: #FAFAF8; font-weight: 600;
}
.pager-link.off { opacity: .35; pointer-events: none; }
.pager-gap { padding: 0 2px; opacity: .5; }

/* --------------------------------------------------------------------
   Disclosure
   -------------------------------------------------------------------- */
details.disclose { border: 1px solid var(--line); border-radius: var(--r-sm); }
details.disclose > summary {
    padding: var(--s3) var(--s4);
    cursor: pointer; list-style: none;
    font-size: var(--t-sm); font-weight: 600;
    display: flex; align-items: center; gap: var(--s2);
}
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose > summary::after {
    content: ''; margin-left: auto;
    width: 8px; height: 8px;
    border-right: 1.5px solid var(--ink-faint);
    border-bottom: 1.5px solid var(--ink-faint);
    transform: rotate(45deg); transition: transform .15s ease;
}
details.disclose[open] > summary::after { transform: rotate(-135deg); }
details.disclose > .disclose-body { padding: 0 var(--s4) var(--s4); }
details.disclose[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: var(--s4); }

/* --------------------------------------------------------------------
   Auth pages
   -------------------------------------------------------------------- */
.auth {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: var(--s5);
    background: var(--paper);
}
.auth-card {
    width: 100%; max-width: 390px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: var(--s6);
    box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s6); }
.auth h1 { font-size: var(--t-lg); margin-bottom: var(--s2); }
.auth-intro { color: var(--ink-soft); font-size: var(--t-sm); margin-bottom: var(--s5); }
.auth-foot {
    margin-top: var(--s5); padding-top: var(--s4);
    border-top: 1px solid var(--line);
    font-size: var(--t-sm); color: var(--ink-faint);
    display: flex; justify-content: space-between; gap: var(--s3);
}

/* --------------------------------------------------------------------
   Agreement document
   -------------------------------------------------------------------- */
.doc {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: var(--s7) var(--s6);
    font-size: var(--t-sm);
    line-height: 1.75;
    max-width: 78ch;
}
.doc h1 { font-size: var(--t-lg); text-align: center; margin-bottom: var(--s5); }
.doc h2 { font-size: var(--t-md); margin: var(--s6) 0 var(--s3); }
.doc h3 { font-size: var(--t-base); margin: var(--s4) 0 var(--s2); }
.doc p { margin-bottom: var(--s3); }
.doc table { margin: var(--s4) 0; font-size: var(--t-sm); }
.doc table th, .doc table td { border: 1px solid var(--line); padding: var(--s2) var(--s3); }
.doc section { margin-bottom: var(--s4); }
.doc-sign { display: grid; gap: var(--s6); grid-template-columns: 1fr 1fr; margin-top: var(--s7); }
.doc-line { border-bottom: 1px solid var(--ink); height: var(--s6); margin-bottom: var(--s2); }
.doc-note {
    margin-top: var(--s6); padding-top: var(--s4);
    border-top: 1px solid var(--line);
    font-size: var(--t-xs); color: var(--ink-faint);
}

/* --------------------------------------------------------------------
   Agreement document
   The markup comes from core/agreement_text.php, which is carried over
   verbatim because executed contracts are hashed against it. The styling
   lives here instead, so the legal text is never edited for looks.
   -------------------------------------------------------------------- */
.agreement-document { font-size: var(--t-sm); line-height: 1.8; }
.agreement-document h1 { font-size: var(--t-lg); letter-spacing: -0.02em; margin: 0 0 var(--s3); }
.agreement-document h2 { font-size: var(--t-base); margin: var(--s6) 0 var(--s2); }
.agreement-document h3 { font-size: var(--t-sm); margin: var(--s4) 0 var(--s2); }
.agreement-document p  { margin: 0 0 var(--s3); }
.agreement-document ol, .agreement-document ul { margin: 0 0 var(--s3) var(--s5); }
.agreement-document li { margin-bottom: var(--s2); }

.agreement-cover {
    text-align: center;
    padding-bottom: var(--s5);
    margin-bottom: var(--s5);
    border-bottom: 2px solid var(--ink);
}
.agreement-kicker {
    font-size: var(--t-xs); font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--moss);
    margin-bottom: var(--s2);
}

.agreement-table { width: 100%; margin: var(--s4) 0; }
.agreement-table th, .agreement-table td {
    border: 1px solid var(--line-strong);
    padding: var(--s2) var(--s3);
    text-align: left; vertical-align: top;
}
.agreement-table th { background: var(--surface-sunk); font-weight: 600; }

.agreement-divider {
    text-align: center; color: var(--ink-faint);
    overflow: hidden; white-space: nowrap;
    margin: var(--s6) 0 var(--s4);
    font-size: var(--t-xs);
}

.agreement-members { margin: var(--s4) 0; }

.signature-section { margin-top: var(--s7); page-break-inside: avoid; }
.signature-grid {
    display: grid; gap: var(--s6) var(--s5);
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.signature-grid-members  { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.signature-grid-secondary { margin-top: var(--s6); }
.signature-group-heading { margin-top: var(--s6); }
.signature-group-heading h3 { margin-bottom: 2px; }
.signature-group-heading p  { font-size: var(--t-xs); color: var(--ink-faint); }
.signature-party { margin-bottom: var(--s4); }

.signature-line {
    border-bottom: 1px solid var(--ink);
    height: var(--s6);
    margin: var(--s5) 0 var(--s2);
}
.primary-signature-mark {
    display: inline-block;
    font-size: var(--t-xs); font-weight: 600;
    color: var(--moss);
}
.signing-note {
    margin-top: var(--s6); padding-top: var(--s4);
    border-top: 1px solid var(--line);
    font-size: var(--t-xs); color: var(--ink-faint);
}

@media print {
    .agreement-document { font-size: 10.5pt; line-height: 1.6; color: #000; }
    .agreement-document h2 { page-break-after: avoid; }
    .signature-grid { grid-template-columns: 1fr 1fr; }
}

/* --------------------------------------------------------------------
   Print
   -------------------------------------------------------------------- */
@media print {
    .nav, .topbar, .no-print, .btn, .alert-close { display: none !important; }
    .shell, .main, .page { display: block; margin: 0; padding: 0; max-width: none; }
    body { background: #fff; color: #000; font-size: 11pt; }
    .doc { border: 0; padding: 0; max-width: none; box-shadow: none; }
    a { color: #000; text-decoration: none; }
}

/* --------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------- */
@media (max-width: 1040px) {
    .split { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .nav {
        position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--shadow-lg);
    }
    body.nav-open .nav { transform: translateX(0); }
    .nav-veil {
        position: fixed; inset: 0; z-index: 40;
        background: rgba(20,33,28,.45);
        opacity: 0; pointer-events: none; transition: opacity .22s ease;
        border: 0;
    }
    body.nav-open .nav-veil { opacity: 1; pointer-events: auto; }
    body.nav-open { overflow: hidden; }
    .menu-btn { display: grid; }
    .page { padding: var(--s5) var(--s4) var(--s7); }
    .head { margin-bottom: var(--s5); }
    .form-grid { grid-template-columns: 1fr; }
    .doc-sign { grid-template-columns: 1fr; }
    .search kbd { display: none; }
    .row { padding: var(--s3) var(--s4); }
    .pager { padding: var(--s3) var(--s4); }
}

@media (max-width: 560px) {
    :root { --t-xl: 1.5rem; --t-2xl: 1.875rem; }
    .count-lg .count-n { font-size: 2rem; }
    .pager-link:not(.pager-prev):not(.pager-next):not([aria-current]) { display: none; }
    .pager-gap { display: none; }
    .row-meta { font-size: var(--t-xs); }
}

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

/* Utilities */
.muted { color: var(--ink-faint); }
.soft { color: var(--ink-soft); }
.tnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hide { display: none !important; }

/* The hidden attribute only sets display:none at browser-default
   strength, so any author rule — .field is display:grid — silently wins
   and the element stays on screen. Make the attribute mean what it says. */
[hidden] { display: none !important; }
.sr {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.mt0 { margin-top: 0; } .mt3 { margin-top: var(--s3); } .mt4 { margin-top: var(--s4); }
.mt5 { margin-top: var(--s5); } .mb0 { margin-bottom: 0; } .mb4 { margin-bottom: var(--s4); }
