/* ============================================================
   VMS Admin — "Midnight Aurora"
   Same identity as the public site (serif headings, luminous
   green, rounded surfaces) but denser and built for data work.
   ============================================================ */

:root {
    --green:     #35a668;
    --green-lit: #5fe39b;
    --grad:      linear-gradient(135deg, #35a668 0%, #5fe39b 100%);

    --ff:      'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --ff-serif:'Instrument Serif', Georgia, serif;
    --mono:    'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --r-sm: 10px;
    --r:    14px;
    --r-lg: 20px;
    --pill: 999px;

    --side-w: 262px;
    --top-h:  66px;
    --ease: cubic-bezier(.22, .68, .32, 1);
}

/* ---- dark (default) ---- */
:root, [data-theme="dark"] {
    --bg:      #080b0d;
    --panel:   #0f1417;
    --panel-2: #151b1f;
    --panel-3: #1c2429;
    --side:    #0b0f11;
    --line:    rgba(255,255,255,.08);
    --line-2:  rgba(255,255,255,.05);
    --text:    #e9f0ec;
    --muted:   #93a29b;
    --faint:   #67766e;

    --accent:      #5fe39b;
    --accent-soft: rgba(95,227,155,.12);
    --accent-line: rgba(95,227,155,.28);
    --on-accent:   #04140b;

    --ok:   #4ecf87;
    --warn: #e0a437;
    --err:  #e25e46;
    --info: #589ce0;

    --shadow-sm: 0 2px 10px rgba(0,0,0,.35);
    --shadow:    0 10px 30px rgba(0,0,0,.45);
    --shadow-lg: 0 30px 70px rgba(0,0,0,.6);
    --lift:      inset 0 1px 0 rgba(255,255,255,.06);
    --glow:      0 0 0 1px rgba(95,227,155,.22), 0 16px 40px -14px rgba(53,166,104,.45);
    --aurora-a: rgba(53,166,104,.16);
    --aurora-b: rgba(38,128,145,.10);
    color-scheme: dark;
}

/* ---- light ---- */
[data-theme="light"] {
    --bg:      #f6f7f4;
    --panel:   #ffffff;
    --panel-2: #fbfcfa;
    --panel-3: #f1f4f0;
    --side:    #0b0f11;
    --line:    rgba(13,20,17,.10);
    --line-2:  rgba(13,20,17,.06);
    --text:    #0d1411;
    --muted:   #58675f;
    --faint:   #8b988f;

    --accent:      #248a55;
    --accent-soft: rgba(53,166,104,.12);
    --accent-line: rgba(53,166,104,.28);
    --on-accent:   #ffffff;

    --ok:   #1f9254;
    --warn: #b8801a;
    --err:  #c8452f;
    --info: #2c74b8;

    --shadow-sm: 0 2px 8px rgba(13,20,17,.05);
    --shadow:    0 10px 28px rgba(13,20,17,.09);
    --shadow-lg: 0 30px 70px rgba(13,20,17,.18);
    --lift:      inset 0 1px 0 rgba(255,255,255,.9);
    --glow:      0 0 0 1px rgba(53,166,104,.25), 0 16px 36px -16px rgba(53,166,104,.4);
    --aurora-a: rgba(53,166,104,.13);
    --aurora-b: rgba(38,128,145,.08);
    color-scheme: light;
}

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

body {
    margin: 0;
    font-family: var(--ff);
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    position: relative;
}
body::before {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(55vw 50vh at 78% -10%, var(--aurora-a), transparent 62%),
        radial-gradient(45vw 45vh at 8% 104%, var(--aurora-b), transparent 60%);
}

img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, h5 { font-weight: 600; letter-spacing: -.02em; margin: 0; line-height: 1.25; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

/* ---------- shell ----------------------------------------- */
.a-shell { display: flex; min-height: 100vh; }

.a-side {
    width: var(--side-w); flex: none;
    background: var(--side); color: #cfdad4;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; z-index: 40;
    border-right: 1px solid rgba(255,255,255,.06);
}
.a-side__brand {
    display: flex; align-items: center; gap: .7rem;
    height: var(--top-h); padding: 0 1.2rem; flex: none;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.a-side__brand img { height: 26px; width: auto; }
.a-side__brand span {
    font-size: .58rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
    color: var(--green-lit);
    background: rgba(95,227,155,.12); border: 1px solid rgba(95,227,155,.24);
    border-radius: var(--pill); padding: .18rem .5rem;
}
/* min-height:0 lets the nav actually shrink and scroll instead of
   overflowing behind the footer on short viewports. */
.a-side__nav { flex: 1; min-height: 0; overflow-y: auto; padding: 1rem .7rem; scrollbar-width: thin; }
.a-side__nav::-webkit-scrollbar { width: 6px; }
.a-side__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 999px; }
.a-side__label {
    font-size: .58rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
    color: #5d6f66; padding: 1.15rem .75rem .45rem;
}
.a-side__nav a {
    position: relative;
    display: flex; align-items: center; gap: .75rem;
    padding: .62rem .8rem; margin-bottom: 2px;
    border-radius: var(--pill);
    font-size: .88rem; font-weight: 500; color: #a8b7b0;
    transition: background .22s var(--ease), color .22s var(--ease), transform .22s var(--ease);
}
.a-side__nav a i { font-size: 1rem; width: 18px; text-align: center; flex: none; opacity: .8; }
.a-side__nav a:hover { background: rgba(255,255,255,.06); color: #fff; transform: translateX(2px); }
.a-side__nav a.is-active {
    background: var(--grad); color: var(--on-accent); font-weight: 700;
    box-shadow: 0 8px 22px -8px rgba(53,166,104,.7);
}
.a-side__nav a.is-active i { opacity: 1; }
.a-side__nav a .pill {
    margin-left: auto; font-size: .64rem; font-weight: 700;
    background: rgba(95,227,155,.16); color: var(--green-lit);
    border-radius: var(--pill); padding: .08rem .45rem;
}
.a-side__nav a.is-active .pill { background: rgba(0,0,0,.22); color: inherit; }

.a-side__foot { flex: none; padding: .8rem .7rem 1rem; border-top: 1px solid rgba(255,255,255,.06); }
.a-side__user {
    display: flex; align-items: center; gap: .65rem;
    padding: .6rem .7rem; border-radius: var(--r);
    background: rgba(255,255,255,.05); transition: background .2s ease;
}
.a-side__user:hover { background: rgba(255,255,255,.1); }
.a-side__user span { min-width: 0; flex: 1; }
.a-side__user b { display: block; font-size: .84rem; font-weight: 600; color: #eef3ef; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-side__user small { display: block; font-size: .6rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: #5d6f66; }
.a-side__user i { color: #5d6f66; flex: none; }
.a-side__user .avatar { background: rgba(255,255,255,.12); color: #cfdad4; }

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

.a-top {
    position: sticky; top: 0; z-index: 30;
    height: var(--top-h); flex: none;
    display: flex; align-items: center; gap: .6rem;
    padding: 0 clamp(1rem, .5rem + 1vw, 1.75rem);
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: blur(18px) saturate(160%);
    border-bottom: 1px solid var(--line);
}
.a-top h1 { font-family: var(--ff-serif); font-weight: 400; font-size: 1.45rem; letter-spacing: -.01em; }
.a-top__spacer { margin-left: auto; }
.a-body { padding: clamp(1.1rem, .6rem + 1.4vw, 2rem); flex: 1; }
.a-burger { display: none; }

@media (max-width: 992px) {
    .a-side {
        position: fixed; inset: 0 auto 0 0; width: 280px;
        transform: translateX(-100%);
        transition: transform .3s var(--ease);
        box-shadow: var(--shadow-lg);
    }
    .a-side.is-open { transform: none; }
    .a-burger { display: inline-grid; }
    .a-scrim {
        position: fixed; inset: 0; z-index: 35;
        background: rgba(4, 8, 6, .6); backdrop-filter: blur(3px);
        opacity: 0; pointer-events: none; transition: opacity .3s ease;
    }
    .a-scrim.is-open { opacity: 1; pointer-events: auto; }
    .a-top h1 { font-size: 1.2rem; }
}

/* ---------- buttons --------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    padding: .55rem 1rem;
    font-family: var(--ff); font-size: .85rem; font-weight: 600;
    color: var(--text); background: var(--panel-2);
    border: 1px solid var(--line); border-radius: var(--pill);
    cursor: pointer; white-space: nowrap;
    transition: background .2s ease, border-color .2s ease, color .2s ease, transform .18s var(--ease), box-shadow .2s ease;
}
.btn:hover { border-color: var(--accent-line); color: var(--accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-primary {
    background: var(--grad); border-color: transparent; color: var(--on-accent);
    box-shadow: 0 8px 22px -10px rgba(53,166,104,.75);
}
.btn-primary:hover { color: var(--on-accent); box-shadow: 0 14px 30px -10px rgba(53,166,104,.9); }
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 32%, transparent); background: transparent; }
.btn-danger:hover { background: var(--err); border-color: var(--err); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-3); color: var(--text); border-color: transparent; }
.btn-sm { padding: .34rem .7rem; font-size: .78rem; }
.btn-icon { padding: 0; width: 34px; height: 34px; border-radius: 50%; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.a-side__foot .btn { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); color: #cfdad4; }
.a-side__foot .btn:hover { background: rgba(255,255,255,.13); color: #fff; }

/* ---------- panels ---------------------------------------- */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--lift), var(--shadow-sm);
}
.panel__head {
    display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--line);
}
.panel__head h2 { font-size: .98rem; font-weight: 600; }
.panel__head .spacer { margin-left: auto; }
.panel__body { padding: 1.25rem; }
.panel__foot { padding: .9rem 1.25rem; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
@media (max-width: 760px) {
    .panel__head > .input[type="search"] { max-width: none !important; width: 100%; }
    .panel__head .spacer { display: none; }
}

.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-bottom: 1.5rem; }
.page-head h1 { font-family: var(--ff-serif); font-weight: 400; font-size: clamp(1.7rem, 1.3rem + 1.2vw, 2.3rem); letter-spacing: -.01em; }
.page-head p { margin: .25rem 0 0; color: var(--muted); font-size: .88rem; }
.page-head .spacer { margin-left: auto; }

/* ---------- stat tiles ------------------------------------ */
.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tile {
    position: relative; overflow: hidden;
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--r-lg); padding: 1.25rem 1.35rem;
    box-shadow: var(--lift), var(--shadow-sm);
    transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s ease;
}
.tile:hover { transform: translateY(-3px); border-color: var(--accent-line); box-shadow: var(--glow); }
.tile__label { display: flex; align-items: center; gap: .45rem; font-size: .72rem; font-weight: 600; letter-spacing: .06em; color: var(--faint); margin-bottom: .6rem; }
.tile__value { font-family: var(--ff-serif); font-weight: 400; font-size: 2rem; line-height: 1.1; letter-spacing: -.01em; }
.tile__sub { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.tile__icon {
    position: absolute; right: 1rem; top: 1rem;
    width: 36px; height: 36px; display: grid; place-items: center;
    border-radius: var(--r-sm); font-size: .95rem;
    background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line);
}
.tile.is-ok  .tile__value { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tile.is-err .tile__value { color: var(--err); }

/* A tile reporting several currencies carries a much longer string than a
   single figure, so it steps down in size and each currency gets its own
   line instead of overflowing the card. */
.tile__value.is-multi { font-size: 1.35rem; line-height: 1.28; word-spacing: .02em; }
.tile__value.is-multi .muted { font-size: 2rem; }

/* ---------- tables ---------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.data th {
    text-align: left; white-space: nowrap;
    font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--faint);
    padding: .8rem 1rem; border-bottom: 1px solid var(--line);
    background: var(--panel-2); position: sticky; top: 0; z-index: 1;
}
table.data td { padding: .85rem 1rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .15s ease; }
table.data tbody tr:hover { background: var(--panel-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions form { display: inline; }
table.data .strong { font-weight: 600; }
table.data .sub { display: block; font-size: .77rem; color: var(--faint); }
table.data tfoot td { padding: .9rem 1rem; border-top: 1px solid var(--line); font-weight: 600; }
.empty-row { text-align: center; color: var(--faint); padding: 3rem 1rem !important; }

tr.is-unread td { background: var(--accent-soft); }
tr.is-unread td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

@media (max-width: 760px) {
    table.data.stack thead { display: none; }
    table.data.stack, table.data.stack tbody, table.data.stack tr, table.data.stack td { display: block; width: 100%; }
    table.data.stack tr {
        border: 1px solid var(--line); border-radius: var(--r);
        margin-bottom: .8rem; padding: .5rem .2rem; background: var(--panel-2);
    }
    table.data.stack td { border: 0; padding: .4rem 1rem; display: flex; gap: 1rem; align-items: center; }
    table.data.stack td::before {
        content: attr(data-label);
        font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
        color: var(--faint); flex: none; width: 92px;
    }
    table.data.stack td.actions { justify-content: flex-end; border-top: 1px solid var(--line-2); margin-top: .4rem; padding-top: .6rem; }
    table.data.stack td.actions::before { content: ""; width: 0; }
    table.data.stack td.num { justify-content: flex-start; }
    table.data.stack tfoot { display: block; }
}

/* ---------- badges ---------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: .38rem;
    font-size: .7rem; font-weight: 600; white-space: nowrap;
    padding: .26rem .7rem; border-radius: var(--pill);
    background: var(--panel-3); color: var(--muted); border: 1px solid var(--line);
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.no-dot::before { display: none; }
.badge.b-ok    { color: var(--ok);   background: color-mix(in srgb, var(--ok) 12%, transparent);   border-color: color-mix(in srgb, var(--ok) 26%, transparent); }
.badge.b-warn  { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.badge.b-err   { color: var(--err);  background: color-mix(in srgb, var(--err) 12%, transparent);  border-color: color-mix(in srgb, var(--err) 26%, transparent); }
.badge.b-info  { color: var(--info); background: color-mix(in srgb, var(--info) 12%, transparent); border-color: color-mix(in srgb, var(--info) 26%, transparent); }
.badge.b-brand { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }

/* ---------- forms ----------------------------------------- */
.field { margin-bottom: 1rem; }
label, .label { display: block; margin-bottom: .38rem; font-size: .76rem; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.input, input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=month], input[type=search], input[type=url], input[type=tel], select, textarea {
    width: 100%;
    padding: .6rem .85rem;
    font-family: var(--ff); font-size: .88rem; color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--line); border-radius: var(--r);
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
input[type=file] {
    width: 100%; padding: .55rem .7rem; font-size: .83rem;
    background: var(--panel-2); border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); cursor: pointer;
}
textarea { min-height: 104px; resize: vertical; line-height: 1.55; }
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2393a29b' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M4 6.5l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .75rem center; background-size: 15px;
    padding-right: 2.2rem;
}
.input:focus, input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft); background: var(--panel);
}
.hint { font-size: .78rem; color: var(--faint); margin-top: .3rem; }
.req { color: var(--err); }

