/* =============================================================================
   TachyEl Ops — design system
   -----------------------------------------------------------------------------
   Neo-brutalist: hard edges, offset shadows that collapse on press, saturated
   fills carrying black text in both themes. Replaces the Tailwind CDN, which
   generated CSS at runtime on every page load.

   Structure: tokens, reset, typography, layout, components, motion, responsive.
   ========================================================================== */

/* --- Tokens --------------------------------------------------------------- */

:root {
    /* Accents are deliberately light enough to carry black text, so a chip
       reads identically in both themes and always clears contrast. */
    --lime:   #c8fa3c;
    --cyan:   #5ce1ff;
    --pink:   #ff6fb5;
    --violet: #a78bfa;
    --amber:  #ffc94a;
    --coral:  #ff7a5c;
    --mint:   #6ee7b7;
    --sky:    #93c5fd;

    --bg:            #fff8ef;
    --bg-grid:       rgba(11, 11, 15, 0.05);
    --surface:       #ffffff;
    --surface-sunk:  #f4efe6;
    --surface-alt:   #fffdf8;

    --ink:        #0b0b0f;
    --ink-soft:   #45454f;
    --ink-faint:  #7a7a88;

    --line:         #0b0b0f;
    --line-width:   3px;
    --line-thin:    2px;
    --shadow-color: #0b0b0f;

    --radius:    14px;
    --radius-sm: 10px;
    --radius-lg: 22px;
    --radius-pill: 999px;

    --shadow:     5px 5px 0 var(--shadow-color);
    --shadow-sm:  3px 3px 0 var(--shadow-color);
    --shadow-lg:  8px 8px 0 var(--shadow-color);
    --shadow-in:  inset 0 3px 0 rgba(11, 11, 15, 0.08);

    --font: "Space Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

    --step: 4px;
    --header-h: 68px;
    --rail-w: 268px;

    --ease: cubic-bezier(0.2, 0.9, 0.3, 1.2);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

    color-scheme: light;
}

html[data-theme="dark"] {
    --bg:           #0b0b11;
    --bg-grid:      rgba(255, 255, 255, 0.05);
    --surface:      #17171f;
    --surface-sunk: #101017;
    --surface-alt:  #1d1d27;

    --ink:       #f4f4f8;
    --ink-soft:  #a8a8b8;
    --ink-faint: #71717f;

    --line:         #f4f4f8;
    --line-width:   2px;
    --line-thin:    2px;
    --shadow-color: rgba(244, 244, 248, 0.9);

    --shadow:    4px 4px 0 var(--shadow-color);
    --shadow-sm: 3px 3px 0 var(--shadow-color);
    --shadow-lg: 7px 7px 0 var(--shadow-color);
    --shadow-in: inset 0 3px 0 rgba(0, 0, 0, 0.35);

    color-scheme: dark;
}

/* --- Reset ---------------------------------------------------------------- */

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

* { margin: 0; padding: 0; }

html, body, #root { height: 100%; }

body {
    background-color: var(--bg);
    /* Faint grid: the graph-paper substrate the whole system sits on. */
    background-image:
        linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 26px 26px;
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }

:focus-visible {
    outline: 3px solid var(--violet);
    outline-offset: 2px;
    border-radius: 4px;
}

::selection { background: var(--lime); color: #0b0b0f; }

/* --- Scrollbars ----------------------------------------------------------- */

.scroll { scrollbar-width: thin; scrollbar-color: var(--ink-faint) transparent; }
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb {
    background: var(--surface-alt);
    border: 2px solid var(--line);
    border-radius: var(--radius-pill);
}
.scroll::-webkit-scrollbar-thumb:hover { background: var(--lime); }

/* --- Typography ----------------------------------------------------------- */

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }

.display {
    font-size: clamp(26px, 3.4vw, 38px);
    font-weight: 700;
    letter-spacing: -0.035em;
    text-transform: uppercase;
}

.title    { font-size: 21px; font-weight: 700; letter-spacing: -0.025em; }
.subtitle { font-size: 15px; font-weight: 600; }
.body     { font-size: 14px; }
.small    { font-size: 13px; }
.tiny     { font-size: 11.5px; }

