/* Client Pulse — cockpit UI. Dense, scannable, quiet until something is wrong. */

:root {
    --ground: #f2f4f6;
    --surface: #ffffff;
    --sunk: #e9edf0;
    --ink: #16202a;
    --ink-soft: #3b4855;
    --muted: #5f6c79;
    --hair: #d7dee4;
    --hair-strong: #bcc7cf;
    --accent: #0e7c86;
    --accent-soft: #e0eff0;
    --healthy: #2e7d5b;
    --watch: #a76f14;
    --risk: #bc4630;
    --radius: 3px;
    --shadow: 0 1px 2px rgba(22, 32, 42, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------------------------------------------------------- chrome */

.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0 1.5rem;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--hair);
}

.brand {
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--ink);
    text-decoration: none;
}

.nav { display: flex; gap: 1.25rem; flex: 1; }

.nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
}

.nav a.on { color: var(--ink); border-bottom-color: var(--accent); }
.nav a:hover { color: var(--ink); }

.topbar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: 13px;
    color: var(--muted);
    margin: 0;
}

.page { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
.centered { max-width: 380px; margin: 8vh auto; padding: 0 1.5rem; }

/* ---------------------------------------------------------- headings */

.head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

h1 { font-size: 1.5rem; letter-spacing: -.015em; margin: 0 0 .15rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.sub { color: var(--muted); font-size: 13px; margin: 0; }

/* ---------------------------------------------------------- cards, tables */

.card {
    background: var(--surface);
    border: 1px solid var(--hair);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card + .card { margin-top: 1.25rem; }
.card-body { padding: 1.1rem 1.25rem; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
    text-align: left;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--hair-strong);
    white-space: nowrap;
}

td { padding: .7rem 1rem; border-bottom: 1px solid var(--hair); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--sunk); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td a { text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }
.dim { color: var(--muted); }

.table-wrap { overflow-x: auto; }

/* ---------------------------------------------------------- state */

.pill {
    display: inline-block;
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: .15rem .45rem;
    border: 1px solid currentColor;
    border-radius: var(--radius);
    white-space: nowrap;
}

.pill-active { color: var(--healthy); }
.pill-paused { color: var(--watch); }
.pill-done { color: var(--muted); }
.pill-archived { color: var(--muted); }

.empty {
    padding: 2.5rem 1.25rem;
    text-align: center;
    color: var(--muted);
}

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

form.stack { display: flex; flex-direction: column; gap: 1rem; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: .3rem; }

input[type=text], input[type=email], input[type=password], input[type=date],
select, textarea {
    width: 100%;
    padding: .5rem .6rem;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--hair-strong);
    border-radius: var(--radius);
}

textarea { min-height: 5rem; resize: vertical; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > * { flex: 1 1 12rem; }

.err { color: var(--risk); font-size: 12.5px; margin: .3rem 0 0; }
input.bad, select.bad, textarea.bad { border-color: var(--risk); }

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

.btn {
    display: inline-block;
    padding: .5rem .9rem;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
}

.btn:hover { filter: brightness(1.08); }

.btn-quiet {
    color: var(--ink);
    background: var(--surface);
    border-color: var(--hair-strong);
}

button.link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-size: 13px;
    color: var(--accent);
    cursor: pointer;
}

.flash {
    padding: .6rem .9rem;
    border-radius: var(--radius);
    border: 1px solid var(--healthy);
    color: var(--healthy);
    background: #fff;
    font-size: 14px;
    margin: 0 0 1.25rem;
}

.flash-error { border-color: var(--risk); color: var(--risk); }

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

.meta { display: flex; flex-wrap: wrap; gap: 1.75rem; }
.meta div { min-width: 8rem; }
.meta dt {
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: .2rem;
}
.meta dd { margin: 0; font-size: 14px; font-variant-numeric: tabular-nums; }

.login-brand { font-size: 1.35rem; font-weight: 700; margin: 0 0 .25rem; }
.login-hint { font-size: 12.5px; color: var(--muted); margin-top: 1.25rem; }

/* ---------------------------------------------------------- timeline */

.timeline {
    position: relative;
    height: 42px;
    margin-top: 1.5rem;
    background: var(--sunk);
    border-radius: var(--radius);
    overflow: hidden;
}

.tl-phase {
    position: absolute;
    top: 6px;
    bottom: 6px;
    border-radius: 2px;
    background: var(--hair-strong);
    border: 1px solid rgba(22, 32, 42, .12);
    display: flex;
    align-items: center;
    padding: 0 .4rem;
    overflow: hidden;
}

.tl-phase span {
    font-size: 11px;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.tl-planned { background: #dfe6eb; }
.tl-active { background: var(--accent-soft); border-color: var(--accent); }
.tl-active span { color: var(--accent); }
.tl-done { background: #d8eadf; }
.tl-skipped { background: repeating-linear-gradient(45deg, #e6eaed, #e6eaed 4px, #dde3e7 4px, #dde3e7 8px); }

.tl-today {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--risk);
}

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

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin: 0;
}

.inline-form input[type=text] { flex: 1 1 14rem; width: auto; }
.inline-form input[type=date], .inline-form select { width: auto; flex: 0 0 auto; }

.row-actions { display: flex; gap: .75rem; justify-content: flex-end; }
.row-actions form { margin: 0; }

details summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.pill-open { color: var(--muted); }
.pill-risk { color: var(--risk); }
.pill-phase-planned { color: var(--muted); }
.pill-phase-active { color: var(--accent); }
.pill-phase-done { color: var(--healthy); }
.pill-phase-skipped { color: var(--muted); }

/* ---------------------------------------------------------- history */

.warn { color: var(--risk); font-weight: 600; }

ol.events { list-style: none; margin: 0; padding: 0; }

.event {
    display: grid;
    grid-template-columns: 6.5rem 5.5rem 1fr 6rem;
    gap: .75rem;
    align-items: baseline;
    padding: .55rem 1.25rem;
    border-bottom: 1px solid var(--hair);
    font-size: 14px;
}

.event:last-child { border-bottom: none; }
.event:hover { background: var(--sunk); }

.ev-when { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.ev-type {
    font-size: 10.5px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
    border: 1px solid var(--hair-strong);
    border-radius: var(--radius);
    padding: .1rem .35rem;
    text-align: center;
}

.ev-meeting .ev-type { color: var(--accent); border-color: var(--accent); }
.ev-approval .ev-type { color: var(--watch); border-color: var(--watch); }
.ev-milestone .ev-type, .ev-phase .ev-type { color: var(--healthy); border-color: var(--healthy); }

.ev-what { line-height: 1.45; }
.ev-who { font-size: 12.5px; text-align: right; }

@media (max-width: 40rem) {
    .event { grid-template-columns: 1fr; gap: .2rem; }
    .ev-type { justify-self: start; }
    .ev-who { text-align: left; }
}

/* ---------------------------------------------------------- calendar */

.week-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1.75rem;
    font-size: 13px;
    color: var(--muted);
}

.week-summary .ws-num {
    display: block;
    font-size: 1.5rem;
    line-height: 1.1;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.week-summary .attention .ws-num { color: var(--risk); }

.cal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

.tabs { display: flex; gap: 1.1rem; }
.tabs a {
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding-bottom: 3px;
    border-bottom: 2px solid transparent;
}
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }

.chip {
    display: inline-block;
    font-size: 11px;
    padding: .1rem .35rem;
    border-radius: var(--radius);
    border: 1px solid var(--hair-strong);
    color: var(--muted);
    background: var(--surface);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.chip-held, .chip-done { border-color: var(--healthy); color: var(--healthy); }
.chip-scheduled, .chip-waiting, .chip-open { border-color: var(--accent); color: var(--accent); }
.chip-expected { border-color: var(--watch); color: var(--watch); }
.chip-missing, .chip-overdue { border-color: var(--risk); color: var(--risk); background: #fdf3f1; }

.day-list { display: flex; flex-direction: column; }
.day { border-top: 1px solid var(--hair); }
.day:first-child { border-top: none; }

.day-head {
    display: flex;
    gap: .6rem;
    align-items: baseline;
    padding: .7rem 1.25rem .3rem;
    font-size: 13px;
}

.day-head.is-today strong { color: var(--accent); }

.day-entries { list-style: none; margin: 0; padding: 0 1.25rem .7rem; display: flex; flex-direction: column; gap: .35rem; }
.day-entries li { font-size: 14px; display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.day-entries a { text-decoration: none; font-weight: 600; }
.day-entries a:hover { text-decoration: underline; }

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(7.5rem, 1fr));
    border-top: 1px solid var(--hair);
    border-left: 1px solid var(--hair);
    min-width: 54rem;
}

.month-head {
    padding: .45rem .6rem;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--sunk);
    border-right: 1px solid var(--hair);
    border-bottom: 1px solid var(--hair-strong);
}

.month-cell {
    min-height: 6.5rem;
    padding: .35rem .4rem;
    border-right: 1px solid var(--hair);
    border-bottom: 1px solid var(--hair);
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.month-cell.outside { background: var(--sunk); }
.month-cell.is-today { background: var(--accent-soft); }
.month-date { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

ul.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; font-size: 14px; }
ul.plain-list li { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }

/* ------------------------------------------------------------- pulse */

.score {
    display: inline-block;
    min-width: 2.6rem;
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
    text-align: right;
}

.score-healthy { color: var(--healthy); }
.score-watch { color: var(--watch); }
.score-at_risk { color: var(--risk); }
.score-critical { color: var(--risk); }
.score-unknown { color: var(--muted); }

td.reasons { max-width: 22rem; font-size: 13px; line-height: 1.4; }

.pulse-body { display: flex; gap: 2rem; flex-wrap: wrap; align-items: flex-start; }

.pulse-score {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 11rem;
}

.pulse-score .score { font-size: 3rem; line-height: 1; text-align: left; min-width: 0; }

.pulse-band {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.pulse-healthy { color: var(--healthy); }
.pulse-watch { color: var(--watch); }
.pulse-at_risk, .pulse-critical { color: var(--risk); }

.spark { width: 120px; height: 36px; margin-top: .6rem; color: var(--hair-strong); }

.pulse-factors {
    flex: 1 1 22rem;
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.factor {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .5rem 1rem;
    padding: .4rem 0;
    border-bottom: 1px solid var(--hair);
    font-size: 14px;
}

.factor:last-child { border-bottom: none; }
.factor-name { font-weight: 600; }
.factor-value { font-variant-numeric: tabular-nums; color: var(--healthy); font-weight: 600; }
.factor-hit .factor-value { color: var(--risk); }
.factor-nodata .factor-name { font-weight: 400; color: var(--muted); }

.factor-reasons {
    grid-column: 1 / -1;
    margin: .15rem 0 0;
    padding-left: 1rem;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}