.grid { display: grid; gap: 0 1rem; }
.g-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 720px) { .g-2, .g-3, .g-4 { grid-template-columns: 1fr; } }

.toolbar { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.toolbar .input, .toolbar select { width: auto; min-width: 156px; }
.toolbar .grow { flex: 1; min-width: 190px; }
@media (max-width: 620px) {
    .toolbar { display: grid; grid-template-columns: 1fr 1fr; }
    .toolbar .input, .toolbar select, .toolbar .btn { width: 100%; min-width: 0; }
    .toolbar .grow { grid-column: 1 / -1; }
}

label.check {
    display: flex; align-items: center; gap: .55rem;
    font-size: .87rem; font-weight: 500; color: var(--text); margin: 0;
    padding: .6rem .85rem; border: 1px solid var(--line); border-radius: var(--r);
    background: var(--panel-2); cursor: pointer; transition: border-color .2s ease;
}
label.check:hover { border-color: var(--accent-line); }
label.check input { width: auto; margin: 0; accent-color: var(--green); }

/* ---------- tabs & segmented ------------------------------ */
.tabs { display: inline-flex; gap: 3px; padding: 4px; background: var(--panel-3); border-radius: var(--pill); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tabs button {
    padding: .4rem .95rem; background: none; border: 0; cursor: pointer; border-radius: var(--pill);
    font-family: var(--ff); font-size: .8rem; font-weight: 600; color: var(--muted);
    transition: background .2s ease, color .2s ease;
}
.tabs button:hover { color: var(--text); }
.tabs button.is-active { background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm); }
.tab-pane { display: none; }
.tab-pane.is-active { display: block; }

.segmented { display: inline-flex; padding: 4px; gap: 3px; background: var(--panel-3); border-radius: var(--pill); flex-wrap: wrap; }
.segmented a {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .36rem .85rem; border-radius: var(--pill);
    font-size: .82rem; font-weight: 500; color: var(--muted);
    transition: background .2s ease, color .2s ease;
}
.segmented a:hover { color: var(--text); }
.segmented a.is-active { background: var(--panel); color: var(--accent); font-weight: 600; box-shadow: var(--shadow-sm); }
.segmented a b { font-size: .64rem; font-weight: 700; background: var(--line); color: var(--muted); border-radius: var(--pill); padding: 0 .38rem; }
.segmented a.is-active b { background: var(--grad); color: var(--on-accent); }

/* ---------- modal ----------------------------------------- */
.modal {
    position: fixed; inset: 0; z-index: 60;
    display: none; align-items: flex-start; justify-content: center;
    padding: clamp(.5rem, 3vh, 3.5rem) 1rem;
    background: rgba(4, 8, 6, .65); backdrop-filter: blur(6px);
    overflow-y: auto;
}
.modal.is-open { display: flex; }
.modal__box {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--r-lg); width: min(100%, 660px);
    box-shadow: var(--shadow-lg);
    animation: modal-in .28s var(--ease);
}
.modal__box.is-wide { width: min(100%, 920px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(-14px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .modal__box { animation: none; } }
.modal__head {
    display: flex; align-items: center; gap: .8rem;
    padding: 1.1rem 1.35rem; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; background: var(--panel); border-radius: var(--r-lg) var(--r-lg) 0 0; z-index: 2;
}
.modal__head h3 { font-family: var(--ff-serif); font-weight: 400; font-size: 1.3rem; }
.modal__head button { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--faint); font-size: 1.3rem; line-height: 1; padding: .2rem; }
.modal__head button:hover { color: var(--text); }
.modal__body { padding: 1.35rem; }
.modal__foot {
    display: flex; gap: .6rem; justify-content: flex-end;
    padding: 1rem 1.35rem; border-top: 1px solid var(--line);
    background: var(--panel-2); border-radius: 0 0 var(--r-lg) var(--r-lg); position: sticky; bottom: 0;
}
@media (max-width: 560px) { .modal__foot { flex-direction: column-reverse; } .modal__foot .btn { width: 100%; } }

/* ---------- flash ----------------------------------------- */
.flashes { display: grid; gap: .6rem; margin-bottom: 1.35rem; }
.flash {
    display: flex; align-items: flex-start; gap: .7rem;
    padding: .85rem 1.1rem; font-size: .88rem;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
    box-shadow: var(--lift), var(--shadow-sm);
}
.flash i { margin-top: .1rem; font-size: 1rem; }
.flash.f-success { border-color: var(--accent-line); } .flash.f-success i { color: var(--ok); }
.flash.f-danger  { border-color: color-mix(in srgb, var(--err) 32%, transparent); }  .flash.f-danger i  { color: var(--err); }
.flash.f-warning { border-color: color-mix(in srgb, var(--warn) 32%, transparent); } .flash.f-warning i { color: var(--warn); }
.flash.f-info    { border-color: color-mix(in srgb, var(--info) 32%, transparent); } .flash.f-info i    { color: var(--info); }
.flash button { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--faint); font-size: 1.1rem; line-height: 1; }

