:root {
    color-scheme: dark;
    --bg: #09090b;
    --surface: #131316;
    --surface-2: #1b1b20;
    --line: #292930;
    --text: #f4f4f6;
    --muted: #9898a7;
    --primary: #6366f1;
    --primary-soft: rgba(99, 102, 241, .14);
    --success: #10b981;
    --warning: #fbbf24;
    --danger: #f43f5e;
    --shadow: 0 24px 70px rgba(0, 0, 0, .32);
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-2: #f5f6fa;
    --line: #e2e3eb;
    --text: #17171f;
    --muted: #686878;
    --primary-soft: #ededff;
    --shadow: 0 22px 60px rgba(31, 35, 70, .09);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, sans-serif;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-family: Outfit, sans-serif;
    font-size: 22px;
    font-weight: 800;
}

.brand .material-symbols-outlined, .brand strong { color: var(--primary); }
.muted { color: var(--muted); }

.icon-button {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
}

.icon-button.theme-control {
    width: auto;
    padding: 0 12px;
    gap: 7px;
    font-size: 12px;
    font-weight: 800;
}

.language-switch {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.language-switch button {
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}

.language-switch button.active {
    color: white;
    background: var(--primary);
    box-shadow: 0 5px 14px rgba(99, 102, 241, .22);
}

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.login-story {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 42px clamp(32px, 6vw, 88px);
    background: linear-gradient(145deg, #11111a, #16162a);
}

.login-story::after {
    content: "";
    position: absolute;
    width: 520px;
    height: 520px;
    right: -210px;
    bottom: -190px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, .34), transparent 67%);
}

.login-copy { position: relative; z-index: 1; max-width: 600px; }
.login-copy h1 { margin: 0 0 20px; font: 800 clamp(42px, 5vw, 74px)/.98 Outfit, sans-serif; letter-spacing: -.045em; }
.login-copy p { margin: 0; color: #b5b5c5; font-size: 18px; line-height: 1.7; }

.security-points { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 20px; color: #c8c8d4; font-size: 13px; }
.security-points span { display: flex; align-items: center; gap: 7px; }
.security-points .material-symbols-outlined { color: var(--success); font-size: 19px; }

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: var(--bg);
}

.login-card { width: min(440px, 100%); }
.login-card header { display: flex; justify-content: flex-end; margin-bottom: 56px; }
.login-card header.login-controls { align-items: center; gap: 10px; }
.login-card h2 { margin: 0 0 9px; font: 800 34px Outfit, sans-serif; }
.login-card > p { margin: 0 0 32px; color: var(--muted); line-height: 1.6; }

.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field label { font-size: 13px; font-weight: 700; }
.field input {
    width: 100%;
    height: 52px;
    padding: 0 15px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    outline: none;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }

.primary-button {
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: white;
    background: var(--primary);
    border: 0;
    border-radius: 12px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(99, 102, 241, .25);
}

.demo-note { margin-top: 22px; padding: 14px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; font-size: 12px; line-height: 1.6; }
.demo-note strong { color: var(--text); }
.back-link { display: inline-flex; gap: 6px; align-items: center; margin-top: 24px; color: var(--muted); font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 26px 18px;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.side-nav { display: grid; gap: 5px; margin-top: 38px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 12px 13px; color: var(--muted); border-radius: 10px; font-size: 14px; font-weight: 600; }
.side-nav a.active { color: var(--primary); background: var(--primary-soft); }
.side-nav .material-symbols-outlined { font-size: 21px; }
.sidebar-bottom { margin-top: auto; }
.system-state { display: flex; gap: 9px; align-items: center; margin-bottom: 18px; padding: 12px; color: var(--muted); background: var(--surface-2); border-radius: 10px; font-size: 11px; }
.state-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(16, 185, 129, .12); }
.logout { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px; color: var(--muted); background: transparent; border: 0; cursor: pointer; }

.app-main { min-width: 0; }
.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; background: color-mix(in srgb, var(--surface) 85%, transparent); border-bottom: 1px solid var(--line); }
.topbar-actions, .profile { display: flex; align-items: center; gap: 12px; }
.profile-avatar { width: 38px; height: 38px; display: grid; place-items: center; color: white; background: var(--primary); border-radius: 11px; font-weight: 800; }
.profile small { display: block; color: var(--muted); }
.profile-button { padding: 0; color: var(--text); text-align: left; background: transparent; border: 0; cursor: pointer; }
.profile-button:hover strong { color: var(--primary); }

