:root {
    --bg: #f4f7f3;
    --bg-accent: radial-gradient(circle at top left, rgba(33, 191, 115, 0.14), transparent 35%), radial-gradient(circle at top right, rgba(11, 95, 255, 0.11), transparent 30%), #f4f7f3;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-strong: #ffffff;
    --line: rgba(14, 30, 37, 0.12);
    --text: #152126;
    --muted: #5d7179;
    --accent: #0b5fff;
    --accent-soft: rgba(11, 95, 255, 0.1);
    --success: #138a57;
    --warning: #c96e12;
    --danger: #c53b30;
    --shadow: 0 24px 60px rgba(35, 58, 74, 0.09);
    --radius: 22px;
    --radius-sm: 14px;
    --font-ui: "IBM Plex Sans", "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", "SFMono-Regular", monospace;
}
:root[data-theme="dark"] {
    --bg: #10161a;
    --bg-accent: radial-gradient(circle at top left, rgba(45, 212, 191, 0.12), transparent 35%), radial-gradient(circle at top right, rgba(96, 165, 250, 0.13), transparent 30%), #10161a;
    --surface: rgba(24, 32, 38, 0.9);
    --surface-strong: #172027;
    --line: rgba(220, 238, 245, 0.13);
    --text: #edf7fa;
    --muted: #98acb5;
    --accent: #5aa2ff;
    --accent-soft: rgba(90, 162, 255, 0.16);
    --success: #45d39a;
    --warning: #f4b15d;
    --danger: #ff7d73;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font-ui);
    color: var(--text);
    background: var(--bg-accent);
    min-height: 100vh;
}
a { color: inherit; }
.shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}
.sidebar {
    padding: 28px 20px;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-strong) 74%, transparent);
    backdrop-filter: blur(24px);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
}
.brand {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
}
.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #fff;
    border: 1px solid var(--line);
    overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; display: block; }