/* ---------- notifications --------------------------------- */
.notif { position: relative; }
.notif__dot {
    position: absolute; top: -3px; right: -3px;
    min-width: 18px; height: 18px; padding: 0 5px;
    display: grid; place-items: center; border-radius: var(--pill);
    background: var(--grad); color: var(--on-accent);
    font-size: .6rem; font-weight: 800;
    border: 2px solid var(--bg);
}
.notif__panel {
    position: absolute; right: 0; top: calc(100% + .6rem);
    width: min(94vw, 360px);
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg); overflow: hidden;
    opacity: 0; transform: translateY(-8px) scale(.98); pointer-events: none;
    transition: opacity .22s var(--ease), transform .22s var(--ease); z-index: 50;
}
.notif.is-open .notif__panel { opacity: 1; transform: none; pointer-events: auto; }
.notif__head {
    display: flex; align-items: center; gap: .5rem;
    padding: .85rem 1.1rem; border-bottom: 1px solid var(--line);
    background: var(--panel-2); font-size: .9rem; font-weight: 600;
}
.notif__item { display: flex; align-items: center; gap: .8rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--line-2); transition: background .15s ease; }
.notif__item:last-child { border-bottom: 0; }
.notif__item:hover { background: var(--panel-2); }
.notif__icon {
    width: 36px; height: 36px; flex: none; display: grid; place-items: center;
    border-radius: var(--r-sm); font-size: .92rem;
    background: var(--panel-3); color: var(--muted); border: 1px solid var(--line);
}
.notif__icon.is-brand { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.notif__icon.is-info  { background: color-mix(in srgb, var(--info) 13%, transparent); color: var(--info); border-color: color-mix(in srgb, var(--info) 26%, transparent); }
.notif__icon.is-warn  { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.notif__icon.is-err   { background: color-mix(in srgb, var(--err) 13%, transparent);  color: var(--err);  border-color: color-mix(in srgb, var(--err) 26%, transparent); }
.notif__body { min-width: 0; flex: 1; }
.notif__body b { display: block; font-size: .86rem; font-weight: 600; }
.notif__body small { display: block; font-size: .77rem; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif__count { font-size: .7rem; font-weight: 700; color: var(--faint); background: var(--panel-3); border-radius: var(--pill); padding: .1rem .5rem; flex: none; }
.notif__empty { display: flex; align-items: center; gap: .7rem; padding: 1.75rem 1.1rem; color: var(--faint); font-size: .87rem; }
.notif__empty i { color: var(--ok); font-size: 1.15rem; }

/* ---------- avatars, logos, media ------------------------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; background: var(--panel-3); }
.avatar.lg { width: 60px; height: 60px; }
.thumb { width: 50px; height: 38px; border-radius: var(--r-sm); object-fit: cover; background: var(--panel-3); flex: none; }
.cell { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.cell > div { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; }

.logo-cell {
    width: 58px; height: 40px; display: grid; place-items: center; flex: none; overflow: hidden;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.logo-cell img { max-width: 86%; max-height: 76%; width: auto; object-fit: contain; }
:root:not([data-theme="light"]) .logo-cell img { filter: brightness(1.9) grayscale(.4); }
.logo-cell.is-empty { font-size: .7rem; font-weight: 700; color: var(--faint); }

.logo-picker { display: flex; gap: .9rem; align-items: flex-start; }
.logo-picker__preview {
    width: 118px; height: 80px; flex: none; display: grid; place-items: center; overflow: hidden;
    background: var(--panel-2); border: 1px dashed var(--line); border-radius: var(--r);
    font-size: .74rem; color: var(--faint);
}
.logo-picker__preview img { max-width: 86%; max-height: 78%; width: auto; object-fit: contain; }
@media (max-width: 560px) { .logo-picker { flex-direction: column; } .logo-picker__preview { width: 100%; } }

.imgs { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .7rem; }
.imgs figure { position: relative; margin: 0; width: 92px; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--panel-2); }
.imgs img { width: 100%; height: 68px; object-fit: cover; }
.imgs label {
    display: flex; align-items: center; justify-content: center; gap: .3rem;
    padding: .28rem; margin: 0; font-size: .66rem; font-weight: 500; letter-spacing: 0; text-transform: none;
    background: var(--panel); border-top: 1px solid var(--line); cursor: pointer; color: var(--muted);
}
.imgs input { width: auto; margin: 0; accent-color: var(--green); }

/* ---------- dropzone -------------------------------------- */
.dropzone {
    display: grid; place-items: center; gap: .25rem;
    padding: 1.9rem 1rem; text-align: center; cursor: pointer;
    border: 1.5px dashed var(--line); border-radius: var(--r-lg);
    background: var(--panel-2); color: var(--muted);
    transition: border-color .2s ease, background .2s ease, transform .2s var(--ease);
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-files { padding-block: 1.2rem; }
.dropzone i { font-size: 1.7rem; color: var(--accent); }
.dropzone b { font-size: .9rem; font-weight: 600; color: var(--text); }
.dropzone span { font-size: .78rem; color: var(--faint); }
.dropzone__previews { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .7rem; }
.dropzone__previews figure { position: relative; margin: 0; width: 92px; height: 68px; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--panel-2); }
.dropzone__previews img { width: 100%; height: 100%; object-fit: cover; }
.dropzone__remove {
    position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
    display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer;
    background: rgba(4,8,6,.75); color: #fff; font-size: .72rem; line-height: 1;
}
.dropzone__remove:hover { background: var(--err); }

/* ---------- login ----------------------------------------- */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
    background:
        radial-gradient(60vw 55vh at 15% -10%, var(--aurora-a), transparent 62%),
        radial-gradient(50vw 50vh at 90% 105%, var(--aurora-b), transparent 60%),
        var(--bg);
}
.auth-card {
    width: min(100%, 425px);
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--r-lg); box-shadow: var(--lift), var(--shadow-lg);
    padding: clamp(1.75rem, 1rem + 2.5vw, 2.6rem);
}
.auth-card img { height: 32px; width: auto; margin-bottom: 1.75rem; }
.auth-card h1 { font-family: var(--ff-serif); font-weight: 400; font-size: 1.9rem; margin-bottom: .35rem; }
.auth-card p.sub { color: var(--muted); font-size: .89rem; margin: 0 0 1.75rem; }
.auth-foot { text-align: center; margin-top: 1.25rem; font-size: .85rem; color: var(--muted); }
.auth-foot a { color: var(--accent); font-weight: 600; }

/* ---------- misc ------------------------------------------ */
.mono { font-family: var(--mono); font-size: .76rem; letter-spacing: .04em; color: var(--faint); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 1rem; }
.stack-1 { display: grid; gap: .5rem; }
.row { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.split-cols { display: grid; grid-template-columns: 1.35fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .split-cols { grid-template-columns: 1fr; } }

.list-rows { display: grid; }
.list-rows > * { display: flex; align-items: center; gap: .8rem; padding: .75rem 0; border-bottom: 1px solid var(--line-2); font-size: .88rem; }
.list-rows > *:last-child { border-bottom: 0; }
.list-rows .spacer { margin-left: auto; }
@media (max-width: 620px) {
    .list-rows > * { flex-wrap: wrap; row-gap: .2rem; }
    .list-rows .spacer { flex-basis: 100%; margin: 0; height: 0; }
}

.bar-track { height: 7px; background: var(--panel-3); border-radius: var(--pill); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--pill); background: var(--grad); transition: width .6s var(--ease); }

.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.money.neg { color: var(--err); }
.money.pos { color: var(--ok); }

.hint-bar {
    display: flex; align-items: center; gap: .6rem;
    padding: .8rem 1.1rem; font-size: .85rem; color: var(--muted);
    background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--r);
}
.hint-bar i { color: var(--accent); }