.mono { font-family: var(--mono); font-variant-ligatures: none; }

.label {
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.muted  { color: var(--ink-soft); }
.faint  { color: var(--ink-faint); }
.strong { font-weight: 700; }
.num    { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 {
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}

/* --- Layout utilities ----------------------------------------------------- */

.row  { display: flex; align-items: center; gap: calc(var(--step) * 2); }
.col  { display: flex; flex-direction: column; gap: calc(var(--step) * 2); }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.center  { justify-content: center; }
.end     { justify-content: flex-end; }
.start   { align-items: flex-start; }
.stretch { align-items: stretch; }
.baseline{ align-items: baseline; }
.grow  { flex: 1; min-width: 0; }
.shrink-0 { flex-shrink: 0; }

.gap-1 { gap: 4px; }  .gap-2 { gap: 8px; }   .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-5 { gap: 20px; }  .gap-6 { gap: 26px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.grid-wide { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }

.hidden { display: none !important; }
.relative { position: relative; }
.full { width: 100%; }
.mt-auto { margin-top: auto; }

/* --- Surfaces ------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: var(--line-width) solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    position: relative;
}

.card--flat  { box-shadow: none; }
.card--sunk  { background: var(--surface-sunk); box-shadow: var(--shadow-in); }
.card--tight { padding: 14px; }
.card--pad-0 { padding: 0; overflow: hidden; }

/* A card that reacts to the pointer. Used for anything clickable. */
.card--live {
    transition: transform 140ms var(--ease), box-shadow 140ms var(--ease);
    cursor: pointer;
}
.card--live:hover  { transform: translate(-2px, -2px); box-shadow: var(--shadow-lg); }
.card--live:active { transform: translate(2px, 2px);  box-shadow: var(--shadow-sm); }

/* Colour-washed variants for stat tiles and callouts. */
.wash-lime   { background: var(--lime); }
.wash-cyan   { background: var(--cyan); }
.wash-pink   { background: var(--pink); }
.wash-violet { background: var(--violet); }
.wash-amber  { background: var(--amber); }
.wash-coral  { background: var(--coral); }
.wash-mint   { background: var(--mint); }
.wash-sky    { background: var(--sky); }
[class*="wash-"] { color: #0b0b0f; }
[class*="wash-"] .muted,
[class*="wash-"] .faint,
[class*="wash-"] .label { color: rgba(11, 11, 15, 0.66); }

/* --- Buttons -------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
    border: var(--line-width) solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
    transition: transform 110ms var(--ease), box-shadow 110ms var(--ease), background 110ms linear;
    white-space: nowrap;
    user-select: none;
}

.btn:hover:not(:disabled)  { transform: translate(-1px, -1px); box-shadow: var(--shadow); }
.btn:active:not(:disabled) { transform: translate(3px, 3px);   box-shadow: none; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: var(--shadow-sm); }

.btn--primary { background: var(--lime);   color: #0b0b0f; }
.btn--accent  { background: var(--violet); color: #0b0b0f; }
.btn--info    { background: var(--cyan);   color: #0b0b0f; }
.btn--warn    { background: var(--amber);  color: #0b0b0f; }
.btn--danger  { background: var(--coral);  color: #0b0b0f; }
.btn--chat    { background: var(--mint);   color: #0b0b0f; }

.btn--ghost {
    background: transparent;
    box-shadow: none;
    border-color: transparent;
}
.btn--ghost:hover:not(:disabled) {
    background: var(--surface-alt);
    border-color: var(--line);
    box-shadow: var(--shadow-sm);
    transform: none;
}

.btn--sm  { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn--lg  { padding: 13px 24px; font-size: 16px; border-radius: var(--radius); }
.btn--block { width: 100%; }

.btn--icon { padding: 8px; aspect-ratio: 1; }
.btn--icon.btn--sm { padding: 6px; }

/* The icon leans in when you hover the button it lives in. */
.btn svg { transition: transform 160ms var(--ease); }
.btn:hover:not(:disabled) svg { transform: rotate(-8deg) scale(1.12); }

/* --- Badges & chips ------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: var(--line-thin) solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface-alt);
    color: var(--ink);
    white-space: nowrap;
}

.badge--lime{background:var(--lime)}      .badge--cyan{background:var(--cyan)}
.badge--pink{background:var(--pink)}      .badge--violet{background:var(--violet)}
.badge--amber{background:var(--amber)}    .badge--coral{background:var(--coral)}
.badge--mint{background:var(--mint)}      .badge--sky{background:var(--sky)}
.badge[class*="badge--"]:not(.badge--plain) { color: #0b0b0f; }

/* Stickers sit at a jaunty angle and straighten up when you touch them. */
.sticker {
    transform: rotate(-2.5deg);
    transition: transform 200ms var(--ease);
    box-shadow: 2px 2px 0 var(--shadow-color);
}
.sticker:nth-of-type(even) { transform: rotate(2deg); }
.sticker:hover { transform: rotate(0deg) scale(1.06); }

.dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--line); flex-shrink: 0; }
.dot--on   { background: var(--mint); }
.dot--off  { background: var(--coral); }
.dot--idle { background: var(--amber); }

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

.field { display: flex; flex-direction: column; gap: 6px; }

.field > .label { display: flex; align-items: center; gap: 5px; }
.field .req { color: var(--coral); font-size: 13px; line-height: 1; }

.input, .select, .textarea {
    width: 100%;
    padding: 10px 13px;
    background: var(--surface-alt);
    border: var(--line-width) solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-weight: 500;
    color: var(--ink);
    transition: box-shadow 130ms var(--ease), transform 130ms var(--ease), background 130ms linear;
}

.input::placeholder, .textarea::placeholder { color: var(--ink-faint); font-weight: 400; }

.input:hover, .select:hover, .textarea:hover { background: var(--surface); }

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transform: translate(-1px, -1px);
}

.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }

.select {
    appearance: none;
    cursor: pointer;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%230b0b0f' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
html[data-theme="dark"] .select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23f4f4f8' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.input--invalid, .select--invalid, .textarea--invalid {
    border-color: var(--coral);
    background: color-mix(in srgb, var(--coral) 12%, var(--surface-alt));
}

.field-error {
    font-size: 12px;
    font-weight: 600;
    color: var(--coral);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Toggle switch, built as a real checkbox for keyboard and screen readers. */
.switch { position: relative; display: inline-flex; flex-shrink: 0; }
.switch input {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; z-index: 1;
}
.switch-track {
    width: 46px; height: 26px;
    background: var(--surface-sunk);
    border: var(--line-thin) solid var(--line);
    border-radius: var(--radius-pill);
    transition: background 160ms var(--ease);
    display: flex; align-items: center; padding: 2px;
}
.switch-thumb {
    width: 18px; height: 18px;
    background: var(--surface);
    border: var(--line-thin) solid var(--line);
    border-radius: 50%;
    transition: transform 200ms var(--ease);
}
.switch input:checked + .switch-track { background: var(--lime); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--violet); outline-offset: 2px; }

/* --- Tables --------------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
    border: var(--line-width) solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.table { font-size: 13.5px; min-width: 640px; }

.table thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--ink);
    color: var(--bg);
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: left;
    padding: 11px 14px;
    white-space: nowrap;
}

.table thead th.sortable { cursor: pointer; user-select: none; }
.table thead th.sortable:hover { background: var(--violet); color: #0b0b0f; }

.table tbody td { padding: 12px 14px; border-top: var(--line-thin) solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background 110ms linear; }
.table tbody tr:hover { background: var(--surface-alt); }
.table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-sunk) 45%, transparent); }
.table tbody tr:nth-child(even):hover { background: var(--surface-alt); }

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

/* --- Kanban --------------------------------------------------------------- */

.kanban { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 14px; align-items: start; }

.kanban-col {
    background: var(--surface-sunk);
    border: var(--line-width) solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    min-height: 180px;
    display: flex; flex-direction: column; gap: 10px;
    transition: background 140ms linear, transform 140ms var(--ease);
}
.kanban-col.is-target {
    background: color-mix(in srgb, var(--lime) 35%, var(--surface-sunk));
    transform: scale(1.015);
}