.brand strong { display: block; line-height: 1.05; }
.brand small { display: block; color: var(--muted); }
.brand .vendor { font-size: 0.72rem; margin-top: 4px; }
.nav-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.nav-section {
    margin: 18px 4px 8px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    text-decoration: none;
    color: var(--muted);
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.nav-link:hover, .nav-link.active {
    background: var(--accent-soft);
    color: var(--text);
    transform: translateX(2px);
}
.nav-icon, .action-icon {
    width: 22px;
    min-width: 22px;
    display: inline-flex;
    justify-content: center;
    font-size: 1rem;
}
.icon-blue { color: #2f80ed; }
.icon-green { color: #17a667; }
.icon-orange { color: #f2994a; }
.icon-red { color: #eb5757; }
.icon-purple { color: #9b51e0; }
.icon-cyan { color: #20b8c7; }
.icon-pink { color: #e2559b; }
.nav-link strong {
    display: block;
    font-size: 0.96rem;
    font-weight: 600;
}
.nav-link span {
    font-size: 0.78rem;
    opacity: 0.9;
}
.main {
    padding: 28px 30px 42px;
    min-width: 0;
}
.app-topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.theme-toggle {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
}
.language-toggle {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
}
.lang-btn {
    min-width: 38px;
    height: 36px;
    border-radius: 999px;
    border: 0;
    padding: 0 10px;
    display: inline-grid;
    place-items: center;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
}
.lang-btn:hover, .lang-btn.active {
    background: var(--accent-soft);
    color: var(--text);
}
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 0;
    display: inline-grid;
    place-items: center;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.icon-btn:hover, .icon-btn.active {
    background: var(--accent-soft);
    color: var(--text);
}
.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
}
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}
.topbar h1 {
    margin: 0;
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    line-height: 1.02;
}
.topbar p {
    margin: 4px 0 0;
    color: var(--muted);
}
.toolbar, .actions, .filters, .inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.btn, button, input, select, textarea { font: inherit; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: rgba(201, 110, 18, 0.14); color: var(--warning); border-color: rgba(201, 110, 18, 0.18); }
.btn-danger { background: rgba(197, 59, 48, 0.14); color: var(--danger); border-color: rgba(197, 59, 48, 0.18); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
.panel + .panel { margin-top: 18px; }
.panel-body { padding: 22px; }
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 22px 22px 0;
}
.grid { display: grid; gap: 18px; }
.grid.metrics { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.metric {
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 94%, transparent), color-mix(in srgb, var(--surface) 88%, transparent));
    border: 1px solid var(--line);
}
.metric label {
    display: block;
    color: var(--muted);
    font-size: 0.84rem;
    margin-bottom: 10px;
}
.metric strong {
    font-size: 2rem;
    line-height: 1;
    font-weight: 700;
}
.metric small {
    display: block;
    margin-top: 10px;
    color: var(--muted);
}
.filters { padding: 16px 22px 0; }
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
}
.field label {
    color: var(--muted);
    font-size: 0.8rem;
}
.field input, .field select, .field textarea {
    width: 100%;
    background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--text);
    padding: 11px 13px;
}
.inline-actions input, .inline-actions select {
    min-height: 36px;
    max-width: 180px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
    color: var(--text);
    padding: 8px 10px;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    font-weight: 600;
}
tr:last-child td { border-bottom: none; }
.table-wrap {
    overflow: auto;
    padding: 0 22px 22px;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    background: color-mix(in srgb, var(--text) 8%, transparent);
}
.chip.success { color: var(--success); background: rgba(19, 138, 87, 0.12); }
.chip.warning { color: var(--warning); background: rgba(201, 110, 18, 0.12); }
.chip.danger { color: var(--danger); background: rgba(197, 59, 48, 0.12); }
.chip.status-pending { color: var(--muted); background: rgba(120, 120, 130, 0.12); }
.chip.status-approved { color: var(--success); background: rgba(19, 138, 87, 0.12); }
.chip.status-rejected { color: var(--danger); background: rgba(197, 59, 48, 0.12); }
.chip.status-edited { color: var(--accent); background: rgba(11, 95, 255, 0.1); }
.chip.info { color: var(--accent); background: rgba(11, 95, 255, 0.1); }
.chip.purple { color: #9b51e0; background: rgba(155, 81, 224, 0.13); }
.chip.cyan { color: #20b8c7; background: rgba(32, 184, 199, 0.13); }
.chip.pink { color: #e2559b; background: rgba(226, 85, 155, 0.13); }
.stmt-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    vertical-align: middle;
    white-space: nowrap;
}
.stmt-badge.fact { color: var(--success); background: rgba(19, 138, 87, 0.12); border: 1px solid rgba(19, 138, 87, 0.3); }
.stmt-badge.hypothesis { color: #9b51e0; background: rgba(155, 81, 224, 0.12); border: 1px solid rgba(155, 81, 224, 0.3); }
.stmt-badge.conclusion { color: var(--accent); background: rgba(11, 95, 255, 0.1); border: 1px solid rgba(11, 95, 255, 0.25); }
.stmt-badge.recommendation { color: var(--warning); background: rgba(201, 110, 18, 0.12); border: 1px solid rgba(201, 110, 18, 0.3); }
.stmt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.stmt-item {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface-strong) 60%, transparent);
}
.stmt-item .stmt-text { margin: 4px 0 0; }
.stmt-item .stmt-src { margin-top: 6px; }
.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.stack { display: flex; flex-direction: column; gap: 14px; }
.subtle { color: var(--muted); }
.mono {
    font-family: var(--font-mono);
    font-size: 0.9rem;
}
.payload-summary {
    margin: 4px 0 0;
    display: grid;
    gap: 2px;
    font-size: 0.9rem;
}
.payload-row {
    display: flex;
    gap: 8px;
    align-items: baseline;
}
.payload-key {
    flex: 0 0 auto;
    min-width: 120px;
    color: var(--muted);
    font-size: 0.82rem;
}
.payload-value {
    margin: 0;
    word-break: break-word;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}
.tech-data pre {
    margin: 6px 0 0;
    max-height: 240px;
    overflow: auto;
    background: var(--panel-bg, #f7f7f8);
    padding: 8px;
    border-radius: 6px;
}
.section-title {
    margin: 0 0 6px;
    font-size: 1.08rem;
}
.section-kicker {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}
.divider {
    height: 1px;
    background: var(--line);
    margin: 8px 0;
}
details {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface-strong) 70%, transparent);
    padding: 12px 14px;
}
summary {
    cursor: pointer;
    color: var(--text);
    font-weight: 700;
}
.profile-editor {
    padding: 0;
    overflow: hidden;
}
.profile-editor > summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    list-style: none;
}
.profile-editor > summary::-webkit-details-marker { display: none; }
.profile-editor[open] > summary {
    border-bottom: 1px solid var(--line);
}
.profile-editor form,
.profile-summary {
    padding: 18px;
}
.profile-summary p {
    margin: 0 0 12px;
    color: var(--muted);
}
.pagination {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
    padding: 0 22px 22px;
    flex-wrap: wrap;
}
.pagination-nav {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
}
.pagination .current {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.empty {
    padding: 26px 22px 22px;
    color: var(--muted);
}
.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-item {
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
}
.timeline-item header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.tab {
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    background: color-mix(in srgb, var(--text) 6%, transparent);
    color: var(--muted);
    border: none;
}
.tab.active {
    background: var(--accent);
    color: #fff;
}
pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: color-mix(in srgb, var(--text) 4%, transparent);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    overflow: auto;
}
.danger-box {
    border: 1px solid rgba(197, 59, 48, 0.18);
    background: rgba(197, 59, 48, 0.08);
}
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 22px;
}
.auth-card {
    width: min(460px, 100%);
    padding: 28px;
}
@media (max-width: 1024px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }
    .main { padding: 22px 16px 34px; }
    .nav-group {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .nav-link span { display: none; }
    .app-topbar { justify-content: space-between; }
    .topbar { flex-direction: column; align-items: flex-start; }
    .toolbar, .filters { width: 100%; }
    .toolbar .btn, .filters .field { flex: 1 1 180px; }
}
@media (max-width: 640px) {
    .sidebar { padding: 18px 14px; }
    .brand { grid-template-columns: 40px minmax(0, 1fr); }
    .brand-mark { width: 40px; height: 40px; }
    .nav-group { grid-template-columns: 1fr; }
    .nav-link { padding: 11px 12px; }
    .panel-header, .pagination, .timeline-item header { align-items: flex-start; flex-direction: column; }
    .table-wrap { padding: 0 12px 18px; }
    th, td { padding: 11px 10px; }
    .user-pill span:not(.chip) { display: none; }
}