.stage-select { width: auto; min-width: 140px; padding: .32rem 1.9rem .32rem .8rem; font-size: .79rem; border-radius: var(--pill); }
.balance-grid { display: grid; gap: 1.1rem 1.9rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ============================================================
   AI + SEO assistant
   ============================================================ */

.ai-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: .45rem;
    padding: .6rem .7rem; margin: 0 0 1rem;
    background: linear-gradient(135deg, var(--accent-soft), transparent 70%);
    border: 1px solid var(--accent-line); border-radius: var(--r);
}
.ai-bar__label {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: var(--accent); margin-right: .25rem;
}
.ai-bar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 .2rem; }

.btn-ai {
    display: inline-flex; align-items: center; gap: .38rem;
    font: 600 .78rem/1 var(--ff); color: var(--text);
    background: var(--panel-2); border: 1px solid var(--line);
    border-radius: var(--pill); padding: .44rem .8rem; cursor: pointer;
    transition: background .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.btn-ai:hover:not(:disabled) { background: var(--panel-3); border-color: var(--accent-line); transform: translateY(-1px); }
.btn-ai:disabled { opacity: .55; cursor: default; }
.btn-ai i { color: var(--accent); font-size: .9rem; }

/* Busy state: the icon is swapped for a spinner so the row never reflows. */
.btn-ai.is-busy { position: relative; color: transparent; }
.btn-ai.is-busy i { visibility: hidden; }
.btn-ai.is-busy::after {
    content: ''; position: absolute; inset: 0; margin: auto;
    width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid var(--accent-line); border-top-color: var(--accent);
    animation: ai-spin .6s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* ---- score panel ---- */
.ai-score {
    border: 1px solid var(--line); border-radius: var(--r);
    background: var(--panel-2); padding: .9rem 1rem; margin-top: 1rem;
}
.ai-score__top { display: flex; align-items: center; gap: .9rem; }
.ai-score__ring { position: relative; width: 64px; height: 64px; flex: none; }
.ai-score__ring svg { width: 64px; height: 64px; transform: rotate(-90deg); }
.ai-score__ring circle { fill: none; stroke-width: 6; stroke-linecap: round; }
.ai-score__ring .bg  { stroke: var(--line); }
.ai-score__ring .val { stroke: var(--accent); transition: stroke-dashoffset .5s var(--ease), stroke .3s; }
.ai-score__num {
    position: absolute; inset: 0; display: grid; place-items: center;
    font: 700 1.05rem/1 var(--ff); color: var(--text);
}
.ai-score__meta { min-width: 0; }
.ai-score__meta b { display: block; font-size: .92rem; }
.ai-score__meta span { font-size: .78rem; color: var(--muted); }

.ai-score[data-grade="poor"] .ai-score__ring .val { stroke: var(--err); }
.ai-score[data-grade="fair"] .ai-score__ring .val { stroke: var(--warn); }

.ai-checks { list-style: none; margin: .85rem 0 0; padding: 0; display: grid; gap: .3rem; }
.ai-check { display: flex; align-items: flex-start; gap: .5rem; font-size: .8rem; line-height: 1.45; }
.ai-check i { font-size: .82rem; margin-top: .17rem; flex: none; }
.ai-check.is-pass i { color: var(--ok); }
.ai-check.is-warn i { color: var(--warn); }
.ai-check.is-fail i { color: var(--err); }
.ai-check b  { font-weight: 600; color: var(--text); }
.ai-check em { display: block; font-style: normal; font-size: .75rem; color: var(--muted); }
.ai-check.is-pass b { color: var(--muted); font-weight: 500; }

.ai-notes {
    margin-top: .85rem; padding: .7rem .85rem; display: none;
    background: var(--panel-3); border-radius: var(--r-sm); border: 1px solid var(--line-2);
}
.ai-notes.is-shown { display: block; }
.ai-notes h4 { margin: 0 0 .35rem; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ai-notes ul { margin: 0; padding-left: 1.05rem; font-size: .8rem; color: var(--text); display: grid; gap: .22rem; }

.ai-kw { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .8rem; }
.ai-kw label { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.ai-kw input { flex: 1 1 160px; min-width: 0; }
.ai-kw__list { flex-basis: 100%; font-size: .74rem; color: var(--faint); font-family: var(--mono); }

/* ---- toasts ---- */
.ai-toast {
    position: fixed; z-index: 9000; left: 50%; bottom: 1.4rem;
    transform: translate(-50%, 14px); opacity: 0;
    max-width: min(92vw, 460px);
    padding: .7rem 1rem; border-radius: var(--pill);
    background: var(--panel-3); color: var(--text);
    border: 1px solid var(--line); box-shadow: var(--shadow);
    font-size: .84rem; text-align: center;
    transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.ai-toast.is-in { opacity: 1; transform: translate(-50%, 0); }
.ai-toast.is-ok    { border-color: var(--accent-line); }
.ai-toast.is-error { border-color: color-mix(in srgb, var(--err) 45%, transparent); }

/* ---- console ---- */
.ai-chat { display: flex; flex-direction: column; gap: .8rem; min-height: 46vh; }
.ai-chat__log { flex: 1; display: flex; flex-direction: column; gap: .8rem; overflow-y: auto; padding-right: .3rem; }
.ai-msg { max-width: 88%; padding: .7rem .95rem; border-radius: var(--r); font-size: .87rem; line-height: 1.6; white-space: pre-wrap; }
.ai-msg.is-user { align-self: flex-end; background: var(--accent-soft); border: 1px solid var(--accent-line); }
.ai-msg.is-bot  { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); }
.ai-msg.is-bot.is-typing::after {
    content: '▍'; margin-left: .1rem; color: var(--accent);
    animation: ai-caret 1s steps(2) infinite;
}
@keyframes ai-caret { 50% { opacity: 0; } }
.ai-chat__form { display: flex; gap: .5rem; align-items: flex-end; }
.ai-chat__form textarea { flex: 1; resize: none; min-height: 46px; max-height: 180px; }

.ai-suggest { display: flex; flex-wrap: wrap; gap: .4rem; }
.ai-suggest button {
    font: 500 .78rem/1 var(--ff); color: var(--muted); cursor: pointer;
    background: var(--panel-2); border: 1px solid var(--line);
    border-radius: var(--pill); padding: .4rem .75rem;
}
.ai-suggest button:hover { color: var(--text); border-color: var(--accent-line); }

@media (max-width: 640px) {
    .ai-bar { padding: .55rem; }
    .ai-bar .sep { display: none; }
    .btn-ai { padding: .4rem .7rem; font-size: .74rem; }
    .ai-msg { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .btn-ai, .ai-toast, .ai-score__ring .val { transition: none; }
    .btn-ai.is-busy::after, .ai-msg.is-bot.is-typing::after { animation: none; }
}

/* ---- definition rows + link lists (settings, detail panels) ---- */
.kv { margin: 0; display: grid; gap: .5rem; }
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.kv dt { font-size: .82rem; color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; font-family: var(--mono); font-size: .85rem; }

.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.link-list a {
    display: flex; align-items: center; gap: .5rem;
    font-size: .84rem; color: var(--text); text-decoration: none;
    padding: .38rem .5rem; border-radius: var(--r-sm);
}
.link-list a:hover { background: var(--panel-3); }
.link-list i { color: var(--accent); }

.idea-card {
    padding: .8rem .95rem; margin-bottom: .6rem;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r);
}
.idea-card b { display: block; font-size: .92rem; margin-bottom: .25rem; }
.idea-card p { margin: 0 0 .5rem; font-size: .82rem; color: var(--muted); line-height: 1.55; }
.idea-card code {
    font-size: .74rem; color: var(--accent);
    background: var(--accent-soft); border-radius: var(--pill); padding: .16rem .55rem;
}

.ai-empty {
    margin: auto; padding: 2rem 1rem; text-align: center; color: var(--faint);
    display: grid; gap: .6rem; justify-items: center;
}
.ai-empty i { font-size: 1.9rem; color: var(--accent); opacity: .55; }
.ai-empty p { margin: 0; font-size: .86rem; max-width: 30ch; line-height: 1.55; }

/* ---- role editor: capability tick-boxes ---- */
.cap-group { margin-bottom: 1.1rem; }
.cap-group__head {
    font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: var(--accent); margin-bottom: .5rem;
}
.cap-grid { display: grid; gap: .4rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.cap {
    display: flex; align-items: flex-start; gap: .55rem;
    padding: .55rem .7rem; border-radius: var(--r-sm);
    background: var(--panel-2); border: 1px solid var(--line);
    cursor: pointer; transition: border-color .2s var(--ease), background .2s var(--ease);
}
.cap:hover { border-color: var(--accent-line); }
.cap input { margin-top: .2rem; flex: none; }
.cap input:disabled { cursor: not-allowed; }
.cap:has(input:disabled) { opacity: .6; cursor: not-allowed; }
.cap:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-line); }
.cap b  { display: block; font-size: .84rem; font-weight: 600; }
.cap em { display: block; font-style: normal; font-size: .74rem; color: var(--muted); line-height: 1.4; }

/* ---- chips (capability lists, tags) ---- */
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
    display: inline-flex; align-items: center;
    font-size: .74rem; line-height: 1;
    padding: .34rem .6rem;
    border-radius: var(--pill);
    background: var(--panel-3);
    border: 1px solid var(--line);
    color: var(--muted);
    white-space: nowrap;
}

/* ---- AI provider cards in settings ---- */
.prov {
    padding: .9rem 1rem; margin-bottom: .7rem;
    border: 1px solid var(--line); border-radius: var(--r);
    background: var(--panel-2);
}
.prov.is-active { border-color: var(--accent-line); background: var(--accent-soft); }
.prov .field { margin-bottom: .6rem; }

/* ---- AI image generation panel ---- */
.ai-imagegen {
    margin-top: 1rem; padding: .85rem 1rem;
    border: 1px solid var(--line); border-radius: var(--r);
    background: var(--panel-2);
}
.ai-imagegen__row { display: flex; gap: .5rem; flex-wrap: wrap; }
.ai-imagegen__row .input { flex: 1 1 200px; min-width: 0; }
.ai-imagegen__row select.input { flex: 0 0 auto; width: auto; }
.ai-gen { margin: 0; }
.ai-gen img {
    width: 100%; aspect-ratio: 4/3; object-fit: cover;
    border-radius: var(--r-sm); display: block; border: 1px solid var(--line);
}
.ai-gen label { display: flex; align-items: center; gap: .35rem; font-size: .76rem; margin-top: .3rem; color: var(--muted); }

/* ---------- client message thread -------------------------- */
.thread {
    display: grid;
    gap: .9rem;
    max-height: 420px;
    overflow-y: auto;
    padding-right: .3rem;
    margin-bottom: 1.1rem;
}
.thread__msg { max-width: min(78%, 560px); }
.thread__msg.is-team { justify-self: end; }
.thread__who {
    display: flex; gap: .5rem; align-items: baseline;
    margin-bottom: .3rem;
    font-size: .72rem; font-weight: 600; color: var(--muted);
}
.thread__msg.is-team .thread__who { justify-content: flex-end; }
.thread__who span { font-weight: 400; opacity: .75; }
.thread__body {
    padding: .7rem .95rem;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--panel-2);
    font-size: .9rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
.thread__msg.is-team .thread__body { background: var(--accent-soft); border-color: var(--accent-line); }
.thread__form { display: flex; gap: .7rem; align-items: flex-end; }
.thread__form textarea { flex: 1; }

/* ---------- contact message reader ------------------------- */
.msg-open {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.msg-open:hover .strong { color: var(--accent); }
.msg-open__more {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-top: .35rem;
    font-size: .74rem;
    font-weight: 600;
    color: var(--accent);
}
.msg-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .8rem 1.4rem;
    padding-bottom: 1.1rem;
    margin-bottom: 1.1rem;
    border-bottom: 1px solid var(--line);
}
.msg-meta dt {
    font-size: .66rem; font-weight: 700; letter-spacing: .13em;
    text-transform: uppercase; color: var(--faint); margin-bottom: .15rem;
}
.msg-meta dd { margin: 0; font-size: .9rem; overflow-wrap: anywhere; }
.msg-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: .95rem;
    line-height: 1.7;
    max-height: 52vh;
    overflow-y: auto;
    padding: 1rem 1.1rem;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--panel-2);
}