.kanban-card {
    background: var(--surface);
    border: var(--line-thin) solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    padding: 11px;
    cursor: grab;
    transition: transform 130ms var(--ease), box-shadow 130ms var(--ease);
    display: flex; flex-direction: column; gap: 7px;
}
.kanban-card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow); }
.kanban-card.is-dragging { opacity: 0.4; transform: rotate(3deg) scale(0.97); cursor: grabbing; }

/* --- Progress ------------------------------------------------------------- */

.meter {
    height: 14px;
    background: var(--surface-sunk);
    border: var(--line-thin) solid var(--line);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    background: var(--lime);
    /* Candy stripes so a bar in motion reads as "working". */
    background-image: repeating-linear-gradient(
        45deg, rgba(11, 11, 15, 0.16) 0 6px, transparent 6px 12px
    );
    border-right: var(--line-thin) solid var(--line);
    transition: width 600ms var(--ease-out);
    animation: stripe 900ms linear infinite;
}
.meter-fill[style*="width: 0%"], .meter-fill[style*="width:0%"] { border-right: none; }

@keyframes stripe { to { background-position: 34px 0; } }

/* --- Avatars -------------------------------------------------------------- */

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: var(--line-thin) solid var(--line);
    display: grid; place-items: center;
    font-size: 12.5px; font-weight: 700;
    color: #0b0b0f;
    flex-shrink: 0;
    text-transform: uppercase;
}
.avatar--sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar--lg { width: 48px; height: 48px; font-size: 17px; box-shadow: var(--shadow-sm); }

.avatar-stack { display: flex; }
.avatar-stack .avatar + .avatar { margin-left: -9px; }

/* --- Modal ---------------------------------------------------------------- */

.overlay {
    position: fixed; inset: 0; z-index: 90;
    background: color-mix(in srgb, var(--ink) 55%, transparent);
    backdrop-filter: blur(3px);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 5vh 16px 16px;
    overflow-y: auto;
    animation: fade 160ms var(--ease-out);
}

.modal {
    width: 100%;
    background: var(--surface);
    border: var(--line-width) solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: pop 240ms var(--ease);
    margin-bottom: 5vh;
}

.modal-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
    padding: 18px 20px;
    border-bottom: var(--line-width) solid var(--line);
    background: var(--surface-alt);
    border-radius: calc(var(--radius-lg) - var(--line-width)) calc(var(--radius-lg) - var(--line-width)) 0 0;
}

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.modal-foot {
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
    padding: 16px 20px;
    border-top: var(--line-width) solid var(--line);
    background: var(--surface-sunk);
    border-radius: 0 0 calc(var(--radius-lg) - var(--line-width)) calc(var(--radius-lg) - var(--line-width));
    flex-wrap: wrap;
}

.modal--sm { max-width: 440px; }
.modal--md { max-width: 620px; }
.modal--lg { max-width: 860px; }
.modal--xl { max-width: 1080px; }

/* --- Toasts --------------------------------------------------------------- */

.toaster {
    position: fixed; right: 18px; bottom: 18px; z-index: 120;
    display: flex; flex-direction: column-reverse; gap: 10px;
    max-width: min(380px, calc(100vw - 36px));
    pointer-events: none;
}

.toast {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    background: var(--surface);
    border: var(--line-width) solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: slide-in 280ms var(--ease);
    pointer-events: auto;
    font-size: 13.5px;
    font-weight: 600;
}
.toast.is-leaving { animation: slide-out 200ms var(--ease-out) forwards; }

