/*
 * Structural stylesheet only.
 * Enough to make the scaffold legible and keyboard usable; the visual
 * identity pass comes later and should replace this file wholesale.
 */

:root {
    --ink: #1b1f24;
    --ink-muted: #5c6673;
    --line: #d8dee6;
    --surface: #ffffff;
    --canvas: #f5f7fa;
    --accent: #1f5f8b;
    --danger: #a4353a;
    --warn: #8a6212;
    --ok: #2b6b45;
    --radius: 6px;
    --gap: 1rem;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
}

a { color: var(--accent); }

h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }

.muted { color: var(--ink-muted); }

/* ---- Shell ---------------------------------------------------------- */

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--gap);
    padding: .75rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar__brand { font-weight: 600; text-decoration: none; letter-spacing: .02em; }
.topbar__right { display: flex; align-items: center; gap: var(--gap); }
.topbar__user small { display: block; color: var(--ink-muted); font-size: .8rem; }

.shell { display: flex; align-items: flex-start; }

.sidebar {
    width: 200px; flex: 0 0 200px;
    padding: 1.25rem 0;
    display: flex; flex-direction: column;
    border-right: 1px solid var(--line);
    background: var(--surface);
    min-height: calc(100vh - 57px);
}

.sidebar a { padding: .45rem 1.25rem; text-decoration: none; color: var(--ink); }
.sidebar a:hover { background: var(--canvas); }
.sidebar__section {
    margin: 1.25rem 1.25rem .25rem;
    font-size: .75rem;
    color: var(--ink-muted);
    letter-spacing: .06em;
}

.shell__main { flex: 1; padding: 1.5rem; max-width: 1100px; }

.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: var(--gap); margin-bottom: 1.25rem;
}

/* ---- Plain pages ---------------------------------------------------- */

body.plain { display: grid; place-items: center; min-height: 100vh; }
.plain__panel {
    width: min(380px, 92vw);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 2rem;
}

/* ---- Forms ---------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: .35rem; margin-top: 1.25rem; }
.form label { font-size: .85rem; color: var(--ink-muted); margin-top: .5rem; }

input, select, textarea, button {
    font: inherit;
    padding: .5rem .6rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: inherit;
}

textarea { resize: vertical; width: 100%; }

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

.btn { cursor: pointer; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; margin-top: 1rem; }
.btn--quiet { background: transparent; border-color: transparent; color: var(--ink-muted); }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.check { display: flex; align-items: center; gap: .35rem; font-size: .9rem; }

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

.status-tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.status-tabs button { cursor: pointer; }
.status-tabs .is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.count { margin-left: .35rem; color: inherit; opacity: .7; }

.table {
    width: 100%; border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.table th, .table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-size: .8rem; color: var(--ink-muted); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--gap); }
.card {
    display: block; padding: 1rem; text-decoration: none; color: inherit;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.card__stats { list-style: none; margin: .75rem 0 0; padding: 0; font-size: .9rem; color: var(--ink-muted); }
.card--stat { text-align: center; }
.card--stat strong { display: block; font-size: 1.6rem; }

.queue { margin-top: 2rem; }
.queue__list { list-style: none; margin: 0; padding: 0; }
.queue__list li {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem;
    padding: .55rem 0; border-bottom: 1px solid var(--line);
}

.meta { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1.25rem; margin: 1rem 0 1.5rem; }
.meta dt { color: var(--ink-muted); font-size: .85rem; }
.meta dd { margin: 0; }

.prose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }

/* ---- Pills ---------------------------------------------------------- */

.pill {
    font-size: .75rem; padding: .1rem .45rem; border-radius: 999px;
    border: 1px solid var(--line); text-transform: capitalize;
}
.pill--critical, .pill--overdue { color: var(--danger); border-color: currentColor; }
.pill--high, .pill--due_soon   { color: var(--warn);   border-color: currentColor; }
.pill--on_track, .pill--done   { color: var(--ok);     border-color: currentColor; }

/* ---- Thread --------------------------------------------------------- */

.thread { margin-top: 2rem; }
.thread__list { list-style: none; margin: 0 0 1rem; padding: 0; }
.comment { padding: .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .5rem; }
.comment__meta { margin: 0 0 .35rem; font-size: .85rem; display: flex; gap: .5rem; }
.comment p:last-child { margin-bottom: 0; }
.thread__composer { display: flex; flex-direction: column; gap: .5rem; }
.thread__actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---- Flash ---------------------------------------------------------- */

.flash-stack { margin-bottom: 1rem; }
.flash { padding: .6rem .8rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); margin: 0 0 .5rem; }
.flash--error { border-color: var(--danger); color: var(--danger); }
.flash--success { border-color: var(--ok); color: var(--ok); }