/* ---------- dashboard: currency switch + chart ---------------
   Series colours are a validated categorical pair (income / expenses):
   dark  #2aa96b / #5286c9  — ΔE 17.4 deutan, 20.1 normal, contrast >= 3:1
   light #238a58 / #3f6fae  — same checks against the light surface.
   They are chart-only tokens and never leak into UI chrome. */
:root, [data-theme="dark"] { --s-in: #2aa96b; --s-out: #5286c9; }
[data-theme="light"]       { --s-in: #238a58; --s-out: #3f6fae; }

.cur-switch {
    display: inline-flex;
    gap: .25rem;
    padding: .25rem;
    margin-bottom: 1.1rem;
    border-radius: var(--pill);
    border: 1px solid var(--line);
    background: var(--panel);
}
.cur-switch__btn {
    padding: .42rem 1rem;
    border: 0;
    border-radius: var(--pill);
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .22s var(--ease), color .22s var(--ease);
}
.cur-switch__btn:hover { color: var(--text); }
.cur-switch__btn.is-on { background: var(--grad); color: var(--on-accent); }

.chart__legend {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    margin-bottom: 1rem;
    font-size: .8rem;
    color: var(--muted);
}
.chart__legend .spacer { flex: 1; }
.chart__key { display: inline-flex; align-items: center; gap: .45rem; }
.chart__swatch {
    width: 10px; height: 10px;
    border-radius: 3px;
    flex: none;
    display: inline-block;
}
.chart__swatch.is-in  { background: var(--s-in); }
.chart__swatch.is-out { background: var(--s-out); }
.chart__cur { font-size: .72rem; color: var(--faint); }

.chart__plot {
    display: flex;
    align-items: flex-end;
    gap: clamp(.4rem, 2vw, 1.2rem);
    height: 190px;
}
.chart__group {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    /* 2px of surface between the two fills, per the mark spec. */
    gap: 2px;
}
.chart__bar {
    position: relative;
    width: 46%;
    max-width: 26px;
    /* Rounded only at the data end; the baseline stays square so the bars
       sit on the axis rather than floating. */
    border-radius: 4px 4px 0 0;
    transition: filter .18s var(--ease);
}
.chart__bar.is-in  { background: var(--s-in); }
.chart__bar.is-out { background: var(--s-out); }
.chart__bar:hover, .chart__bar:focus-visible { filter: brightness(1.15); outline: none; }

.chart__tip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: .4rem .6rem;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--panel-3);
    color: var(--text);
    font-size: .74rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s var(--ease), transform .18s var(--ease);
    z-index: 5;
}
.chart__bar:hover .chart__tip,
.chart__bar:focus-visible .chart__tip { opacity: 1; transform: translateX(-50%) translateY(0); }

