/*
 * SVX CRM — design tokens and components.
 *
 * Principle: the chrome stays neutral, color carries information only.
 * Three carriers, never mixed: a person's identity color (chip + card edge),
 * a task status (column header), a priority that actually needs attention
 * (high / urgent badge). Everything else is ink on paper.
 */

/* ---------------------------------------------------------------- fonts */

@font-face {
    font-family: 'Bricolage Grotesque';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url("../fonts/bricolage-latin-ext-E7qegro.woff2") format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Bricolage Grotesque';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url("../fonts/bricolage-latin-ZzKOOYL.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/inter-latin-ext-9fzmmZy.woff2") format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/inter-latin-joy4ri1.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/plexmono-400-latin-ext-bsYzT0_.woff2") format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/plexmono-400-latin--Imvmox.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/plexmono-500-latin-ext-XLxX8eM.woff2") format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/plexmono-500-latin-J35NZ7_.woff2") format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}

/* --------------------------------------------------------------- tokens */

:root {
    /* ink */
    --ink: #141c25;
    --ink-2: #38434f;
    --muted: #667382;
    --muted-2: #8b95a2;

    /* paper */
    --canvas: #eef1f4;
    --surface: #ffffff;
    --surface-2: #f6f8fa;
    --surface-3: #eceff3;
    --line: #e2e7ec;
    --line-2: #cdd5de;

    /* signals */
    --focus: #1d4ed8;
    --danger: #a8261c;
    --danger-soft: #fdf3f2;
    --ok: #0f6e63;
    --warn: #b25e00;

    /* type */
    --font-display: 'Bricolage Grotesque', 'Helvetica Neue', Arial, sans-serif;
    --font-body: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    /* space: one scale, used everywhere, no ad-hoc values */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;
    --sp-7: 3rem;
    --sp-8: 4rem;

    /* shape */
    --r-xs: 4px;
    --r-sm: 6px;
    --r: 10px;
    --r-lg: 14px;

    --shadow-1: 0 1px 2px rgba(20, 28, 37, 0.05), 0 1px 3px rgba(20, 28, 37, 0.04);
    --shadow-2: 0 1px 2px rgba(20, 28, 37, 0.06), 0 10px 24px -12px rgba(20, 28, 37, 0.22);
    --shadow-drawer: -24px 0 60px -24px rgba(20, 28, 37, 0.35);

    /* metrics */
    --control: 2.5rem;
    --control-sm: 2.125rem;
    --rail: 15.5rem;
    --gutter: clamp(1.25rem, 3vw, 2.5rem);

    /* status hues: a progression, not a rainbow */
    --st-new: #7c8b9c;
    --st-assigned: #3d68cd;
    --st-in_progress: #b76a08;
    --st-waiting: #8a7a63;
    --st-review: #0e7885;
    --st-done: #197d43;
    --st-archived: #9aa5b1;
}

/* ----------------------------------------------------------------- base */

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

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

body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    line-height: 1.55;
    font-feature-settings: 'cv05' 1;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0;
}

h1 {
    font-size: clamp(1.5rem, 2.2vw, 1.9rem);
    letter-spacing: -0.03em;
}

h2 {
    font-size: 1.15rem;
}

h3 {
    font-size: 1rem;
}

p {
    margin: 0 0 var(--sp-4);
}

p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--ink);
    text-decoration-color: var(--line-2);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    text-decoration-color: currentColor;
}

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

.mono {
    font-family: var(--font-mono);
    font-size: 0.84em;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 var(--sp-2);
}

.lede {
    color: var(--muted);
    max-width: 60ch;
    margin: var(--sp-2) 0 0;
}

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.stack > * + * {
    margin-top: var(--sp-5);
}

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

.app {
    display: grid;
    grid-template-columns: var(--rail) minmax(0, 1fr);
    min-height: 100dvh;
}

.app--bare {
    display: block;
}

/* sidebar ---------------------------------------------------------------*/

.sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
    padding: var(--sp-5) var(--sp-4);
    background: var(--surface);
    border-right: 1px solid var(--line);
    z-index: 20;
}