.trace { overflow: auto; font-size: .8rem; background: #fff; padding: 1rem; border: 1px solid var(--line); }

@media (max-width: 720px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; min-height: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .sidebar__section { display: none; }
}

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

/* ---- Panels and approval chain -------------------------------------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.25rem 1.25rem;
    margin-bottom: 1.25rem;
}

.chain { list-style: none; margin: 0; padding: 0; counter-reset: step; }

.chain__step {
    position: relative;
    padding: .75rem 0 .75rem 2.25rem;
    border-bottom: 1px solid var(--line);
    display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem;
}

/* The chain IS a sequence, so numbering the steps carries real meaning. */
.chain__step::before {
    counter-increment: step;
    content: counter(step);
    position: absolute; left: 0; top: .7rem;
    width: 1.5rem; height: 1.5rem;
    display: grid; place-items: center;
    border: 1px solid var(--line); border-radius: 50%;
    font-size: .75rem; color: var(--ink-muted);
}

.chain__step--approved::before { border-color: var(--ok); color: var(--ok); }
.chain__step--rejected::before { border-color: var(--danger); color: var(--danger); }
.chain__step--current::before  { border-color: var(--accent); color: var(--accent); border-width: 2px; }

.chain__comment { flex-basis: 100%; margin: .35rem 0 0; color: var(--ink-muted); }

select[multiple] { min-height: 8rem; }

/* ---- Conversation panel --------------------------------------------- */

.thread__attach input[type="file"] { max-width: 15rem; }

.thread__timer {
    font-variant-numeric: tabular-nums;
    color: var(--danger);
}

.thread__recorded { margin: .5rem 0 0; font-size: .9rem; }

.comment__meta { flex-wrap: wrap; }
.comment__audio { display: block; width: 100%; max-width: 20rem; margin-top: .5rem; }
.comment__files { margin: .5rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.comment__file {
    font-size: .85rem;
    padding: .15rem .5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
}

details.panel summary { cursor: pointer; font-weight: 600; }
details.panel[open] summary { margin-bottom: .75rem; }

.sidebar a.is-current { background: var(--canvas); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }

/* ---- Notifications --------------------------------------------------- */

.notifications { position: relative; }

.topbar__bell { cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; }

.badge {
    background: var(--danger); color: #fff;
    border-radius: 999px; font-size: .7rem;
    min-width: 1.1rem; padding: 0 .3rem; text-align: center;
}

.notifications__panel {
    position: absolute; right: 0; top: calc(100% + .4rem); z-index: 20;
    width: min(340px, 90vw);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
}

.notifications__head {
    display: flex; align-items: center; justify-content: space-between;
    margin: 0; padding: .6rem .75rem;
    border-bottom: 1px solid var(--line);
    font-weight: 600; font-size: .9rem;
}

.notifications__list {
    list-style: none; margin: 0; padding: 0;
    max-height: 60vh; overflow-y: auto;
}

.notifications__list li { padding: .6rem .75rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
.notifications__list li:last-child { border-bottom: 0; }
.notification.is-unread { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.notification a { display: block; text-decoration: none; }
.notification span { font-size: .78rem; }

/* ---- Pagination ------------------------------------------------------ */

.pagination { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-top: 1rem; }
.pagination button { cursor: pointer; min-width: 2.2rem; }
.pagination button:disabled { opacity: .45; cursor: default; }
.pagination .is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination span { margin-left: .5rem; font-size: .85rem; }

/* ---- Audit trail ----------------------------------------------------- */

.audit__list { list-style: none; margin: 0; padding: 0; }
.audit__list li { padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.audit__list li:last-child { border-bottom: 0; }
.audit__list span { margin-left: .4rem; font-size: .8rem; }

/* ---- Administration -------------------------------------------------- */

.topbar__admin { text-decoration: none; font-size: .9rem; }
.topbar__link { text-decoration: none; font-size: .9rem; }

.row-actions { display: flex; flex-wrap: wrap; gap: .25rem; white-space: nowrap; }
.row-actions .btn { padding: .25rem .5rem; font-size: .85rem; }

.chain-step-row {
    display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
    padding: .5rem 0; border-bottom: 1px solid var(--line);
}
.chain-step-row select { flex: 1 1 12rem; }

.steps { margin: 0; padding-left: 1.2rem; }
.steps li { margin-bottom: .35rem; }

.card p { margin: .5rem 0 0; font-size: .9rem; }

[hidden]{display:none!important}
.kanban{display:flex;gap:1rem;overflow-x:auto;margin:1rem 0}.kanban__column{min-width:240px;flex:1;background:#f3f5f8;padding:1rem;border-radius:8px}.kanban__column h3{text-transform:capitalize}.kanban__card{display:block;background:white;color:inherit;border:1px solid #d9e1ea;padding:1rem;margin-bottom:.75rem;border-radius:6px;text-decoration:none}.view-switch{display:flex;gap:.5rem;margin:1rem 0}.health{display:inline-block;padding:.25rem .6rem;border-radius:5px;font-weight:600}.health--red{background:#fee2e2;color:#991b1b}.health--yellow{background:#fef3c7;color:#854d0e}.health--green{background:#dcfce7;color:#166534}.table-scroll{overflow-x:auto;-webkit-overflow-scrolling:touch}.table-scroll>.table{width:auto;min-width:100%}.drawing-stage{position:relative;max-width:100%;overflow:hidden}.drawing-stage canvas{display:block;width:100%;height:auto}.drawing-stage [data-markup-canvas]{position:absolute;inset:0;touch-action:none}.markup-note{white-space:pre-wrap}