.toast--ok    { background: var(--lime);  color: #0b0b0f; }
.toast--bad   { background: var(--coral); color: #0b0b0f; }
.toast--info  { background: var(--cyan);  color: #0b0b0f; }
.toast--warn  { background: var(--amber); color: #0b0b0f; }

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

.shell { display: flex; min-height: 100%; }

.rail {
    width: var(--rail-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: var(--line-width) solid var(--line);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    z-index: 40;
}

.rail-head {
    padding: 16px;
    border-bottom: var(--line-width) solid var(--line);
    display: flex; align-items: center; gap: 11px;
}

.rail-nav { flex: 1; overflow-y: auto; padding: 12px 10px 16px; }

.rail-group + .rail-group { margin-top: 16px; }
.rail-group > .label { padding: 0 8px 7px; display: block; }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: var(--line-thin) solid transparent;
    font-size: 13.5px; font-weight: 600;
    color: var(--ink-soft);
    text-align: left;
    transition: transform 120ms var(--ease), background 120ms linear, color 120ms linear;
}
.nav-item:hover { background: var(--surface-alt); color: var(--ink); border-color: var(--line); transform: translateX(3px); }
.nav-item.is-active {
    background: var(--lime);
    color: #0b0b0f;
    border-color: var(--line);
    box-shadow: var(--shadow-sm);
    font-weight: 700;
}
.nav-item svg { flex-shrink: 0; }

.nav-count {
    margin-left: auto;
    font-family: var(--mono); font-size: 10.5px; font-weight: 700;
    padding: 1px 7px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--ink);
}
.nav-item.is-active .nav-count { background: var(--surface); }

.rail-foot { padding: 12px; border-top: var(--line-width) solid var(--line); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--header-h);
    flex-shrink: 0;
    position: sticky; top: 0; z-index: 35;
    background: var(--surface);
    border-bottom: var(--line-width) solid var(--line);
    display: flex; align-items: center; gap: 12px;
    padding: 0 18px;
}

.content { flex: 1; min-width: 0; padding: 22px; display: flex; flex-direction: column; gap: 20px; max-width: 1560px; width: 100%; }

/* Search trigger in the top bar. */
.search-trigger {
    display: flex; align-items: center; gap: 9px;
    min-width: 210px;
    padding: 7px 12px;
    background: var(--surface-sunk);
    border: var(--line-thin) solid var(--line);
    border-radius: var(--radius-pill);
    color: var(--ink-faint);
    font-size: 13px; font-weight: 500;
    transition: background 130ms linear, transform 130ms var(--ease);
}
.search-trigger:hover { background: var(--surface-alt); transform: translateY(-1px); }

.kbd {
    font-family: var(--mono); font-size: 10px; font-weight: 700;
    padding: 2px 6px;
    border: 1.5px solid var(--line);
    border-radius: 5px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 2px 0 var(--shadow-color);
}

/* --- Command palette ------------------------------------------------------ */

.palette { max-width: 580px; width: 100%; }

.palette-input {
    width: 100%;
    padding: 17px 18px;
    background: transparent;
    border: none;
    font-size: 17px; font-weight: 600;
    outline: none;
}
.palette-input::placeholder { color: var(--ink-faint); }

.palette-results { max-height: 340px; overflow-y: auto; padding: 8px; }

.palette-row {
    display: flex; align-items: center; gap: 11px;
    width: 100%; padding: 9px 11px;
    border-radius: var(--radius-sm);
    border: var(--line-thin) solid transparent;
    text-align: left;
    transition: background 100ms linear;
}
.palette-row:hover, .palette-row.is-cursor {
    background: var(--lime); color: #0b0b0f; border-color: var(--line);
}
.palette-row.is-cursor .muted { color: rgba(11,11,15,0.66); }

/* --- Empty states & skeletons --------------------------------------------- */

.empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px;
    padding: 52px 24px;
    text-align: center;
    border: var(--line-width) dashed var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-sunk);
}
.empty-art { font-size: 46px; line-height: 1; animation: bob 3.2s ease-in-out infinite; }

.skeleton {
    background: linear-gradient(90deg, var(--surface-sunk) 25%, var(--surface-alt) 50%, var(--surface-sunk) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.3s linear infinite;
    border: var(--line-thin) solid var(--line);
    border-radius: var(--radius-sm);
}

/* --- Marquee -------------------------------------------------------------- */

.marquee {
    overflow: hidden;
    min-width: 0;
    border: var(--line-width) solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--ink);
    color: var(--bg);
    padding: 7px 0;
    box-shadow: var(--shadow-sm);
}
.marquee-track {
    display: flex; gap: 40px;
    white-space: nowrap;
    animation: marquee 34s linear infinite;
    font-family: var(--mono); font-size: 11.5px; font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase;
}
.marquee:hover .marquee-track { animation-play-state: paused; }

/* --- Tabs ----------------------------------------------------------------- */

