/*
  STAPI web — the desktop's WPF-UI Fluent Dark tokens (UISTYLE.md §2) as CSS variables, with the neon orange of
  the STAPI logo (StapiLogo / NeonGlyph) as accent. Every colour comes from a token below.
*/
:root {
    --app-bg: #0d0f13;
    --bg-top: #151821;
    --bg-bottom: #0a0b0e;
    --bg-glow: rgba(255, 138, 30, 0.10);
    --card: rgba(30, 33, 40, 0.72);
    --card-selected: rgba(44, 40, 36, 0.85);
    --fill-secondary: rgba(255, 255, 255, 0.08);
    --fill-default: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(14px) saturate(140%);
    --text-1: #ffffff;
    --text-2: rgba(255, 255, 255, 0.786);
    --text-3: rgba(255, 255, 255, 0.544);
    --accent: #ffb24d;
    --accent-fill: #ff8a1e;
    --glow: rgba(255, 138, 30, 0.55);
    --glow-soft: rgba(255, 138, 30, 0.22);
    --good-glow: rgba(108, 203, 95, 0.45);
    --bad-glow: rgba(255, 153, 164, 0.40);
    --good: #6ccb5f;
    --good-bg: #393d1b;
    --caution: #fce100;
    --caution-bg: #433519;
    --bad: #ff99a4;
    --bad-bg: #442726;
    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
    --mono: "Cascadia Mono", Consolas, ui-monospace, "SF Mono", Menlo, monospace;
    --tabbar-height: 60px;
    --sidebar-width: 0px;
    --row-hover: rgba(255, 255, 255, 0.035);
    --accent-line: rgba(255, 178, 77, 0.45);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(120% 60% at 50% -10%, var(--bg-glow), transparent 60%),
        linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 70%);
    background-color: var(--app-bg);
    background-attachment: fixed;
    color: var(--text-1);
    font-family: var(--font);
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ---------- frame ---------- */

/*
  One markup for every screen: below 768 px the phone layout (bottom tab bar, cards); from 768 px a side bar
  (icons only up to 1100 px, with labels above), wider pages, tables as tables.
*/
.shell {
    min-height: 100vh;
}

.page {
    max-width: 760px;
    margin: 0 auto;
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(var(--tabbar-height) + 24px + env(safe-area-inset-bottom));
}

.sidebar {
    display: none;
}

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border);
    z-index: 10;
}

.tab {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
}

.tab.active {
    color: var(--accent);
    text-shadow: 0 0 10px var(--glow);
}

.tab.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 28%;
    right: 28%;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 0 10px 1px var(--glow);
}

.icon {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}

.tab.active .icon {
    filter: drop-shadow(0 0 6px var(--glow));
}

.tab-count {
    position: absolute;
    top: 6px;
    left: calc(50% + 8px);
    min-width: 18px;
    padding: 1px 5px;
    border-radius: 9px;
    background: var(--bad);
    color: var(--app-bg);
    font-size: 10px;
    font-weight: 700;
    text-align: center;
}

.tab-dot {
    position: absolute;
    top: 8px;
    left: calc(50% + 10px);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--caution);
}

/* ---------- page skeleton ---------- */

.page-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
    min-height: 34px;
}

.title {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
}

.title.small {
    font-size: 20px;
    margin-bottom: 10px;
}

.caption {
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
}

.hint {
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    margin: 8px 0;
}

.status {
    color: var(--bad);
    margin: 0 0 8px;
}

.back {
    color: var(--accent);
    font-size: 15px;
    font-weight: 600;
}

.spacer {
    flex: 1;
}

.section {
    margin: 18px 0;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text-2);
    line-height: 1.45;
}

.text.small {
    font-size: 12px;
}