.wordmark {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 0 var(--sp-2);
    color: var(--ink);
    text-decoration: none;
}

.wordmark-mark {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--r-sm);
    background: var(--ink);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.wordmark-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.wordmark-text strong {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

.wordmark-text span {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.railnav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.railnav a {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: var(--control);
    padding: 0 var(--sp-3);
    border-radius: var(--r-sm);
    color: var(--ink-2);
    font-weight: 500;
    text-decoration: none;
}

.railnav a svg {
    width: 1.05rem;
    height: 1.05rem;
    flex: none;
    color: var(--muted);
}

.railnav a:hover {
    background: var(--surface-3);
    color: var(--ink);
}

.railnav a[aria-current='page'] {
    background: var(--ink);
    color: #fff;
}

.railnav a[aria-current='page'] svg {
    color: #fff;
}

.sidebar-foot {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--line);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-height: var(--control);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-sm);
    color: var(--ink);
    text-decoration: none;
    min-width: 0;
}

.sidebar-user:hover {
    background: var(--surface-3);
}

.sidebar-user > span:not(.chip) {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user .identity-name,
.sidebar-user .identity-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-logout {
    justify-content: flex-start;
    width: 100%;
}

/* content ---------------------------------------------------------------*/

.content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100dvh;
    overflow-y: auto;
}

/* Board and other full-height screens own their scrolling internally. */
.content--fixed {
    overflow: hidden;
}

.page {
    width: min(64rem, 100%);
    margin: 0 auto;
    padding: var(--sp-6) var(--gutter) var(--sp-8);
    flex: 1;
    min-width: 0;
}

.page--wide {
    width: min(84rem, 100%);
}

/* Screens that manage their own gutters and scrolling (the board). */
.page--full {
    width: 100%;
    max-width: none;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0 0 var(--sp-4);
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-4) var(--sp-5);
    flex-wrap: wrap;
    margin-bottom: var(--sp-5);
}

.page-head > div:first-child {
    min-width: 0;
}

.page-head-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

/* ----------------------------------------------------------------- chip */

.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--chip-color, var(--ink));
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    flex: none;
}

.chip--lg {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 0.9rem;
}

.identity {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-width: 0;
}

.identity-name {
    font-weight: 600;
    line-height: 1.25;
}

.identity-meta {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.3;
}

.is-inactive .chip {
    background: var(--line-2);
}

.is-inactive .identity-name {
    color: var(--muted);
    text-decoration: line-through;
    text-decoration-thickness: 1px;
}

/* ---------------------------------------------------------------- badge */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 0.1rem 0.5rem;
    border: 1px solid var(--line-2);
    border-radius: 999px;
    background: var(--surface);
    font-size: 0.73rem;
    font-weight: 500;
    color: var(--ink-2);
    white-space: nowrap;
}

.badge--admin {
    border-color: var(--ink);
    background: var(--ink);
    color: #fff;
}

.badge--off {
    border-color: var(--line-2);
    background: var(--surface-2);
    color: var(--muted);
}

.badge--warn {
    border-color: color-mix(in srgb, var(--warn) 45%, transparent);
    background: color-mix(in srgb, var(--warn) 8%, var(--surface));
    color: var(--warn);
}

.badge--danger {
    border-color: color-mix(in srgb, var(--danger) 45%, transparent);
    background: color-mix(in srgb, var(--danger) 8%, var(--surface));
    color: var(--danger);
}

.badge--quiet {
    border-color: transparent;
    background: var(--surface-3);
    color: var(--muted);
}

.tag {
    display: inline-flex;
    padding: 0.05rem 0.45rem;
    border-radius: var(--r-xs);
    background: var(--surface-3);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--ink-2);
}

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

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-1);
}

.panel + .panel {
    margin-top: var(--sp-5);
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--line);
}

.panel-head .help {
    display: block;
    margin: var(--sp-1) 0 0;
    font-size: 0.82rem;
    color: var(--muted);
}

