/* ==========================================================
   Project Core — stylesheet

   This is an internal work-tracking tool. It is read many times
   a day by people scanning for what changed, so it is built for
   density and legibility rather than impact: tight vertical
   rhythm, tabular figures so dates and numbers align down a
   column, and colour reserved almost entirely for status, where
   it carries information.

   Colour is the one place there is any boldness. Everything
   else stays quiet.
   ========================================================== */

:root {
    --ink:        #14212e;   /* headings, primary text */
    --body:       #33404e;   /* body copy */
    --muted:      #64748b;   /* secondary text, labels */
    --paper:      #ffffff;
    --surface:    #f3f6f8;   /* page background, cool not cream */
    --rule:       #d9e1e8;
    --rule-soft:  #eaeff3;
    --accent:     #0f6e8c;   /* deep teal — links, primary action */
    --accent-dim: #0b5570;

    /* Status colours. These are data, not decoration — do not
       reuse them for anything else. */
    --idle:     #8a97a5;
    --active:   #1f6feb;
    --review:   #b45309;
    --done:     #15803d;
    --blocked:  #b91c1c;
    --returned: #7c3aed;
    --dead:     #94a3b8;

    --crit: #b91c1c;
    --high: #c2410c;
    --med:  #64748b;
    --low:  #94a3b8;

    --radius: 4px;
    --shell:  1180px;
}

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

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

body {
    margin: 0;
    background: var(--surface);
    color: var(--body);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

/* Numbers, dates and ids line up vertically in every table. */
table, .num, time, .pct { font-variant-numeric: tabular-nums; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-dim); }

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

h1, h2, h3 {
    color: var(--ink);
    line-height: 1.25;
    margin: 0 0 .4em;
    font-weight: 620;
    letter-spacing: -0.011em;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .97rem; }

p { margin: 0 0 1em; max-width: 68ch; }

/* ---------- top bar ---------- */

.bar {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0 1.5rem;
    height: 54px;
    background: var(--ink);
    color: #cfd8e3;
}

.bar .mark {
    color: #fff;
    font-weight: 640;
    letter-spacing: -0.015em;
    text-decoration: none;
    white-space: nowrap;
}

.bar nav {
    display: flex;
    gap: 1.35rem;
    margin-right: auto;
    overflow-x: auto;
}