/* Markdown from agenda texts and memos */
.md {
    color: var(--text-2);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.md .mention {
    display: inline-block;
    padding: 0 5px 1px;
    margin: 0 1px;
    border: 1px solid var(--mention);
    border-radius: 4px;
    background: color-mix(in srgb, var(--mention) 18%, transparent);
    color: var(--mention);
    font-weight: 600;
    line-height: 1.35;
}

.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md blockquote, .md table { margin: 0 0 8px; }
.md ul, .md ol { padding-left: 20px; }
.md li { margin: 2px 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 12px 0 6px; color: var(--text-1); font-size: 15px; font-weight: 600; }
.md h1 { font-size: 17px; }
.md strong { color: var(--text-1); }
.md a { color: var(--accent); text-decoration: underline; }
.md code { padding: 1px 5px; border-radius: 4px; background: var(--fill-secondary); font: 12px var(--mono); }
.md pre { padding: 10px; border-radius: 6px; background: var(--fill-default); overflow-x: auto; }
.md pre code { padding: 0; background: none; }
.md blockquote { padding-left: 10px; border-left: 3px solid var(--accent); color: var(--text-3); }
.md table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 12px; }
.md th, .md td { padding: 4px 8px; border: 1px solid var(--border); text-align: left; }
.md hr { border: none; border-top: 1px solid var(--border); }
.md input[type="checkbox"] { width: auto; margin-right: 6px; }

.panel {
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
    background: var(--card);
    border: 1px solid var(--border);
}

.panel.caution {
    background: var(--caution-bg);
}

/* ---------- summary ---------- */

.summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 0 18px -8px var(--glow-soft);
}

.stat .value.good { text-shadow: 0 0 12px var(--good-glow); }
.stat .value.bad { text-shadow: 0 0 12px var(--bad-glow); }

.stat .label {
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
}

.stat .value {
    font-size: 16px;
    text-align: left;
}

h1:focus {
    outline: none;
}

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

.card {
    position: relative;
    display: block;
    margin: 0 0 6px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    animation: rise 0.35s ease-out both;
}

.card.active-position::before {
    content: "";
    position: absolute;
    left: -1px;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 3px;
    background: var(--accent);
    box-shadow: 0 0 10px 1px var(--glow);
}

.card.active-position.long::before { background: var(--good); box-shadow: 0 0 10px 1px var(--good-glow); }
.card.active-position.short::before { background: var(--bad); box-shadow: 0 0 10px 1px var(--bad-glow); }

.live-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
    animation: pulse 1.8s ease-in-out infinite;
}

.card.link:active,
.card:active {
    background: var(--fill-secondary);
}

.card.unread {
    border-left: 3px solid var(--accent);
}

.row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 22px;
}

.row.secondary {
    margin-top: 4px;
    color: var(--text-2);
    font-size: 12.5px;
}

.row.wrap {
    flex-wrap: wrap;
}