.panel-body {
    padding: var(--sp-5);
}

/* A section is a panel's quieter sibling: used inside panels, where a
   second nested box would only add noise. */
.section + .section {
    margin-top: var(--sp-5);
    padding-top: var(--sp-5);
    border-top: 1px solid var(--line);
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}

.section-head h3 {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

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

.table-wrap {
    overflow-x: auto;
    border-radius: var(--r);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

table.data-table td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

table.data-table tr:last-child td {
    border-bottom: none;
}

table.data-table tbody tr:hover {
    background: var(--surface-2);
}

table.data-table .identity-meta {
    margin-top: 0.1rem;
    font-size: 0.76rem;
}

td.actions {
    text-align: right;
    white-space: nowrap;
}

/* Inline forms in an actions cell used to collapse onto the buttons next
   to them; give the cell one row layout instead. */
td.actions > * {
    vertical-align: middle;
}

.action-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-2);
}

.action-row form {
    margin: 0;
}

/* -------------------------------------------------------------- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-height: var(--control);
    padding: 0 var(--sp-4);
    border: 1px solid var(--ink);
    border-radius: var(--r-sm);
    background: var(--ink);
    color: #fff;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.btn:hover {
    background: #000;
    border-color: #000;
}

.btn--ghost {
    background: var(--surface);
    border-color: var(--line-2);
    color: var(--ink);
    font-weight: 500;
}

.btn--ghost:hover {
    background: var(--surface-2);
    border-color: var(--ink-2);
    color: var(--ink);
}

.btn--quiet {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
    font-weight: 500;
}

.btn--quiet:hover {
    background: var(--surface-3);
    border-color: transparent;
    color: var(--ink);
}

/* Quiet until touched: destructive actions must not compete with the
   identity colors that carry the actual data. */
.btn--danger {
    background: var(--surface);
    border-color: var(--line-2);
    color: var(--ink-2);
    font-weight: 500;
}

.btn--danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn--sm {
    min-height: var(--control-sm);
    padding: 0 var(--sp-3);
    font-size: 0.83rem;
}

.btn--icon {
    padding: 0;
    width: var(--control-sm);
    min-height: var(--control-sm);
}

.btn-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-wrap: wrap;
}

/* --------------------------------------------------------------- fields */

.field {
    margin-bottom: var(--sp-4);
}

.field > label,
.field-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: var(--sp-1);
}