.tabs {
    display: flex; gap: 6px; flex-wrap: wrap;
    padding: 5px;
    background: var(--surface-sunk);
    border: var(--line-thin) solid var(--line);
    border-radius: var(--radius-pill);
    width: fit-content;
    max-width: 100%;
}
.tab {
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 13px; font-weight: 700;
    color: var(--ink-soft);
    border: var(--line-thin) solid transparent;
    transition: background 120ms linear, color 120ms linear;
}
.tab:hover { color: var(--ink); background: var(--surface-alt); }
.tab.is-active { background: var(--cyan); color: #0b0b0f; border-color: var(--line); }

/* --- Main two-column layout ------------------------------------------------
   A named class rather than an inline grid-template-columns, so the mobile
   breakpoint below can actually collapse it. */

.grid-main {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

/* --- Split view (list + detail) ------------------------------------------- */

.split { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
.split-list { display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 210px); overflow-y: auto; padding-right: 4px; }

/* --- Confetti ------------------------------------------------------------- */

.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confetti-bit {
    position: absolute;
    width: 9px; height: 14px;
    border: 1.5px solid var(--shadow-color);
    animation: confetti-fall var(--dur, 1.5s) var(--ease-out) forwards;
}

/* --- Motion --------------------------------------------------------------- */

@keyframes fade      { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop       { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes slide-in  { from { opacity: 0; transform: translateX(30px) rotate(2deg); } to { opacity: 1; transform: none; } }
@keyframes slide-out { to   { opacity: 0; transform: translateX(30px) scale(0.94); } }
@keyframes shimmer   { to   { background-position: -200% 0; } }
@keyframes bob       { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-9px) rotate(3deg); } }
@keyframes marquee   { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes spin      { to   { transform: rotate(360deg); } }
@keyframes confetti-fall {
    from { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
    to   { transform: translateY(105vh) rotate(var(--spin, 540deg)); opacity: 0; }
}
@keyframes pulse-ring {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--coral) 70%, transparent); }
    70%  { box-shadow: 0 0 0 11px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.rise { animation: pop 320ms var(--ease) backwards; }
.spin { animation: spin 900ms linear infinite; }
.alarm { animation: pulse-ring 1.9s ease-out infinite; }

/* --- Responsive ----------------------------------------------------------- */

.rail-toggle { display: none; }
.scrim { display: none; }

@media (max-width: 1180px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main { grid-template-columns: minmax(0, 1fr); }
    .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split  { grid-template-columns: minmax(0, 1fr); }
    .split-list { max-height: 340px; }
}

@media (max-width: 860px) {
    body { font-size: 14.5px; }

    .rail {
        position: fixed; inset: 0 auto 0 0;
        transform: translateX(-100%);
        transition: transform 240ms var(--ease-out);
        box-shadow: var(--shadow-lg);
    }
    .rail.is-open { transform: none; }

    .rail-toggle { display: inline-flex; }

    .scrim {
        display: block; position: fixed; inset: 0; z-index: 39;
        background: color-mix(in srgb, var(--ink) 50%, transparent);
        animation: fade 160ms var(--ease-out);
    }

    .content { padding: 15px; gap: 16px; }
    .grid-2, .grid-3, .grid-4, .grid-main { grid-template-columns: minmax(0, 1fr); }
    .grid-auto, .grid-wide { grid-template-columns: minmax(0, 1fr); }
    /* The pipeline board keeps its columns but scrolls sideways, which reads
       better on a phone than six stacked stages. */
    .kanban { display: flex; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
    .kanban > .kanban-col { flex: 0 0 82vw; scroll-snap-align: start; }
    .search-trigger { min-width: 0; }
    .search-trigger span, .kbd { display: none; }
    .modal-foot { justify-content: stretch; }
    .modal-foot .btn { flex: 1; }
    .toaster { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}

@media (max-width: 520px) {
    .display { font-size: 23px; }
    .card { padding: 15px; }
    .hide-xs { display: none !important; }
}

/* Print: the invoice and payslip views. */
@media print {
    .rail, .topbar, .toaster, .no-print { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; break-inside: avoid; }
}

/* --- Reduced motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .btn:hover, .card--live:hover, .nav-item:hover, .sticker:hover { transform: none !important; }
}