.primary-text {
    font-size: 14px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.snippet {
    margin-top: 6px;
    color: var(--text-3);
    font-size: 12px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow-wrap: anywhere;
}

.snippet.full {
    display: block;
    -webkit-line-clamp: unset;
}

.num {
    font-family: var(--mono);
    font-size: 13px;
    text-align: right;
}

.kv {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3px 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    color: var(--text-3);
    font-size: 12px;
}

.sub-list {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.trade {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.side {
    width: 18px;
    font-weight: 700;
    text-align: center;
}

/* ---------- groups, pills, badges, chips ---------- */

.group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0 8px;
    font-size: 15px;
    font-weight: 600;
}

.group-header .rule {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.pill {
    padding: 1px 8px;
    border-radius: 9px;
    background: var(--fill-secondary);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 600;
}

.pill.alert {
    background: var(--bad);
    color: var(--app-bg);
}

.badge {
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge-good { background: var(--good-bg); color: var(--good); }
.badge-caution { background: var(--caution-bg); color: var(--caution); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-accent { background: var(--fill-secondary); color: var(--accent); }
.badge-neutral { background: var(--fill-secondary); color: var(--text-2); }

.good { color: var(--good); }
.caution { color: var(--caution); }
.bad { color: var(--bad); }
.muted { color: var(--text-3); }

.position {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.brand .caption {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.chip,
.chip-select {
    padding: 4px 12px;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-2);
    font: 600 12px var(--font);
}

.chip.on {
    background: var(--fill-secondary);
    border-color: rgba(255, 178, 77, 0.45);
    color: var(--accent);
    box-shadow: 0 0 12px -2px var(--glow-soft);
}

.agent {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
}

.agent::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--agent);
}

/* ---------- agenda, inbox ---------- */

.check {
    padding: 3px 0;
    color: var(--text-2);
}

.check.done {
    color: var(--text-3);
    text-decoration: line-through;
}

.activity {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.activity .caption {
    margin-left: 8px;
}

/* ---------- chat (inbox) ---------- */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--agent) 22%, transparent);
    border: 1.5px solid var(--agent);
    box-shadow: 0 0 12px -3px var(--agent);
    color: var(--text-1);
    font-size: 15px;
    font-weight: 700;
}

.avatar.small {
    width: 30px;
    height: 30px;
    font-size: 11px;
}

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

.chat-row {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    animation: rise 0.35s ease-out both;
}

.chat-row:active {
    background: var(--fill-secondary);
}

.chat-row.unread {
    border-color: rgba(255, 178, 77, 0.35);
    box-shadow: 0 0 16px -6px var(--glow);
}

.chat-row-body {
    flex: 1;
    min-width: 0;
}

.chat-subject {
    color: var(--text-3);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-snippet {
    color: var(--text-2);
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.chat-row.unread .chat-snippet {
    color: var(--text-1);
    font-weight: 600;
}

.chat-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 -16px 8px;
    padding: 8px 16px;
    background: var(--card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border);
}

.chat-header .back {
    font-size: 26px;
    line-height: 1;
    padding-right: 4px;
}

.chat-header-text {
    min-width: 0;
}

.chat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 76px;
}

.chat-day {
    align-self: center;
    margin: 10px 0 4px;
    padding: 2px 10px;
    border-radius: 9px;
    background: var(--fill-secondary);
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
}

.bubble-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: rise 0.3s ease-out both;
}

.bubble-row.mine {
    justify-content: flex-end;
}

.bubble {
    max-width: 82%;
    padding: 8px 12px 6px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.bubble-row.theirs .bubble {
    border-bottom-left-radius: 4px;
}

.bubble-row.mine .bubble {
    border-bottom-right-radius: 4px;
    border-color: rgba(255, 178, 77, 0.35);
    background: linear-gradient(160deg, rgba(255, 178, 77, 0.22), rgba(255, 138, 30, 0.12));
    box-shadow: 0 0 18px -8px var(--glow);
}

.bubble-row.mine .md {
    color: var(--text-1);
}

.bubble-sender {
    margin-bottom: 2px;
    color: var(--agent);
    font-size: 11px;
    font-weight: 700;
}

.bubble-time {
    margin-top: 2px;
    text-align: right;
    color: var(--text-3);
    font-size: 10px;
}

.composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    z-index: 9;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 760px;
    margin: 0 auto;
    padding: 8px 12px;
    background: var(--card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border);
}

.composer textarea {
    flex: 1;
    min-height: 40px;
    max-height: 160px;
    padding: 9px 14px;
    border-radius: 20px;
    resize: none;
    line-height: 1.35;
}

.composer .send {
    flex: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: linear-gradient(180deg, var(--accent), var(--accent-fill));
    color: var(--app-bg);
    box-shadow: 0 0 16px -3px var(--glow);
}

.composer .send .icon {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.agent-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.agent-choice {
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border-radius: 20px;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
}

.agent-choice.on {
    border-color: rgba(255, 178, 77, 0.45);
    background: var(--fill-secondary);
    color: var(--text-1);
    box-shadow: 0 0 12px -2px var(--glow-soft);
}

/* ---------- collapsible groups ---------- */

button.group-header.toggle {
    width: 100%;
    padding: 4px 0;
    border: none;
    background: none;
    color: var(--text-1);
    font: 600 15px var(--font);
    text-align: left;
    justify-content: flex-start;
}

.group-header.toggle .icon {
    width: 18px;
    height: 18px;
    color: var(--text-3);
    transition: transform 0.2s ease;
}

.group-header.toggle.collapsed .icon {
    transform: rotate(-90deg);
}

.group-header .num {
    font-size: 12px;
}

/* ---------- schedule ---------- */

.slot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.slot:last-child {
    border-bottom: none;
}

.slot.current {
    margin: 0 -14px;
    padding: 6px 14px 6px 11px;
    border-left: 3px solid var(--accent);
    background: var(--card-selected);
}

.slot-name {
    width: 120px;
    flex: none;
}

.slot-agents {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* ---------- logs ---------- */

.log {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.log .level {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
}

.log-message {
    margin-top: 2px;
    color: var(--text-2);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.exception {
    margin: 6px 0 0;
    padding: 8px;
    border-radius: 6px;
    background: var(--fill-default);
    color: var(--text-3);
    font: 11px var(--mono);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

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

.form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

.field > span {
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
}

input, select, textarea {
    width: 100%;
    padding: 9px 11px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--fill-default);
    color: var(--text-1);
    font: 16px var(--font);
}

textarea {
    resize: vertical;
}

.toggle-field {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-1);
}

.toggle-field input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), 0 0 16px -2px var(--glow);
}

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font: 600 14px var(--font);
    cursor: pointer;
}

button.primary, .button.primary {
    background: linear-gradient(180deg, var(--accent), var(--accent-fill));
    border-color: var(--accent);
    color: var(--app-bg);
    box-shadow: 0 0 18px -4px var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transition: transform 0.12s ease, box-shadow 0.2s ease;
}

button.primary:active, .button.primary:active {
    transform: scale(0.97);
    box-shadow: 0 0 26px -2px var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

button.secondary {
    background: var(--fill-secondary);
    color: var(--text-1);
}

.page-header .button.primary {
    padding: 6px 12px;
    font-size: 13px;
    align-self: center;
}

button:disabled {
    opacity: 0.45;
    cursor: default;
}

/* ---------- neon logo (the desktop's StapiLogo, rendered once to logo.png) ---------- */

/* logo.png is 580x260 with the 520x200 frame inset by 30 on each side; the padding carries the glow. */
.neon-logo {
    display: block;
    width: 100%;
    max-width: 380px;
    height: auto;
    aspect-ratio: 580 / 260;
    object-fit: contain;
    flex: none;
    margin: 0 auto;
}

.neon-logo.compact {
    width: 103px;
    max-width: 103px;
    margin: -6px;
}

.neon-logo.power-on {
    animation: rise 0.8s ease-out both;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 14px;
}

.brand .caption {
    letter-spacing: 0.04em;
}

/* ---------- login, boot, loader, errors ---------- */

.login {
    max-width: 380px;
    margin: 0 auto;
    padding: calc(56px + env(safe-area-inset-top)) 16px 32px;
}

.login .neon-logo {
    margin-bottom: 14px;
}

.login .hint {
    text-align: center;
    margin-bottom: 18px;
}

.login input {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.login button.primary {
    margin-top: 6px;
    padding: 12px 14px;
}

.boot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
    padding: 26vh 32px 0;
}

.boot-bar {
    position: relative;
    width: min(260px, 70vw);
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 178, 77, 0.18);
    overflow: hidden;
}

.boot-bar::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 40%;
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 0 10px 1px var(--glow);
    animation: sweep 1.3s ease-in-out infinite;
}

.loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    filter: drop-shadow(0 0 4px var(--glow));
    animation: spin 0.8s linear infinite;
    align-self: center;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes sweep {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(260%); }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.8); }
}


/* ---------- overview: tiles, panels, lines ---------- */

.kpis {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.stat.link {
    transition: border-color 0.15s ease, background 0.15s ease;
}

.stat.link:hover {
    border-color: var(--accent-line);
}

.value.accent {
    color: var(--accent);
    text-shadow: 0 0 12px var(--glow);
}

.dash {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: start;
}

.dash > .panel {
    margin: 0;
    min-width: 0;
}

.dash > .panel.wide {
    grid-column: 1 / -1;
}

.panel {
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.panel-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.panel-head .section-title {
    margin: 0;
}

a.section-title:hover {
    color: var(--accent);
}

.line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-top: 1px solid var(--border);
    min-width: 0;
}

.panel-head + .line,
.stations + .line,
.status + .line {
    border-top: none;
}

a.line:hover .line-title {
    color: var(--accent);
}

.line-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.line-title {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-sub {
    color: var(--text-3);
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-sub.tags,
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    white-space: normal;
}

.live-dot.accent {
    color: var(--accent);
}

.progress {
    display: block;
    height: 4px;
    margin: 3px 0 1px;
    border-radius: 2px;
    background: var(--fill-secondary);
    overflow: hidden;
}

.progress > span {
    display: block;
    height: 100%;
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 0 8px var(--glow);
}

.progress.caution > span { background: var(--caution); box-shadow: none; }
.progress.bad > span { background: var(--bad); box-shadow: none; }

.stations {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.station {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--fill-default);
    min-width: 0;
}

.station .num {
    text-align: left;
    font-size: 15px;
    color: var(--accent);
}

.station.empty .num {
    color: var(--text-3);
}

.station .caption {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.service-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.service {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 10px;
    background: var(--fill-default);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
}

.dot.good { box-shadow: 0 0 6px var(--good-glow); }
.dot.bad { box-shadow: 0 0 6px var(--bad-glow); }

.uptime {
    display: inline-flex;
    gap: 1px;
    height: 14px;
    vertical-align: middle;
}

.uptime > span {
    width: 4px;
    border-radius: 1px;
    background: var(--fill-secondary);
}

.uptime > .up { background: var(--good); opacity: 0.75; }
.uptime > .warn { background: var(--caution); opacity: 0.8; }
.uptime > .part { background: var(--caution); }
.uptime > .down { background: var(--bad); }

/* ---------- tables (cards on the phone) ---------- */

table.grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 8px;
}

table.grid th {
    padding: 6px 10px;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

table.grid td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.grid .r {
    text-align: right;
}

table.grid tbody tr {
    position: relative;
    transition: background 0.12s ease;
}

table.grid tr.clickable {
    cursor: pointer;
}

table.grid tbody tr:hover {
    background: var(--row-hover);
}

table.grid tr.detail td {
    padding: 8px 14px 12px;
    background: var(--fill-default);
}

table.grid tr.active-position td:first-child {
    box-shadow: inset 3px 0 0 var(--accent);
}

table.grid tr.active-position.long td:first-child { box-shadow: inset 3px 0 0 var(--good); }
table.grid tr.active-position.short td:first-child { box-shadow: inset 3px 0 0 var(--bad); }

table.grid.fixed {
    table-layout: fixed;
}

table.grid.fixed td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

table.grid.fixed tr.detail td {
    white-space: normal;
}

table.grid.compact td {
    padding: 6px 8px;
}

table.grid.compact th {
    padding: 4px 8px;
}

.row-link::after {
    content: "";
    position: absolute;
    inset: 0;
}

.row-link:hover {
    color: var(--accent);
}

.link-text {
    color: var(--accent);
}

.c-wide .snippet {
    margin: 0;
    -webkit-line-clamp: 1;
}

@media (max-width: 767.98px) {
    table.grid,
    table.grid tbody {
        display: block;
    }

    table.grid thead {
        display: none;
    }

    table.grid tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px 10px;
        margin: 0 0 6px;
        padding: 10px 14px;
        border-radius: 8px;
        border: 1px solid var(--border);
        background: var(--card);
        backdrop-filter: var(--glass-blur);
        -webkit-backdrop-filter: var(--glass-blur);
    }

    .panel table.grid tbody tr {
        background: var(--fill-default);
        backdrop-filter: none;
    }

    table.grid td,
    table.grid.fixed td {
        display: block;
        padding: 0;
        border: none;
        font-size: 12px;
        white-space: normal;
        overflow: visible;
    }

    table.grid td:empty,
    table.grid .hide-sm {
        display: none;
    }

    table.grid td.c-main {
        flex: 1 1 100%;
        font-size: 14px;
    }

    table.grid td.c-main + td.c-end,
    table.grid td.c-end {
        margin-left: auto;
    }

    table.grid td.c-wide {
        flex: 1 1 100%;
    }

    table.grid td[data-label]:not(:empty)::before {
        content: attr(data-label) " ";
        color: var(--text-3);
        font-family: var(--font);
        font-size: 11px;
        font-weight: 600;
    }

    table.grid tr.detail {
        margin-top: -10px;
        border-top: none;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }

    table.grid tr.detail td {
        flex: 1 1 100%;
        background: none;
        padding: 0;
    }

    table.grid tr.active-position td:first-child,
    table.grid tr.active-position.long td:first-child,
    table.grid tr.active-position.short td:first-child {
        box-shadow: none;
    }

    table.grid tr.active-position { border-left: 3px solid var(--accent); }
    table.grid tr.active-position.long { border-left-color: var(--good); }
    table.grid tr.active-position.short { border-left-color: var(--bad); }
}

/* ---------- schedule: day bar, blocks, days ---------- */

.chips-label {
    align-self: center;
    margin-right: 4px;
}

.daybar {
    position: relative;
    height: 30px;
    margin: 6px 0 2px;
    border-radius: 6px;
    background: var(--fill-default);
    overflow: hidden;
}

.daybar-seg {
    position: absolute;
    top: 3px;
    bottom: 3px;
    display: flex;
    align-items: center;
    padding: 0 6px;
    border-radius: 4px;
    border: 1px solid var(--accent-line);
    background: linear-gradient(180deg, rgba(255, 178, 77, 0.20), rgba(255, 138, 30, 0.10));
    color: var(--text-1);
    font: 600 11px var(--mono);
    overflow: hidden;
    white-space: nowrap;
}

.daybar-seg + .daybar-seg {
    margin-left: 2px;
}

.daybar-seg.past {
    border-color: var(--border);
    background: var(--fill-secondary);
    color: var(--text-3);
}

.daybar-seg.current {
    border-color: var(--accent);
    background: linear-gradient(180deg, rgba(255, 178, 77, 0.45), rgba(255, 138, 30, 0.25));
    box-shadow: 0 0 14px -2px var(--glow);
}

.daybar-seg.empty {
    border-style: dashed;
    border-color: var(--border);
    background: none;
    color: var(--text-3);
}

.daybar-seg.paused {
    border-color: var(--caution);
    background: var(--caution-bg);
    color: var(--caution);
}

.daybar-now {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: var(--text-1);
    box-shadow: 0 0 8px 1px var(--glow);
}

.daybar-scale {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: var(--text-3);
    font: 10px var(--mono);
}

.blocks {
    display: flex;
    flex-direction: column;
}

.block {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
}

.block.current {
    border-radius: 6px;
    border-top-color: transparent;
    background: var(--card-selected);
    box-shadow: inset 3px 0 0 var(--accent);
}

.block.current + .block {
    border-top-color: transparent;
}

.block.past .block-time {
    opacity: 0.55;
}

.block-time {
    display: flex;
    flex-direction: column;
    width: 112px;
    flex: none;
}

.block-time .num {
    text-align: left;
    font-weight: 600;
}

.block-agents {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    min-width: 0;
}

.agent-run {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.day-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.day-grid .panel {
    margin: 0;
}

.day .section-title {
    font-size: 13px;
}

.day .slot-name {
    width: 40px;
    text-align: left;
}

.day .slot-agents {
    gap: 4px 10px;
}

/* ---------- more menu, search, small buttons ---------- */

.menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.menu-link {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    font-size: 15px;
    font-weight: 600;
}

.menu-link > .icon:first-child {
    grid-row: 1 / 3;
    color: var(--accent);
}

.menu-link > .caption {
    grid-column: 2;
    grid-row: 2;
}

.menu-link > .icon:last-child {
    grid-column: 3;
    grid-row: 1 / 3;
    width: 18px;
    color: var(--text-3);
}

.menu-link:active {
    background: var(--fill-secondary);
}

button.wide {
    width: 100%;
}

button.ghost {
    background: none;
    border: none;
    color: var(--text-3);
    padding: 6px;
    gap: 8px;
    font-size: 12px;
}

button.ghost:hover {
    color: var(--accent);
}

input.search {
    flex: 1;
    min-width: 180px;
    max-width: 420px;
    padding: 5px 12px;
    border-radius: 11px;
    font-size: 13px;
}

/* ---------- wide screens: side bar, wider pages ---------- */

@media (min-width: 768px) {
    :root {
        --sidebar-width: 72px;
    }

    .tabbar,
    .brand {
        display: none;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 20;
        display: flex;
        flex-direction: column;
        width: var(--sidebar-width);
        padding: 14px 10px;
        background: rgba(18, 20, 26, 0.78);
        backdrop-filter: var(--glass-blur);
        -webkit-backdrop-filter: var(--glass-blur);
        border-right: 1px solid var(--border);
        overflow-y: auto;
    }

    .sidebar-brand {
        display: flex;
        justify-content: center;
        margin: 0 0 14px;
        overflow: hidden;
    }

    .sidebar-brand .neon-logo.compact {
        width: 56px;
        max-width: 56px;
        margin: -2px;
    }

    .side-nav {
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex: 1;
    }

    .side-group {
        height: 1px;
        margin: 10px 8px;
        background: var(--border);
        overflow: hidden;
        color: transparent;
    }

    .side-group:first-child {
        display: none;
    }

    .side-link {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        height: 40px;
        padding: 0 12px;
        border-radius: 8px;
        color: var(--text-3);
        font-size: 13.5px;
        font-weight: 600;
        transition: background 0.12s ease, color 0.12s ease;
    }

    .side-link > span:not(.side-count):not(.side-dot) {
        display: none;
    }

    .side-link:hover {
        background: var(--fill-default);
        color: var(--text-1);
    }

    .side-link.active {
        background: var(--fill-secondary);
        color: var(--accent);
        text-shadow: 0 0 10px var(--glow);
    }

    .side-link.active::before {
        content: "";
        position: absolute;
        left: -10px;
        top: 9px;
        bottom: 9px;
        width: 3px;
        border-radius: 0 3px 3px 0;
        background: var(--accent);
        box-shadow: 0 0 10px 1px var(--glow);
    }

    .side-link.active .icon {
        filter: drop-shadow(0 0 6px var(--glow));
    }

    .side-count {
        position: absolute;
        top: 3px;
        right: 4px;
        min-width: 18px;
        padding: 1px 5px;
        border-radius: 9px;
        background: var(--bad);
        color: var(--app-bg);
        font-size: 10px;
        font-weight: 700;
        text-align: center;
    }

    .side-dot {
        position: absolute;
        top: 8px;
        right: 12px;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--caution);
    }

    .sidebar-foot {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding-top: 10px;
        border-top: 1px solid var(--border);
    }

    .sidebar-foot .connection {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .sidebar-foot .label {
        display: none;
    }

    .page {
        max-width: none;
        margin: 0 0 0 var(--sidebar-width);
        padding: 26px 28px 40px;
    }

    .page > * {
        max-width: 1480px;
        margin-left: auto;
        margin-right: auto;
    }

    .page-header {
        margin-bottom: 18px;
    }

    .kpis {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px;
    }

    .stat .value {
        font-size: 18px;
    }

    .summary {
        max-width: 640px;
        margin-left: 0;
    }

    .form,
    .agent-picker,
    .login {
        max-width: 760px;
    }

    .page > .form,
    .page > .hint,
    .page > .title.small {
        margin-left: 0;
    }

    .chat-list,
    .chat,
    .page > .card,
    .page > .panel:not(.wide) {
        max-width: 960px;
    }

    .page > .section,
    .page > .md,
    .page > .text {
        max-width: 960px;
    }

    .chat-row:hover,
    .card.link:hover {
        border-color: var(--accent-line);
        background: var(--card-selected);
    }

    .chat-header {
        margin: -26px -28px 12px;
        padding: 12px 28px;
        max-width: none;
    }

    .composer {
        left: var(--sidebar-width);
        bottom: 0;
        max-width: none;
        padding: 10px max(16px, calc((100vw - var(--sidebar-width) - 960px) / 2));
    }

    .chat {
        padding-bottom: 90px;
    }

    .day-grid {
        grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    }

    .stations {
        grid-template-columns: repeat(8, 1fr);
    }

    .dash .stations {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1100px) {
    :root {
        --sidebar-width: 220px;
    }

    .sidebar {
        padding: 16px 12px;
    }

    .sidebar-brand {
        justify-content: flex-start;
        margin: 0 0 10px 2px;
    }

    .sidebar-brand .neon-logo.compact {
        width: 120px;
        max-width: 120px;
    }

    .side-group {
        height: auto;
        margin: 14px 12px 4px;
        background: none;
        color: var(--text-3);
        font-size: 10.5px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .side-group:first-child {
        display: block;
        margin-top: 4px;
    }

    .side-link {
        justify-content: flex-start;
    }

    .side-link > span:not(.side-count):not(.side-dot) {
        display: inline;
    }

    .side-link.active::before {
        left: -12px;
    }

    .side-count {
        position: static;
        margin-left: auto;
    }

    .side-dot {
        position: static;
        margin-left: auto;
    }

    .sidebar-foot {
        flex-direction: row;
        justify-content: space-between;
    }

    .sidebar-foot .label {
        display: inline;
    }

    .page {
        padding: 28px 36px 48px;
    }

    .chat-header {
        margin: -28px -36px 12px;
        padding: 12px 36px;
    }

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

    .block-time {
        width: 140px;
    }
}

@media (min-width: 1500px) {
    .dash {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .kpis {
        grid-template-columns: repeat(7, 1fr);
    }
}

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

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--bad-bg);
    color: var(--bad);
    z-index: 100;
}

#blazor-error-ui .reload {
    margin-left: 12px;
    color: var(--accent);
    font-weight: 600;
}