.dashboard { padding: 34px; max-width: 1500px; margin: 0 auto; }
.dashboard-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 28px; }
.dashboard-heading h1 { margin: 0 0 6px; font: 800 34px Outfit, sans-serif; }
.dashboard-heading p { margin: 0; color: var(--muted); }
.new-operation { padding: 12px 17px; color: white; background: var(--primary); border: 0; border-radius: 11px; font-weight: 800; cursor: pointer; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.metric { padding: 20px; }
.metric-label { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.metric-label .material-symbols-outlined { padding: 8px; color: var(--primary); background: var(--primary-soft); border-radius: 9px; }
.metric strong { display: block; margin: 18px 0 6px; font: 800 29px Outfit, sans-serif; }
.metric small { color: var(--success); }

.dashboard-grid { display: grid; grid-template-columns: 1.6fr .8fr; gap: 18px; margin-top: 18px; }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.card-header h2 { margin: 0; font: 700 18px Outfit, sans-serif; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 15px 22px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 99px; font-size: 11px; font-weight: 800; }
.status.approved { color: var(--success); background: rgba(16, 185, 129, .12); }
.status.review { color: #b77900; background: rgba(251, 191, 36, .14); }
.status.blocked { color: var(--danger); background: rgba(244, 63, 94, .12); }

.risk-list { display: grid; gap: 12px; padding: 18px; }
.risk-item { display: flex; gap: 12px; align-items: center; padding: 13px; background: var(--surface-2); border-radius: 12px; }
.risk-icon { width: 38px; height: 38px; display: grid; place-items: center; color: var(--warning); background: rgba(251, 191, 36, .12); border-radius: 10px; }
.risk-item strong, .risk-item small { display: block; }
.risk-item small { margin-top: 3px; color: var(--muted); }

.app-view[hidden] { display: none !important; }
.app-view.active { animation: view-in .24s ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

button { color: inherit; }
.text-button, .row-action { color: var(--primary); background: transparent; border: 0; font-weight: 700; cursor: pointer; }
.text-button:hover, .row-action:hover { text-decoration: underline; }
.status-button { border: 0; cursor: pointer; }
.risk-button { width: 100%; color: var(--text); text-align: left; border: 1px solid transparent; cursor: pointer; }
.risk-button:hover { border-color: var(--line); }
.risk-button > span:nth-child(2) { flex: 1; }
.risk-button .chevron { color: var(--muted); }
.agent-ok { color: var(--success) !important; background: rgba(16,185,129,.12) !important; }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; padding: 14px; }
.search-field { min-width: 260px; flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.search-field .material-symbols-outlined { color: var(--muted); }
.search-field input, .toolbar select { height: 42px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; outline: none; }
.search-field input { width: 100%; padding: 0; border: 0; }
.toolbar select { padding: 0 34px 0 12px; }
.search-field:focus-within, .toolbar select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.compliance-grid { display: grid; grid-template-columns: .8fr 1.3fr; gap: 18px; }
.case-list { align-self: start; overflow: hidden; }
.case-card { width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 16px 18px; color: var(--text); text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.case-card:hover, .case-card.active { background: var(--surface-2); }
.case-card.active { box-shadow: inset 3px 0 var(--primary); }
.case-card.resolved { opacity: .7; }
.case-card strong, .case-card small { display: block; }
.case-card small { margin-top: 4px; color: var(--muted); }
.case-content { padding: 22px; }
.case-alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px; color: #a16207; background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.25); border-radius: 12px; }
.case-alert p { margin: 0; line-height: 1.55; }
.case-content dl { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.case-content dl div { padding: 13px; background: var(--surface-2); border-radius: 10px; }
.case-content dt { color: var(--muted); font-size: 11px; }
.case-content dd { margin: 6px 0 0; font-weight: 700; }
.decision-note { display: grid; gap: 8px; font-size: 12px; font-weight: 700; }
.decision-note textarea, .modal-grid input { width: 100%; padding: 12px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; resize: vertical; outline: none; }
.decision-note textarea:focus, .modal-grid input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.decision-actions, .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.danger-button, .success-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 11px 15px; border-radius: 10px; font-weight: 800; cursor: pointer; }
.danger-button { color: white; background: var(--danger); border: 0; }
.success-button { color: white; background: var(--success); border: 0; }
.secondary-button { color: var(--text); background: var(--surface); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: not-allowed; }

.agent-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.agent-card { padding: 20px; }
.agent-head { display: flex; align-items: center; justify-content: space-between; }
.agent-symbol { padding: 10px; color: var(--primary); background: var(--primary-soft); border-radius: 11px; }
.agent-card h2 { margin: 18px 0 7px; font: 700 18px Outfit, sans-serif; }
.agent-card p { min-height: 58px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.agent-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0; color: var(--muted); font-size: 11px; }
.agent-meta strong { display: block; margin-top: 3px; color: var(--text); }
.agent-test { width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 9px; }
.activity-card { margin-top: 18px; }
.activity-list { padding: 4px 22px; }
.activity-list p { display: flex; align-items: center; gap: 9px; margin: 0; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.activity-list p:last-child { border: 0; }
.activity-list small { margin-left: auto; color: var(--muted); }
.is-loading .material-symbols-outlined { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(8,8,12,.7); backdrop-filter: blur(8px); }
.modal-backdrop[hidden] { display: none; }
.app-modal { width: min(620px, 100%); padding: 22px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h2 { margin: 3px 0 0; font: 800 25px Outfit, sans-serif; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-grid label { display: grid; gap: 7px; font-size: 12px; font-weight: 700; }
.file-control { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding: 13px; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px; font-size: 12px; }
.file-control input { max-width: 240px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 120; max-width: 420px; padding: 13px 16px; color: white; background: #167c5a; border-radius: 11px; box-shadow: 0 18px 50px rgba(0,0,0,.28); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .22s ease; }
.toast[data-type="danger"] { background: #be123c; }
.toast.show { opacity: 1; transform: none; }

.settings-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; align-items: start; }
.account-card { overflow: hidden; }
.account-profile { display: flex; align-items: center; gap: 14px; padding: 22px 22px 4px; }
.account-profile strong, .account-profile small { display: block; }
.account-profile small { margin-top: 4px; color: var(--muted); }
.account-avatar { width: 56px; height: 56px; font-size: 18px; }
.settings-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 22px; }
.settings-fields label { display: grid; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.settings-fields label:first-child, .settings-fields label:nth-child(2) { grid-column: span 1; }
.settings-fields input { width: 100%; height: 44px; padding: 0 12px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; outline: none; }
.settings-fields input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.settings-actions { display: flex; justify-content: flex-end; padding: 0 22px 22px; }
.settings-column { display: grid; gap: 18px; }
.preference-card { overflow: hidden; }
.preference-content { padding: 18px; }
.preference-content > p { margin: 0 0 14px; font-size: 13px; }
.language-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option-button { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center; padding: 12px; color: var(--text); text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.option-button > span:first-child { color: var(--primary); font-size: 11px; font-weight: 800; }
.option-button .material-symbols-outlined { color: transparent; font-size: 18px; }
.option-button.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.option-button.active .material-symbols-outlined { color: var(--primary); }
.appearance-options { display: flex; gap: 10px; }
.appearance-button { width: 52px; height: 52px; display: grid; place-items: center; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px; cursor: pointer; }
.appearance-button.active { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.session-card { display: flex; gap: 13px; align-items: center; padding: 18px; }
.session-card > .material-symbols-outlined { padding: 10px; color: var(--success); background: rgba(16,185,129,.12); border-radius: 11px; }
.session-card p { margin: 4px 0 0; font-size: 12px; }

@media (max-width: 1000px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .agent-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
    .login-page { grid-template-columns: 1fr; }
    .login-story { min-height: 360px; padding: 28px; }
    .login-panel { padding: 28px 20px; }
    .login-card header { margin-bottom: 35px; }
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar { position: static; height: auto; padding: 16px; }
    .side-nav { grid-template-columns: repeat(5, 1fr); margin-top: 16px; overflow-x: auto; }
    .side-nav a { justify-content: center; }
    .side-nav a span:last-child, .sidebar-bottom { display: none; }
    .topbar { padding: 0 16px; }
    .profile > div:not(.profile-avatar) { display: none; }
    .dashboard { padding: 24px 16px; }
    .dashboard-heading { align-items: flex-start; flex-direction: column; }
    .metric-grid { grid-template-columns: 1fr; }
    .toolbar, .decision-actions { align-items: stretch; flex-direction: column; }
    .search-field { min-width: 0; }
    .compliance-grid, .modal-grid { grid-template-columns: 1fr; }
    .agent-grid { grid-template-columns: 1fr; }
    .case-content dl { grid-template-columns: 1fr; }
    .activity-list p { align-items: flex-start; flex-wrap: wrap; }
    .activity-list small { width: 100%; margin-left: 17px; }
    .settings-grid, .settings-fields { grid-template-columns: 1fr; }
}

/* Full light/dark coverage for authentication and protected application. */
:root[data-theme="dark"] .login-story {
    color: #f4f4f6;
    background: linear-gradient(145deg, #11111a, #16162a);
}

:root[data-theme="light"] .login-story {
    color: #17171f;
    background: linear-gradient(145deg, #ffffff, #eceeff);
    border-right: 1px solid var(--line);
}

:root[data-theme="light"] .login-story::after {
    background: radial-gradient(circle, rgba(99, 102, 241, .18), transparent 67%);
}

:root[data-theme="light"] .login-copy p,
:root[data-theme="light"] .security-points {
    color: #626273;
}

:root[data-theme="light"] .topbar {
    background: rgba(255, 255, 255, .9);
}

:root[data-theme="dark"] .topbar {
    background: rgba(19, 19, 22, .9);
}

:root[data-theme="light"] .status.review {
    color: #8a5700;
    background: #fff4d6;
}

:root[data-theme="light"] .status.blocked {
    color: #be123c;
    background: #fff0f3;
}

:root[data-theme="light"] .status.approved {
    color: #047857;
    background: #e9fbf4;
}

:root[data-theme="light"] .risk-icon {
    color: #9a6700;
    background: #fff4d6;
}

:root[data-theme] body,
:root[data-theme] .login-story,
:root[data-theme] .login-panel,
:root[data-theme] .app-sidebar,
:root[data-theme] .topbar,
:root[data-theme] .card,
:root[data-theme] input,
:root[data-theme] .icon-button,
:root[data-theme] .risk-item {
    transition: color .2s ease, background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