.field input[type='text'],
.field input[type='email'],
.field input[type='password'],
.field input[type='date'],
.field input[type='search'],
.field textarea,
.field select,
.input {
    width: 100%;
    min-height: var(--control);
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.9rem;
    transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.field textarea {
    min-height: 5.5rem;
    resize: vertical;
    line-height: 1.5;
}

.field input::placeholder,
.input::placeholder {
    color: var(--muted-2);
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.input:hover {
    border-color: var(--muted-2);
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible,
.input:focus-visible {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
}

.field .help {
    display: block;
    margin-top: var(--sp-1);
    font-size: 0.8rem;
    color: var(--muted);
}

.field .errors {
    list-style: none;
    margin: var(--sp-2) 0 0;
    padding: 0;
    color: var(--danger);
    font-size: 0.83rem;
    font-weight: 500;
}

.field--check {
    display: flex;
    gap: var(--sp-3);
    align-items: flex-start;
    margin-bottom: var(--sp-4);
    min-width: 0;
}

.field--check input {
    width: 1.1rem;
    height: 1.1rem;
    margin-top: 0.2rem;
    accent-color: var(--ink);
    flex: none;
}

.field--check label {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
}

.field--check .help {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.8rem;
    color: var(--muted);
}

/* Long input lines are hard to scan; keep form columns to a readable width. */
.form-column {
    max-width: 36rem;
}

.input--mono {
    font-family: var(--font-mono);
    font-size: 0.86rem;
}

.password-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrap input {
    padding-right: 5.75rem;
}

.password-toggle {
    position: absolute;
    right: 0.3rem;
    min-height: 1.9rem;
    padding: 0 var(--sp-2);
    border: 1px solid var(--line-2);
    border-radius: var(--r-xs);
    background: var(--surface-2);
    color: var(--ink-2);
    font: inherit;
    font-size: 0.76rem;
    cursor: pointer;
}

.password-toggle:hover {
    border-color: var(--ink-2);
    background: var(--surface);
}

/* ------------------------------------------------------------- swatches */

.swatches {
    border: 0;
    margin: 0 0 var(--sp-4);
    padding: 0;
}

.swatches > legend {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-2);
    padding: 0;
    margin-bottom: var(--sp-2);
}

.swatch-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.swatch-grid label {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: var(--control);
    padding: 0 var(--sp-3) 0 var(--sp-2);
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: 0.85rem;
    cursor: pointer;
}

.swatch-grid label::before {
    content: '';
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: var(--swatch, var(--ink));
}

.swatch-grid input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.swatch-grid input:checked + label,
.swatch-grid label:has(input:checked) {
    border-color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--ink);
    font-weight: 600;
}

.swatch-grid input:focus-visible + label,
.swatch-grid label:has(input:focus-visible) {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

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

/* Flashes sit inside the page, so they line up with its content on every
   screen width instead of following their own container. */
.flashes {
    width: 100%;
    margin: 0 0 var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.page--full .flashes {
    padding: var(--sp-4) var(--gutter) 0;
    margin-bottom: 0;
}

.flash {
    display: flex;
    gap: var(--sp-3);
    align-items: flex-start;
    padding: var(--sp-3) var(--sp-4);
    border: 1px solid var(--line);
    border-left: 3px solid var(--ink);
    border-radius: var(--r-sm);
    background: var(--surface);
    box-shadow: var(--shadow-1);
    font-size: 0.9rem;
}

.flash--success {
    border-left-color: var(--ok);
}

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

/* ----------------------------------------------------------------- home */

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: var(--sp-3);
}

.legend-cell {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: var(--sp-3);
}

.stat {
    padding: var(--sp-4);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    margin-top: var(--sp-1);
    font-size: 0.8rem;
    color: var(--muted);
}

/* ---------------------------------------------------------------- board */

.board-page {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.board-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
    padding: var(--sp-5) var(--gutter) var(--sp-4);
}

.board-title {
    display: flex;
    align-items: baseline;
    gap: var(--sp-3);
    min-width: 0;
}

.board-title .eyebrow {
    margin: 0;
}

.board-toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

/* filters ---------------------------------------------------------------*/

.filterbar {
    display: flex;
    align-items: flex-end;
    gap: var(--sp-3) var(--sp-4);
    flex-wrap: wrap;
    margin: 0 var(--gutter) var(--sp-4);
    padding: var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-1);
}

/* The basis keeps the fields from being squeezed by the buttons: below it
   the actions wrap onto their own row instead of overlapping the last
   field. */
.filterbar-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: var(--sp-3) var(--sp-4);
    flex: 1 1 24rem;
    min-width: 0;
}

.filterbar .field {
    margin: 0;
    min-width: 0;
}

.filterbar .field--check {
    margin: 0;
    align-self: end;
    padding-bottom: 0.55rem;
}

.filterbar-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

/* columns ---------------------------------------------------------------*/

.board-columns {
    display: flex;
    align-items: stretch;
    gap: var(--sp-3);
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 var(--gutter) var(--sp-4);
    scroll-snap-type: x proximity;
}

.board-column {
    flex: 0 0 19rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r);
    scroll-snap-align: start;
}

.board-column-head {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--line);
    border-radius: var(--r) var(--r) 0 0;
    background: var(--surface);
}

/* The status is the column's own identity — it gets the color, the cards
   do not have to repeat it. */
.board-column-head::before {
    content: '';
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--status, var(--st-new));
    flex: none;
}

.board-column-name {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-2);
    margin-right: auto;
}

