:root {
    --bg: #f7f8fa;
    --panel: #ffffff;
    --ink: #17202a;
    --muted: #687382;
    --line: #d9dee7;
    --primary: #146c5a;
    --primary-dark: #0f5244;
    --success: #137047;
    --success-dark: #0f5a39;
    --info: #2563eb;
    --info-dark: #1d4ed8;
    --accent: #b66d16;
    --danger: #a33a3a;
}

[hidden] {
    display: none !important;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.stock-symbol-link {
    font-weight: 800;
    white-space: nowrap;
}

.price-stack {
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
}

.price-change {
    color: var(--ink);
    font-weight: 800;
    white-space: nowrap;
}

.price-change--up {
    color: #137047;
}

.price-change--down {
    color: var(--danger);
}

.price-change--flat {
    color: #000000;
}

.trade-result {
    display: inline-grid;
    gap: 2px;
    color: #000000;
    font-weight: 900;
    line-height: 1.15;
    white-space: nowrap;
}

.trade-result small {
    color: inherit;
    font-size: 12px;
    font-weight: 800;
}

.trade-result--gain {
    color: #137047;
}

.trade-result--loss {
    color: var(--danger);
}

.trade-result--even {
    color: #000000;
}

.datetime-stack {
    display: inline-grid;
    gap: 2px;
}

.datetime-stack__date {
    color: var(--ink);
    font-weight: 800;
}

.datetime-stack__time {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.estimate-detail {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.35;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 64px;
    padding: 0 28px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    color: var(--ink);
    font-weight: 800;
    font-size: 18px;
}

.build-number {
    margin-left: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    vertical-align: middle;
}

.mobile-menu-toggle {
    display: none;
}

.nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.nav-link:hover,
.nav-link:focus,
.nav-submenu a:hover,
.nav-submenu a:focus {
    background: #eef4f1;
    color: var(--primary-dark);
    text-decoration: none;
}

.nav-link.is-active {
    background: #eef4f1;
    color: var(--primary-dark);
}

.nav-item--group > .nav-link::after {
    content: "";
    width: 6px;
    height: 6px;
    margin: -3px 1px 0 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
}

.nav-submenu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 20;
    display: grid;
    gap: 2px;
    min-width: 218px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 14px 34px rgb(23 32 42 / 14%);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
}

.nav-submenu--wide {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    min-width: 400px;
}

.nav-item--group:hover .nav-submenu,
.nav-item--group:focus-within .nav-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-submenu a {
    display: flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 9px;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 700;
}

.nav-submenu a.is-active {
    background: #eef4f1;
    color: var(--primary-dark);
}

.quick-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 28px;
    border-bottom: 1px solid var(--line);
    background: #fbfcfd;
}

.quick-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
}

.quick-nav a:hover,
.quick-nav a:focus,
.quick-nav a.is-active {
    border-color: #bfd1ca;
    background: #eef4f1;
    color: var(--primary-dark);
    text-decoration: none;
}

.logout-form {
    margin-left: auto;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 56px;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.command-hero,
.v2-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    gap: 24px;
    margin-bottom: 22px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 10px 28px rgb(23 32 42 / 7%);
}

.command-hero h1,
.v2-hero h1 {
    margin-bottom: 10px;
    font-size: 34px;
}

.command-hero p,
.v2-hero p {
    max-width: 780px;
    color: var(--muted);
    font-size: 16px;
}