.chart__x {
    display: flex;
    gap: clamp(.4rem, 2vw, 1.2rem);
    margin-top: .55rem;
}
.chart__x span {
    flex: 1;
    text-align: center;
    font-family: var(--mono);
    font-size: .62rem;
    color: var(--faint);
}

/* The "all currencies" view: a small table, because six months of two
   currencies on one axis would be a lie. */
.chart__all { width: 100%; display: grid; gap: .5rem; align-content: center; }
.chart__all-row {
    display: grid;
    grid-template-columns: minmax(70px, .8fr) 1fr 1fr minmax(90px, .9fr);
    gap: .8rem;
    align-items: center;
    padding: .7rem .9rem;
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    background: var(--panel-2);
    font-size: .84rem;
}
.chart__all-row b { font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.chart__all-in, .chart__all-out { display: inline-flex; align-items: center; gap: .45rem; }
.chart__all-net { text-align: right; font-weight: 700; }
.chart__empty { margin: 2rem 0; text-align: center; color: var(--muted); font-size: .88rem; }

@media (max-width: 640px) {
    .chart__all-row { grid-template-columns: 1fr 1fr; gap: .4rem .8rem; }
    .chart__all-row b { grid-column: 1 / -1; }
    .chart__all-net { text-align: left; }
}

/* ---------- client inbox ----------------------------------- */
.inbox { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 1rem; align-items: start; }
.inbox__list { position: sticky; top: calc(var(--top-h) + 1rem); }
.inbox__scroll { max-height: 62vh; overflow-y: auto; }
.inbox__row {
    display: flex; align-items: center; gap: .7rem;
    padding: .75rem .9rem;
    border-bottom: 1px solid var(--line-2);
    transition: background .2s var(--ease);
}
.inbox__row:hover { background: var(--panel-2); }
.inbox__row.is-on { background: var(--accent-soft); }
.inbox__av {
    width: 34px; height: 34px; flex: none;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--panel-3); color: var(--muted);
    font-size: .82rem; font-weight: 700;
    overflow: hidden;
}
.inbox__av img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.inbox__body { min-width: 0; flex: 1; }
.inbox__body b { display: block; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox__body small { display: block; font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox__meta { display: flex; align-items: center; gap: .4rem; flex: none; }
.inbox__meta time { font-size: .68rem; color: var(--faint); }
.inbox__dot {
    min-width: 18px; padding: 0 .3rem;
    border-radius: var(--pill);
    background: var(--accent); color: var(--on-accent);
    font-size: .66rem; line-height: 18px; text-align: center;
}
/* Overlapping initials, the way every shared inbox shows participants. */
.inbox__who { display: flex; padding-left: 6px; }
.inbox__chip {
    width: 26px; height: 26px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--panel-3);
    border: 1px solid var(--line);
    font-size: .7rem; font-weight: 700;
    margin-left: -6px;
}
.thread__file {
    display: block; margin-top: .4rem;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    overflow: hidden; background: var(--panel-3);
}
.thread__file img { width: 100%; max-height: 200px; object-fit: cover; }
.thread__file span { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem; font-size: .8rem; }
.thread__file em { margin-left: auto; font-style: normal; color: var(--faint); font-size: .72rem; }
@media (max-width: 900px) {
    .inbox { grid-template-columns: 1fr; }
    .inbox__list { position: static; }
}

/* ---------- admin language picker -------------------------- */
.a-lang { position: relative; }
.a-lang__menu {
    position: absolute; right: 0; top: calc(100% + .4rem);
    min-width: 168px;
    padding: .35rem;
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow-lg);
    opacity: 0; visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .2s var(--ease), transform .2s var(--ease), visibility .2s;
    z-index: 60;
}
.a-lang:hover .a-lang__menu,
.a-lang:focus-within .a-lang__menu { opacity: 1; visibility: visible; transform: none; }
.a-lang__menu a {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .5rem .7rem; border-radius: var(--r-sm);
    font-size: .86rem; color: var(--muted);
}
.a-lang__menu a:hover { background: var(--panel-2); color: var(--text); }
.a-lang__menu a.is-active { color: var(--accent); font-weight: 600; }
.a-lang__menu a span { font-size: .68rem; letter-spacing: .1em; color: var(--faint); }