.board-column-count {
    min-width: 1.5rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.board-column[data-status='new'] { --status: var(--st-new); }
.board-column[data-status='assigned'] { --status: var(--st-assigned); }
.board-column[data-status='in_progress'] { --status: var(--st-in_progress); }
.board-column[data-status='waiting'] { --status: var(--st-waiting); }
.board-column[data-status='review'] { --status: var(--st-review); }
.board-column[data-status='done'] { --status: var(--st-done); }
.board-column[data-status='archived'] { --status: var(--st-archived); }

/* Tasks stranded in a switched-off column: visible, clearly not part of
   the workflow, and one-way — nothing can be dropped back in. */
.board-column--hidden {
    background: var(--surface-3);
    border-style: dashed;
}

.board-column--hidden .board-column-head::before {
    background: var(--muted-2);
}

.board-column-note {
    margin: 0;
    padding: var(--sp-3) var(--sp-3) 0;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.4;
}

.board-column-body {
    flex: 1;
    min-height: 3rem;
    overflow-y: auto;
    padding: var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    scrollbar-width: thin;
}

.board-column-body:empty::after {
    content: 'Sem presuň kartu';
    display: grid;
    place-items: center;
    min-height: 4rem;
    border: 1px dashed var(--line-2);
    border-radius: var(--r-sm);
    color: var(--muted-2);
    font-size: 0.82rem;
}

/* cards -----------------------------------------------------------------*/

.task-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    width: 100%;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--edge, var(--line-2));
    border-radius: var(--r-sm);
    padding: var(--sp-3);
    font: inherit;
    color: inherit;
    box-shadow: var(--shadow-1);
    cursor: pointer;
    transition: box-shadow 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.task-card:hover {
    box-shadow: var(--shadow-2);
}

.task-card:focus-within,
.task-card.is-active {
    border-color: var(--focus);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 30%, transparent);
}

.task-card--unassigned {
    border-left-style: dashed;
}

.task-card-title {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--ink);
    font-weight: 600;
    font-size: 0.92rem;
    line-height: 1.35;
    text-decoration: none;
}

.task-card-title:hover {
    text-decoration: underline;
    text-decoration-color: var(--line-2);
    text-underline-offset: 3px;
}

.task-card-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-width: 0;
}

.task-card-row .identity {
    min-width: 0;
    font-size: 0.82rem;
}

.task-card-row .identity span:not(.chip) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-card-spacer {
    margin-left: auto;
}

.task-card-facts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-1) var(--sp-3);
    color: var(--muted);
    font-size: 0.76rem;
}

.task-card-facts .mono {
    font-size: 0.72rem;
}

.task-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
}

.overdue-flag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--danger);
    font-weight: 600;
}

/* Status control on the card: the keyboard-and-screenreader route to the
   same move drag-and-drop performs. Quiet until pointed at, never hidden. */
.status-select {
    width: 100%;
    min-height: var(--control-sm);
    padding: 0 var(--sp-2);
    border: 1px solid transparent;
    border-radius: var(--r-xs);
    background: var(--surface-2);
    color: var(--muted);
    font: inherit;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    cursor: pointer;
}

.status-select:hover,
.task-card:hover .status-select {
    border-color: var(--line-2);
    background: var(--surface);
    color: var(--ink-2);
}

.status-select:focus-visible {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
    color: var(--ink);
}

.status-select--lg {
    width: auto;
    min-width: 12rem;
    min-height: var(--control);
    border-color: var(--line-2);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 0.9rem;
}

/* SortableJS states */
.sortable-ghost {
    opacity: 0.4;
}

.sortable-drag {
    box-shadow: var(--shadow-2);
}

.board-column-body.sortable-over {
    background: var(--surface-3);
}

/* --------------------------------------------------------------- drawer */

.drawer {
    position: fixed;
    inset: 0;
    z-index: 40;
    pointer-events: none;
}

.drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 28, 37, 0.28);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100dvh;
    width: min(32rem, 100%);
    display: flex;
    flex-direction: column;
    background: var(--canvas);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-drawer);
    transform: translateX(100%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.drawer.is-open {
    pointer-events: auto;
}

.drawer.is-open .drawer-backdrop {
    opacity: 1;
}

.drawer.is-open .drawer-panel {
    transform: translateX(0);
}

.drawer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex: none;
}