.bar nav a {
    color: #a9b8c9;
    text-decoration: none;
    font-size: .9rem;
    white-space: nowrap;
    padding: .35rem 0;
    border-bottom: 2px solid transparent;
}
.bar nav a:hover { color: #fff; }
.bar nav a[aria-current="page"] {
    color: #fff;
    border-bottom-color: #4eb3d3;
}

.who {
    display: flex;
    align-items: baseline;
    gap: .7rem;
    font-size: .85rem;
    white-space: nowrap;
}
.who .name { color: #fff; }
.who .role { color: #8fa3b8; }
.who .out  { color: #a9b8c9; text-decoration: none; }
.who .out:hover { color: #fff; text-decoration: underline; }

/* ---------- page shell ---------- */

main {
    max-width: var(--shell);
    margin: 0 auto;
    padding: 1.75rem 1.5rem 4rem;
}

.head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.4rem;
}
.head p { margin: 0; color: var(--muted); font-size: .92rem; }

/* ---------- metric row ---------- */

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.75rem;
}

.metric {
    background: var(--paper);
    padding: .9rem 1.1rem 1rem;
}
.metric .v {
    display: block;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.1;
    letter-spacing: -0.02em;
}
.metric .k {
    font-size: .82rem;
    color: var(--muted);
}
.metric.warn .v { color: var(--blocked); }

/* ---------- panels ---------- */

.panel {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}
.panel > h2 {
    margin: 0;
    padding: .8rem 1.1rem;
    border-bottom: 1px solid var(--rule-soft);
    font-size: .95rem;
}
.panel .pad { padding: 1.1rem; }

/* ---------- tables ---------- */

.scroll { overflow-x: auto; }

table.list {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

table.list th {
    text-align: left;
    font-weight: 560;
    font-size: .82rem;
    color: var(--muted);
    padding: .55rem .8rem;
    border-bottom: 1px solid var(--rule);
    white-space: nowrap;
}

table.list td {
    padding: .62rem .8rem;
    border-bottom: 1px solid var(--rule-soft);
    vertical-align: middle;
}
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #fbfcfd; }

table.list td.title { min-width: 15rem; }
table.list td.title a { font-weight: 520; text-decoration: none; color: var(--ink); }
table.list td.title a:hover { color: var(--accent); text-decoration: underline; }

/* A coloured rail on the left edge of each row, keyed to status.
   Structural rather than decorative: it lets you find blocked and
   overdue work by scanning the edge of the table. */
table.list td.rail {
    width: 3px;
    padding: 0;
    border-bottom: 0;
}
.rail-idle     { background: var(--idle); }
.rail-active   { background: var(--active); }
.rail-review   { background: var(--review); }
.rail-done     { background: var(--done); }
.rail-blocked  { background: var(--blocked); }
.rail-returned { background: var(--returned); }
.rail-dead     { background: var(--dead); }

td.late { color: var(--blocked); font-weight: 520; }

.sub { color: var(--muted); font-size: .83rem; }

/* ---------- pills ---------- */

.pill {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 2rem;
    font-size: .78rem;
    line-height: 1.5;
    white-space: nowrap;
    border: 1px solid;
}

.status-idle     { color: #55606c; border-color: #ccd4dc; background: #f4f6f8; }
.status-active   { color: #14539e; border-color: #b9d3f5; background: #eff5fe; }
.status-review   { color: #92400e; border-color: #f2d9a8; background: #fdf7ec; }
.status-done     { color: #14602f; border-color: #b4dcc2; background: #f0f9f3; }
.status-blocked  { color: #991b1b; border-color: #f2c2c2; background: #fdf1f1; }
.status-returned { color: #5b21b6; border-color: #d6c6f5; background: #f7f3fe; }
.status-dead     { color: #64748b; border-color: #d7dee6; background: #f6f8fa; }

.prio-crit { color: var(--crit); border-color: #f2c2c2; background: #fdf1f1; font-weight: 560; }
.prio-high { color: var(--high); border-color: #f5d3bc; background: #fdf5f0; }
.prio-med  { color: #4a5764; border-color: #d3dae1; background: #f5f7f9; }
.prio-low  { color: var(--low);  border-color: #e0e6eb; background: #f8fafb; }

/* ---------- progress ---------- */

.pct { font-size: .82rem; color: var(--muted); }

.meter {
    width: 62px;
    height: 5px;
    background: var(--rule-soft);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: .45rem;
}
.meter span {
    display: block;
    height: 100%;
    background: var(--active);
}

/* ---------- forms ---------- */

label { display: block; font-size: .85rem; color: var(--ink); margin-bottom: .3rem; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
    width: 100%;
    padding: .5rem .6rem;
    font: inherit;
    font-size: .92rem;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(15,110,140,.13);
}
textarea { min-height: 5rem; resize: vertical; }

.field { margin-bottom: .95rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .95rem; }

button, .btn {
    font: inherit;
    font-size: .9rem;
    padding: .48rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--rule);
    background: var(--paper);
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
button:hover, .btn:hover { background: #f7f9fb; }

button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
button.primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }

button.go   { border-color: #b4dcc2; color: #14602f; background: #f0f9f3; }
button.stop { border-color: #f2c2c2; color: #991b1b; background: #fdf1f1; }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- flash ---------- */

.flash {
    padding: .6rem .9rem;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: .9rem;
    margin-bottom: 1.2rem;
    max-width: none;
}
.flash.note { background: #eff5fe; border-color: #b9d3f5; color: #14539e; }
.flash.ok   { background: #f0f9f3; border-color: #b4dcc2; color: #14602f; }
.flash.bad  { background: #fdf1f1; border-color: #f2c2c2; color: #991b1b; }

/* ---------- login ---------- */

.gate {
    max-width: 22rem;
    margin: 4.5rem auto;
    padding: 0 1.25rem;
}
.gate .mark {
    color: var(--ink);
    font-size: 1.35rem;
    font-weight: 640;
    letter-spacing: -0.02em;
    margin-bottom: .2rem;
}
.gate .tag { color: var(--muted); font-size: .9rem; margin-bottom: 1.6rem; }
.gate form {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1.35rem;
}
.gate button { width: 100%; margin-top: .3rem; }
.gate .hint {
    margin-top: 1.1rem;
    font-size: .82rem;
    color: var(--muted);
    line-height: 1.7;
}
.gate .hint code { color: var(--ink); }

/* ---------- task detail ---------- */

.split { display: grid; grid-template-columns: minmax(0,1.9fr) minmax(0,1fr); gap: 1.5rem; }

dl.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .45rem 1.1rem; font-size: .9rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; color: var(--ink); }

.thread { list-style: none; margin: 0; padding: 0; }
.thread li { padding: .8rem 0; border-bottom: 1px solid var(--rule-soft); }
.thread li:last-child { border-bottom: 0; padding-bottom: 0; }
.thread .meta { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.thread .body { margin: 0; white-space: pre-wrap; font-size: .9rem; }

.empty { color: var(--muted); font-size: .9rem; margin: 0; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
    .split, .row2 { grid-template-columns: 1fr; }
    .bar { gap: 1rem; padding: 0 1rem; height: auto; flex-wrap: wrap; padding-bottom: .5rem; }
    .bar nav { order: 3; width: 100%; }
    main { padding: 1.25rem 1rem 3rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