/* ---------- Task board ------------------------------------------
   Three columns of draggable cards. The layout is a grid rather than flex so
   the columns stay equal whatever is in them, and each column scrolls on its
   own — one long backlog must not push the other two off the screen. */

.tboard {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    align-items: start;
}

.tcol {
    display: flex;
    flex-direction: column;
    min-height: 220px;
    max-height: calc(100vh - 220px);
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel);
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
/* The column the pointer is over during a drag. */
.tcol.is-drop {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, var(--panel));
}
.tcol__head {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .75rem .9rem;
    border-bottom: 1px solid var(--line);
}
.tcol__head h2 {
    margin: 0;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--muted);
}
.tcol__count {
    margin-left: auto;
    min-width: 22px;
    padding: .1rem .45rem;
    border-radius: 999px;
    background: var(--panel-2);
    color: var(--muted);
    font-size: .72rem;
    font-weight: 600;
    text-align: center;
}
.tcol__list {
    display: flex;
    flex-direction: column;
    gap: .55rem;
    padding: .6rem;
    overflow-y: auto;
    /* A column with nothing in it still has to be droppable, or the only way
       to empty a column would be to move every card somewhere else first. */
    min-height: 90px;
}
.tcol__empty {
    margin: 0;
    padding: 0 .9rem 1rem;
    color: var(--faint);
    font-size: .82rem;
}