.drawer-bar-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.drawer-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--sp-4);
}

.drawer-empty {
    display: grid;
    place-items: center;
    min-height: 12rem;
    padding: var(--sp-6) var(--sp-4);
    border: 1px dashed var(--line-2);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--muted);
    text-align: center;
}

/* The task detail doubles as a standalone page; inside the drawer it drops
   the extra frame so the panel is not a box inside a box. */
.drawer .panel {
    border: none;
    box-shadow: none;
    background: transparent;
}

.drawer .panel-head {
    padding: 0 0 var(--sp-3);
}

.drawer .panel-body {
    padding: var(--sp-4) 0 0;
}

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

.task-detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: var(--sp-3);
    padding: var(--sp-4);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
}

.task-detail-meta + .section {
    margin-top: var(--sp-5);
}

.meta-item {
    min-width: 0;
}

.meta-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.15rem;
}

.meta-value {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: 0.88rem;
    font-weight: 500;
    min-width: 0;
}

.task-description {
    white-space: pre-wrap;
    color: var(--ink-2);
}

.checklist {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--line);
}

.checklist-item:last-child {
    border-bottom: none;
}

.checklist-item form {
    display: flex;
    margin: 0;
}

.checklist-item input[type='checkbox'] {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--ok);
    cursor: pointer;
}

.checklist-item.is-done .checklist-label {
    color: var(--muted);
    text-decoration: line-through;
}

.checklist-label {
    flex: 1;
    font-size: 0.88rem;
    min-width: 0;
}

.file-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--line);
}

.file-row:last-of-type {
    border-bottom: none;
}

.file-row a {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.88rem;
}

.file-row form {
    margin: 0;
}

/* Explicitly distinct from button shapes so the two can never be mistaken
   for each other. */
.dropzone {
    border: 1px dashed var(--line-2);
    border-radius: var(--r-sm);
    padding: var(--sp-4);
    text-align: center;
    color: var(--muted);
    background: var(--surface-2);
    font-size: 0.85rem;
}

.dropzone p {
    margin: 0 0 var(--sp-2);
}

.dropzone.is-dragover {
    border-color: var(--focus);
    border-style: solid;
    background: color-mix(in srgb, var(--focus) 6%, var(--surface));
    color: var(--ink);
}

.dropzone input[type='file'] {
    display: block;
    margin: 0 auto;
    font-size: 0.8rem;
}

.comment {
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--line);
}

.comment:last-of-type {
    border-bottom: none;
}

.comment-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    margin-bottom: var(--sp-1);
}

.comment-body {
    white-space: pre-wrap;
    margin: 0;
    font-size: 0.9rem;
}

.comment textarea {
    width: 100%;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.88rem;
    resize: vertical;
}

.comment--deleted .comment-body {
    color: var(--muted);
    font-style: italic;
}

.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    font-size: 0.83rem;
}

.history-item {
    color: var(--muted);
    padding-left: var(--sp-3);
    border-left: 2px solid var(--line);
}

.history-item strong {
    color: var(--ink-2);
    font-weight: 600;
}

/* ----------------------------------------------------------------- auth */

.auth {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    background: var(--surface);
}

.auth--plain {
    grid-template-columns: minmax(0, 1fr);
}

/* The team palette: the one primitive the whole app is built on, shown at
   the size it deserves instead of as an 88px sliver. */
.auth-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--sp-6);
    padding: var(--sp-7) var(--sp-6);
    background: var(--ink);
    color: #fff;
    overflow: hidden;
}

.auth-aside .wordmark {
    color: #fff;
    padding: 0;
}

.auth-aside .wordmark-mark {
    background: #fff;
    color: var(--ink);
}

.auth-aside .wordmark-text span {
    color: rgba(255, 255, 255, 0.6);
}

.auth-claim {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.15;
    max-width: 18ch;
    margin: 0;
}