.eyebrow {
    display: block;
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.command-actions,
.v2-actions {
    display: grid;
    align-content: start;
    gap: 12px;
}

.command-actions .inline-form,
.v2-actions .inline-form {
    justify-content: flex-end;
}

.command-actions .button-row,
.v2-actions .button-row {
    justify-content: flex-end;
    margin-bottom: 0;
}

.command-flow,
.v2-flow {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.command-flow article,
.v2-flow article {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.command-flow span,
.v2-flow span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-bottom: 12px;
    border-radius: 999px;
    background: #e8f1f7;
    color: #24546f;
    font-weight: 900;
}

.command-flow strong,
.v2-flow strong {
    display: block;
    margin-bottom: 4px;
    font-size: 17px;
}

.command-flow p,
.v2-flow p {
    margin: 0;
    color: var(--muted);
}

h1,
h2 {
    margin: 0 0 8px;
    line-height: 1.15;
}

h1 {
    font-size: 30px;
}

h2 {
    font-size: 20px;
}

h3 {
    margin: 0 0 8px;
    line-height: 1.2;
}

p {
    margin: 0 0 12px;
}

section {
    margin-bottom: 22px;
}

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

.danger-text {
    color: var(--danger);
}

.auth-panel {
    width: min(430px, 100%);
    margin: 12vh auto;
    padding: 28px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.auth-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.auth-header h1 {
    margin-bottom: 0;
}

.auth-header a {
    padding-top: 6px;
    font-weight: 800;
    white-space: nowrap;
}

.auth-divider {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    margin: 22px 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    height: 1px;
    background: var(--line);
}

.stack {
    display: grid;
    gap: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.compact-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 0;
    border: 0;
}

.span-2 {
    grid-column: span 2;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 11px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

textarea {
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--ink);
    font-weight: 800;
    cursor: pointer;
}

.button.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.button.primary:hover {
    background: var(--primary-dark);
}

.button.success {
    border-color: var(--success);
    background: var(--success);
    color: #fff;
}

.button.success:hover {
    background: var(--success-dark);
}

.button.info {
    border-color: var(--info);
    background: var(--info);
    color: #fff;
}

.button.info:hover {
    background: var(--info-dark);
}

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

.button.ghost {
    background: transparent;
}

.button.small {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
}

.icon-button {
    width: 34px;
    min-width: 34px;
    padding: 6px;
}

.icon-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.backup-action-stack {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    min-width: 260px;
}

.backup-action-stack .button.success {
    border-color: var(--success);
    background: var(--success);
    color: #fff;
}

.backup-action-stack .button.info {
    border-color: var(--info);
    background: var(--info);
    color: #fff;
}

.backup-action-stack .button.danger {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
}

.backup-restore-details summary {
    list-style: none;
}

.backup-restore-details summary::-webkit-details-marker {
    display: none;
}

.backup-restore-form {
    display: grid;
    gap: 9px;
    width: min(280px, 72vw);
    margin-top: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 24px rgb(19 24 38 / 10%);
}

.backup-restore-form label {
    font-size: 13px;
}

.backup-restore-form .button {
    width: 100%;
}

.mutation-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
}

.mutation-actions .button {
    flex: 0 0 auto;
}

.mutation-action-status {
    color: var(--muted);
    font-size: 0.85rem;
}

.mutation-row-complete {
    opacity: 0.45;
    transition: opacity 160ms ease;
}

.alert-resolution-note {
    max-width: 320px;
    margin: 6px 0 0;
    font-size: 0.82rem;
    line-height: 1.35;
}

.alert-resolution-status {
    margin: 6px 0 0;
    font-size: 0.82rem;
}

.alert-row-resolved {
    background: #f6fbf8;
}

.stacked-form,
.button-row {
    display: flex;
    gap: 10px;
}

.stacked-form {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 14px;
}

.button-row {
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

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

.metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 8px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 18px;
}

.metric strong {
    font-size: 28px;
}

.metric strong.metric-value--compact {
    font-size: 22px;
    line-height: 1.15;
}

.metric .agent-identity {
    font-size: 15px;
    line-height: 1.2;
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.split > .stack {
    min-width: 0;
}

.split > article,
section.panel,
section > table,
.details {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.split > article {
    padding: 18px;
    min-width: 0;
}

section.panel {
    padding: 18px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.agent-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.agent-identity {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: inherit;
    font-weight: 800;
    vertical-align: middle;
}

.agent-identity:hover {
    text-decoration: none;
}

.agent-identity--link .agent-identity__name {
    color: var(--primary);
}

.agent-identity--link:hover .agent-identity__name {
    text-decoration: underline;
}

.agent-identity--large {
    gap: 18px;
}

.agent-identity__name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.agent-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 8px;
    background: var(--agent-avatar-bg, var(--primary));
    color: var(--agent-avatar-fg, #fff);
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0;
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 24%);
}

.agent-avatar--compact {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    font-size: 12px;
}

.agent-avatar--large {
    width: 100px;
    height: 100px;
    flex-basis: 100px;
    border-radius: 16px;
    font-size: 32px;
}

.check .agent-identity {
    font-weight: 700;
}

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

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
}

tr:last-child td {
    border-bottom: 0;
}

.actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.agent-request-actions {
    align-items: center;
    flex-wrap: nowrap;
    justify-content: flex-start;
    min-width: 310px;
}

.agent-request-actions .inline-form {
    margin: 0;
}

.agent-request-actions .button {
    white-space: nowrap;
}

.agent-request-action-status {
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.agent-request-detail-row td {
    background: #fbfcfd;
}

.agent-request-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.agent-request-detail-grid .details {
    background: var(--panel);
}

.inline-control {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
}

.inline-control input {
    width: 86px;
}

.chart-controls {
    display: grid;
    gap: 14px;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.chart-panel {
    min-width: 0;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

.chart-panel canvas {
    display: block;
    width: 100%;
    min-height: 220px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.bracket-visual {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.bracket-visual .bracket-round h3 {
    margin: 0 0 10px;
    font-size: 15px;
}

.bracket-match {
    display: grid;
    gap: 4px;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f7f8fa;
}

.bracket-match span {
    color: var(--muted);
    font-size: 13px;
}

.badge,
.value-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 4px 10px;
    background: #eef4f1;
    color: var(--primary-dark);
    font-weight: 800;
}

.value-pill {
    background: #fff5e8;
    color: var(--accent);
    font-size: 20px;
}

.details {
    margin: 0;
    padding: 12px;
}

.details div {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.details div:last-child {
    border-bottom: 0;
}

.status-list {
    display: grid;
    gap: 8px;
}

.status-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fbfcfd;
}

.status-list a:hover,
.status-list a:focus {
    border-color: #aab7c4;
    text-decoration: none;
}

.status-list span {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.status-list small {
    color: var(--muted);
    font-weight: 700;
}

.status-list em {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 4px 10px;
    background: #fff5e8;
    color: var(--accent);
    font-style: normal;
    font-weight: 900;
}

.section-subhead {
    margin-top: 18px;
}

.arena-agent-list {
    display: grid;
    gap: 8px;
    margin: 10px 0 14px;
}

.arena-agent-list div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

.arena-agent-list span {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.arena-agent-list small {
    color: var(--muted);
    font-weight: 700;
}

.arena-agent-list em {
    min-width: 44px;
    border-radius: 999px;
    padding: 4px 10px;
    background: #e8f1f7;
    color: #24546f;
    font-style: normal;
    font-weight: 900;
    text-align: center;
}

.arena-actions {
    margin-bottom: 0;
}

.rule-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px 22px;
    margin: 0;
}

.rule-list div {
    min-width: 0;
}

.rule-list dt {
    color: var(--text);
    font-weight: 800;
    margin-bottom: 4px;
}

.rule-list dd {
    color: var(--muted);
    margin: 0;
}

.trade-history-list {
    display: grid;
    gap: 16px;
}

.trade-history-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

.trade-history-card__header,
.trade-history-grid,
.trade-context-grid {
    display: grid;
    gap: 14px;
}

.trade-history-card__header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
}

.trade-history-card__header h3 {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.trade-history-grid,
.trade-context-grid {
    grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
}

.logic-block {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.logic-block .details {
    margin-top: 10px;
}

.reference-list {
    display: grid;
    gap: 8px;
}

.reference-list span {
    display: block;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
}

.audit-json {
    max-height: 420px;
    overflow: auto;
    margin: 10px 0 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #101820;
    color: #edf5f2;
    font-size: 12px;
    white-space: pre-wrap;
}

.build-update-list {
    display: grid;
    gap: 6px;
    margin: 0;
    padding-left: 18px;
    color: var(--ink);
}

.build-update-list li {
    word-break: break-word;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.92em;
}

.json-panel {
    width: 100%;
    max-height: 520px;
    overflow: auto;
    margin: 10px 0 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #101820;
    color: #f4f7fb;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.db-admin-layout {
    display: grid;
    grid-template-columns: minmax(240px, 0.32fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.db-admin-main {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.db-admin-sidebar {
    max-height: 78vh;
    overflow: auto;
}

.db-admin-table-list {
    display: grid;
    gap: 7px;
}

.db-admin-table-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 54px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fbfcfd;
}

.db-admin-table-link:hover,
.db-admin-table-link:focus,
.db-admin-table-link.is-active {
    border-color: #bfd1ca;
    background: #eef4f1;
    color: var(--primary-dark);
    text-decoration: none;
}

.db-admin-table-link span {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.db-admin-table-link strong {
    overflow-wrap: anywhere;
}

.db-admin-table-link small {
    color: var(--muted);
    font-weight: 700;
}

.db-admin-table-link em {
    flex: 0 0 auto;
    color: var(--muted);
    font-style: normal;
    font-weight: 900;
}

.db-admin-table-wrap {
    max-width: 100%;
    max-height: 620px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.db-admin-table-wrap table {
    border: 0;
    border-radius: 0;
}

.db-admin-cell {
    max-width: 420px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.db-admin-sql textarea {
    min-height: 140px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.db-admin-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.db-admin-toolbar .inline-form,
.db-admin-delete-row .inline-form {
    margin-bottom: 0;
}

.db-admin-danger-form input {
    width: min(220px, 100%);
}

.db-admin-actions-cell {
    min-width: 88px;
    white-space: nowrap;
}

.db-admin-field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.db-admin-field {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

.db-admin-field label span {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.db-admin-field small {
    color: var(--muted);
    font-weight: 700;
}

.db-admin-field--disabled {
    display: grid;
    align-content: center;
    gap: 4px;
}

.db-admin-null-control {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
}

.db-admin-null-control input {
    width: auto;
}

.db-admin-delete-row {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.db-admin-pagination {
    align-items: center;
    margin-top: 12px;
    margin-bottom: 0;
}

dt {
    color: var(--muted);
    font-weight: 800;
}

dd {
    margin: 0;
}

.flash {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    font-weight: 700;
    line-height: 1.45;
    white-space: pre-line;
}

.flash.success {
    border-color: #9fc7b3;
    color: var(--primary-dark);
}

.flash.warning {
    border-color: #d6a35b;
    color: #8a5a13;
}

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

#aiv-error-reporting-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 500;
    width: min(420px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.aiv-error-popup {
    --aiv-card-opacity: 0.96;
    --aiv-fall-duration: 1220ms;
    position: relative;
    pointer-events: auto;
    overflow: hidden;
    border: 2px solid rgb(20 108 90 / 30%);
    border-radius: 14px;
    background: #ffffff;
    color: var(--ink);
    box-shadow: 0 18px 36px rgba(23, 32, 42, 0.22);
    padding: 12px 13px;
    opacity: 0;
    transform: translate3d(0, 18px, 0) scale(0.98);
    transition: opacity 220ms ease, transform 220ms ease;
}

.aiv-error-popup.is-visible {
    opacity: var(--aiv-card-opacity);
    transform: translate3d(0, 0, 0) scale(1);
}

.aiv-error-popup.is-success {
    border-color: #7fb296;
    background: linear-gradient(180deg, #ffffff, #ecf8f1);
}

.aiv-error-popup.is-warning {
    border-color: #d6a35b;
    background: linear-gradient(180deg, #ffffff, #fff4df);
}

.aiv-error-popup.is-error {
    border-color: #d39191;
    background: linear-gradient(180deg, #ffffff, #fff0f0);
}

.aiv-error-popup.is-shaking {
    animation: aiv-error-popup-shake 450ms linear infinite;
}

.aiv-error-popup.is-falling-forward {
    transform-origin: 50% 100%;
    transform-style: preserve-3d;
    animation: aiv-card-fall-forward var(--aiv-fall-duration) cubic-bezier(0.24, 0.74, 0.22, 1) forwards;
}

.aiv-error-popup.is-falling-forward .aiv-popup-content {
    animation: aiv-card-content-dim calc(var(--aiv-fall-duration) * 0.8) ease-out forwards;
}

.aiv-popup-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.aiv-popup-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.aiv-popup-version {
    margin: 0;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

.aiv-popup-message {
    margin: 7px 0 0;
    font-size: 0.92rem;
    line-height: 1.35;
}

.aiv-popup-details {
    margin-top: 8px;
    font-size: 0.85rem;
}

.aiv-popup-details summary {
    cursor: pointer;
    font-weight: 800;
}

.aiv-popup-details ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

.aiv-popup-details li + li {
    margin-top: 4px;
}

.aiv-popup-copy {
    margin-top: 9px;
    border: 1px solid rgb(20 108 90 / 42%);
    border-radius: 10px;
    background: linear-gradient(180deg, #ffffff, #eef6f3);
    color: var(--ink);
    cursor: pointer;
    font-weight: 800;
    padding: 6px 10px;
}

.aiv-popup-copy:hover {
    filter: brightness(1.03);
}

.aiv-popup-copy:focus-visible {
    outline: 3px solid rgb(182 109 22 / 45%);
    outline-offset: 2px;
}

.walkv1-launch {
    margin: 14px 0 0;
}

.walkv1-backdrop {
    position: fixed;
    inset: 0;
    z-index: 520;
    background: rgb(23 32 42 / 42%);
    pointer-events: none;
}

.walkv1-panel {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 540;
    width: min(430px, calc(100vw - 32px));
    padding: 18px;
    border: 1px solid rgb(20 108 90 / 36%);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    box-shadow: 0 24px 56px rgb(23 32 42 / 28%);
}

.walkv1-panel--top {
    top: 16px;
    bottom: auto;
}

.walkv1-panel:focus {
    outline: 0;
}

.walkv1-kicker {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.walkv1-panel h2 {
    margin-bottom: 8px;
}

.walkv1-panel p {
    line-height: 1.5;
}

.walkv1-checklist {
    display: grid;
    gap: 8px;
    margin: 12px 0;
    padding: 0;
    list-style: none;
}

.walkv1-check {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-weight: 800;
}

.walkv1-check__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    min-width: 26px;
    height: 26px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f5f7f9;
    color: var(--primary-dark);
    font-size: 10px;
    font-weight: 900;
}

.walkv1-check.is-complete {
    color: var(--ink);
}

.walkv1-check.is-complete .walkv1-check__mark {
    border-color: #9fc7b3;
    background: #eaf6f0;
}

.walkv1-progress {
    margin: 4px 0 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.walkv1-actions {
    justify-content: flex-end;
    margin-bottom: 0;
}

.walkv1-highlight {
    position: relative;
    z-index: 535;
    border-radius: 8px;
    outline: 3px solid rgb(182 109 22 / 78%);
    outline-offset: 4px;
    box-shadow: 0 0 0 9999px rgb(23 32 42 / 14%), 0 18px 36px rgb(23 32 42 / 24%);
}

@keyframes aiv-error-popup-shake {
    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-3px);
    }

    40% {
        transform: translateX(3px);
    }

    60% {
        transform: translateX(-2px);
    }

    80% {
        transform: translateX(2px);
    }
}

@keyframes aiv-card-fall-forward {
    0% {
        opacity: var(--aiv-card-opacity);
        transform: translate3d(0, 0, 0) perspective(900px) rotateX(0deg) scale(1);
    }

    28% {
        opacity: var(--aiv-card-opacity);
        transform: translate3d(0, 5px, 0) perspective(900px) rotateX(28deg) scale(1.01);
    }

    66% {
        opacity: calc(var(--aiv-card-opacity) * 0.9);
        transform: translate3d(0, 38px, 0) perspective(900px) rotateX(72deg) scale(1.03);
    }

    100% {
        opacity: 0;
        transform: translate3d(0, 102px, 0) perspective(900px) rotateX(89deg) scale(1.05);
    }
}

@keyframes aiv-card-content-dim {
    0% {
        opacity: 1;
        filter: none;
    }

    62% {
        opacity: 0.96;
        filter: saturate(0.92);
    }

    100% {
        opacity: 0;
        filter: blur(0.8px);
    }
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check input {
    width: auto;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
    margin-top: 10px;
}

.bracket {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.bracket-round {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.symbol-monitor-metrics {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.symbol-monitor-controls {
    display: grid;
    gap: 14px;
}

.symbol-monitor-meta .details {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.symbol-monitor-meta .details div {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 8px 10px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
}

.symbol-monitor-meta .details div:last-child {
    border-right: 0;
}

.symbol-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.symbol-table-wrap table {
    border: 0;
    border-radius: 0;
}

.symbol-monitor-table th,
.symbol-monitor-table td {
    white-space: nowrap;
}

.symbol-monitor-table td:nth-child(2) {
    min-width: 260px;
    max-width: 430px;
    white-space: normal;
}

.symbol-raw {
    display: inline-block;
    margin-left: 4px;
    font-size: 12px;
}

.symbol-age-fresh {
    color: var(--primary-dark);
    font-weight: 800;
}

.symbol-age-stale {
    color: var(--danger);
    font-weight: 800;
}

.symbol-badge-inactive {
    background: #eef0f3;
    color: var(--muted);
}

.symbol-badge-crypto {
    background: #eef2ff;
    color: #304c9a;
}

@media (max-width: 860px) {
    .topbar,
    .page-heading,
    .auth-header,
    .inline-form,
    .agent-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .auth-header a {
        padding-top: 0;
    }

    .logout-form {
        margin-left: 0;
    }

    .nav {
        display: grid;
        width: 100%;
        gap: 10px;
    }

    .quick-nav {
        padding: 10px 16px;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .nav-item {
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel);
    }

    .nav-link {
        justify-content: space-between;
        width: 100%;
        min-height: 42px;
        padding: 9px 11px;
    }

    .nav-submenu {
        position: static;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        min-width: 0;
        padding: 0 8px 8px;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: none;
    }

    .nav-submenu--wide {
        min-width: 0;
    }

    .nav-submenu a {
        white-space: normal;
    }

    .topbar {
        align-items: center;
        flex-direction: row;
        min-height: 56px;
        gap: 12px;
        padding: 10px 16px;
    }

    .brand {
        flex: 1;
        min-width: 0;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 38px;
        padding: 8px 12px;
        border: 1px solid var(--line);
        border-radius: 6px;
        background: var(--panel);
        color: var(--ink);
        font: inherit;
        font-weight: 900;
    }

    .mobile-menu-toggle:focus,
    .mobile-menu-toggle:hover {
        border-color: #bfd1ca;
        background: #eef4f1;
        color: var(--primary-dark);
    }

    .topbar .nav,
    .topbar .logout-form,
    .quick-nav {
        display: none;
    }

    body.is-mobile-menu-open .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    body.is-mobile-menu-open .topbar .nav {
        display: grid;
    }

    body.is-mobile-menu-open .topbar .logout-form {
        display: block;
        width: 100%;
    }

    body.is-mobile-menu-open .topbar .logout-form .button {
        width: 100%;
    }

    body.is-mobile-menu-open .quick-nav {
        display: flex;
    }

    .metric-grid,
    .metrics,
    .db-admin-layout,
    .command-hero,
    .v2-hero,
    .command-flow,
    .v2-flow,
    .split,
    .form-grid,
    .compact-form,
    .chart-grid,
    .trade-history-card__header,
    .trade-history-grid,
    .trade-context-grid,
    .check-grid,
    .bracket-visual,
    .bracket {
        grid-template-columns: 1fr;
    }

    .command-actions .inline-form,
    .v2-actions .inline-form,
    .command-actions .button-row,
    .v2-actions .button-row {
        justify-content: stretch;
    }

    .command-actions .button,
    .v2-actions .button {
        width: 100%;
    }

    .chart-panel.wide {
        grid-column: auto;
    }

    .agent-request-actions {
        flex-wrap: wrap;
        min-width: 0;
    }

    .agent-request-detail-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    .symbol-monitor-meta .details {
        grid-template-columns: 1fr;
    }

    .symbol-monitor-meta .details div {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .symbol-monitor-meta .details div:last-child {
        border-bottom: 0;
    }

    .walkv1-panel,
    .walkv1-panel--top {
        top: auto;
        right: 12px;
        bottom: 12px;
        left: 12px;
        width: auto;
        max-height: calc(100vh - 24px);
        overflow: auto;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}