/* ---- cards ---- */
.tcard {
    position: relative;
    padding: .7rem .8rem .55rem;
    border: 1px solid var(--line);
    border-left: 3px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--panel-2);
    cursor: grab;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease),
                opacity .15s var(--ease), transform .15s var(--ease);
}
.tcard:hover { box-shadow: var(--shadow-lg); }
.tcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tcard:active { cursor: grabbing; }
/* Half-visible while it is being carried, so the gap it will land in reads. */
.tcard.is-dragging { opacity: .45; }
.tcard.is-saving { opacity: .6; }
/* A move the server refused. The card has already snapped back; this says why
   something moved on its own. */
.tcard.is-error {
    border-color: var(--err);
    animation: tcard-shake .4s var(--ease);
}
@keyframes tcard-shake {
    0%, 100% { transform: none; }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}
@media (prefers-reduced-motion: reduce) {
    .tcard.is-error { animation: none; }
}

/* Priority is the left edge — legible at a glance without a badge competing
   with the title for space. */
.tcard.p-high   { border-left-color: var(--err); }
.tcard.p-normal { border-left-color: var(--accent); }
.tcard.p-low    { border-left-color: var(--faint); }

.tcard__title {
    margin: 0 0 .4rem;
    font-size: .9rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
}
.tcard__meta {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem .7rem;
    font-size: .74rem;
    color: var(--muted);
}
.tcard__meta .is-late { color: var(--err); font-weight: 600; }
.tcard__who {
    padding: .05rem .4rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
    font-weight: 600;
}
.tcard.is-late { border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }

/* The row of actions. Hidden until the card is hovered or focused on a mouse,
   because it is the least important thing on the card — but always visible
   where there is no hover, since there it is the only way to move anything. */
.tcard__acts {
    display: flex;
    align-items: center;
    gap: .1rem;
    margin-top: .45rem;
    opacity: 0;
    transition: opacity .15s var(--ease);
}
.tcard:hover .tcard__acts,
.tcard:focus-within .tcard__acts { opacity: 1; }
@media (hover: none) {
    .tcard__acts { opacity: 1; }
}
.tcard__move { display: inline; }
.tcard__act {
    width: 26px; height: 26px;
    display: grid; place-items: center;
    border: 0; border-radius: var(--r-sm);
    background: none;
    color: var(--muted);
    font-size: .8rem;
    cursor: pointer;
}
.tcard__act:hover { background: var(--panel); color: var(--text); }
.tcard__act--danger:hover { color: var(--err); }

/* ---- narrow ---- */
@media (max-width: 900px) {
    /* Three columns of 100px are three columns of nothing. Stacked, each one
       keeps a readable width and the arrow buttons carry the moves — which is
       the mechanism on a touch screen anyway, where HTML5 drag never fires. */
    .tboard { grid-template-columns: 1fr; }
    .tcol { max-height: none; }
    .tcol__list { max-height: 60vh; }
}