.auth-claim-note {
    margin: var(--sp-3) 0 0;
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.9rem;
    max-width: 34ch;
}

.spectrum {
    display: flex;
    gap: 3px;
    height: 4.5rem;
}

.spectrum span {
    flex: 1;
    border-radius: var(--r-xs);
    background: var(--band);
    transform: scaleY(0);
    transform-origin: bottom;
    animation: band-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes band-in {
    to {
        transform: scaleY(1);
    }
}

.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 5vw, 4rem);
    background: var(--canvas);
}

.auth-inner {
    width: min(26rem, 100%);
}

.auth-inner h1 {
    margin-bottom: var(--sp-2);
}

.auth-sub {
    color: var(--muted);
    margin-bottom: var(--sp-5);
}

.auth-form {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: var(--shadow-2);
    padding: var(--sp-5);
}

.auth-form .field:last-of-type {
    margin-bottom: var(--sp-2);
}

.auth-foot {
    margin-top: var(--sp-4);
    font-size: 0.85rem;
    color: var(--muted);
}

.auth-error {
    border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
    border-left-width: 3px;
    border-radius: var(--r-sm);
    background: var(--danger-soft);
    color: #7d1c14;
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-4);
    font-size: 0.9rem;
}

.auth .flashes {
    width: 100%;
    padding: 0;
    margin: 0 0 var(--sp-4);
}

/* --------------------------------------------------------- adaptations */

@media (max-width: 1100px) {
    :root {
        --rail: 13.5rem;
    }
}

@media (max-width: 900px) {
    .app {
        grid-template-columns: minmax(0, 1fr);
    }

    /* The rail becomes a bottom bar: thumb-reachable, never covering
       content because the content reserves the space. */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: var(--sp-1);
        padding: var(--sp-2) var(--sp-2) max(var(--sp-2), env(safe-area-inset-bottom));
        border-right: none;
        border-top: 1px solid var(--line);
        box-shadow: 0 -8px 24px -16px rgba(20, 28, 37, 0.4);
    }

    .sidebar > .wordmark {
        display: none;
    }

    .railnav {
        flex-direction: row;
        flex: 1;
        gap: var(--sp-1);
    }

    .railnav a {
        flex: 1;
        flex-direction: column;
        gap: 2px;
        justify-content: center;
        min-height: 3.25rem;
        padding: 0 var(--sp-1);
        font-size: 0.68rem;
        text-align: center;
    }

    .railnav a svg {
        width: 1.15rem;
        height: 1.15rem;
    }

    .sidebar-foot {
        margin: 0;
        padding: 0;
        border: none;
        flex: none;
    }

    .sidebar-user {
        padding: var(--sp-1);
        min-height: 3.25rem;
    }

    .sidebar-user .identity-name,
    .sidebar-user .identity-meta,
    .sidebar-logout {
        display: none;
    }

    .content {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
        padding-bottom: 4.75rem;
    }

    .content--fixed {
        overflow: visible;
    }

    .board-columns {
        overflow-y: visible;
        padding-bottom: var(--sp-5);
    }

    .board-column {
        flex-basis: min(19rem, 82vw);
        max-height: none;
        height: 70vh;
    }

    .auth {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth-aside {
        padding: var(--sp-5) var(--sp-5) var(--sp-6);
    }

    .auth-claim {
        display: none;
    }

    .spectrum {
        height: 2.25rem;
    }
}

@media (max-width: 640px) {
    :root {
        /* Touch targets grow where fingers are the only input. */
        --control: 2.75rem;
        --control-sm: 2.5rem;
    }

    .page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .drawer-panel {
        width: 100%;
        border-left: none;
    }

    .filterbar {
        flex-direction: column;
        align-items: stretch;
        padding: var(--sp-3);
    }

    .filterbar-fields {
        grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    }

    .filterbar-actions {
        justify-content: flex-end;
    }
}

@media (prefers-reduced-motion: reduce) {
    .spectrum span {
        animation: none;
        transform: none;
    }

    .drawer-panel {
        transition: none;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
