:root {
    --bg: #f2efe5;
    --bg-soft: #faf7ef;
    --panel: #fdfbf5;
    --panel-2: #efe9d9;
    --border: #ddd3bc;
    --text: #2c2620;
    --text-dim: #5d5546;
    --text-mute: #8d8471;
    --accent: #2e9e6b;
    --accent-dim: #1f7a53;
    --accent-soft: rgba(46, 158, 107, .12);
    --blue: #3b6fd4;
    --violet: #7e5cd6;
    --amber: #a86a12;
    --red: #c94f4f;
    --radius: 14px;
    --radius-sm: 9px;
    --sidebar: 264px;
    --shadow: 0 8px 28px rgba(90, 75, 50, .13);
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    color: var(--accent-dim);
}

/* ---------- Layout ---------- */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar);
    flex-shrink: 0;
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
    padding: 22px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 22px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--blue));
    display: grid;
    place-items: center;
    font-size: 20px;
}

.brand-text b {
    display: block;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -.2px;
}

.brand-text span {
    font-size: 11.5px;
    color: var(--text-mute);
}

.nav {
    padding: 0 12px;
}

.nav-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .9px;
    color: var(--text-mute);
    padding: 14px 10px 7px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 14.2px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background .14s, color .14s;
}

.nav-item:hover {
    background: var(--panel);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.nav-item .ico {
    width: 20px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}

.nav-foot {
    padding: 18px 22px 0;
    margin-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--text-mute);
    line-height: 1.5;
}

/* ---------- Main ---------- */

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

.topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}

.burger {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    font-size: 17px;
    cursor: pointer;
}

.content {
    flex: 1;
    padding: 30px 34px 60px;
    max-width: 1180px;
    width: 100%;
}

.page-head {
    margin-bottom: 26px;
}

.page-head h1 {
    font-size: 27px;
    font-weight: 680;
    letter-spacing: -.5px;
    margin-bottom: 5px;
}

.page-head p {
    color: var(--text-dim);
    font-size: 14.5px;
}

/* ---------- Cards ---------- */

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.card + .card {
    margin-top: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 640;
    margin-bottom: 4px;
}

.card-sub {
    color: var(--text-mute);
    font-size: 13px;
    margin-bottom: 16px;
}

.grid {
    display: grid;
    gap: 15px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(288px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(222px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
}

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

.feature {
    display: block;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 19px;
    color: var(--text);
    transition: border-color .16s, transform .16s, background .16s;
}

.feature:hover {
    border-color: var(--accent-dim);
    background: var(--panel-2);
    color: var(--text);
    transform: translateY(-2px);
}

.feature-ico {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: var(--accent-soft);
    display: grid;
    place-items: center;
    font-size: 19px;
    margin-bottom: 13px;
}

.feature h3 {
    font-size: 15.5px;
    font-weight: 620;
    margin-bottom: 5px;
}

.feature p {
    font-size: 13.2px;
    color: var(--text-dim);
    line-height: 1.55;
}

/* ---------- Stats ---------- */

.stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.stat b {
    display: block;
    font-size: 25px;
    font-weight: 700;
    letter-spacing: -.6px;
    line-height: 1.2;
}

.stat span {
    font-size: 12.5px;
    color: var(--text-mute);
}

.stat.accent b {
    color: var(--accent);
}

.stat.blue b {
    color: var(--blue);
}

.stat.violet b {
    color: var(--violet);
}

.stat.amber b {
    color: var(--amber);
}

/* ---------- Forms ---------- */

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 12.8px;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 550;
}

.input,
.textarea,
.select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 10px 13px;
    font-size: 14.2px;
    font-family: inherit;
    transition: border-color .14s, box-shadow .14s;
}

.input:focus,
.textarea:focus,
.select:focus {
    outline: none;
    border-color: var(--accent-dim);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.textarea {
    min-height: 108px;
    resize: vertical;
    line-height: 1.6;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent-dim);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 19px;
    font-size: 14.2px;
    font-weight: 620;
    font-family: inherit;
    cursor: pointer;
    transition: filter .14s, opacity .14s;
}

.btn:hover {
    filter: brightness(1.09);
    color: #ffffff;
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.btn.ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.btn.ghost:hover {
    color: var(--text);
    background: var(--panel);
    border-color: var(--text-mute);
}

.btn.sm {
    padding: 7px 13px;
    font-size: 13px;
}

.row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.row .field {
    flex: 1;
    min-width: 168px;
    margin-bottom: 0;
}

/* ---------- Tables ---------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.8px;
}

th,
td {
    padding: 9px 13px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-soft);
    font-size: 11.8px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-mute);
    font-weight: 620;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--panel-2);
}

td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11.4px;
    font-weight: 620;
    background: var(--panel-2);
    color: var(--text-dim);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.badge.ok {
    background: rgba(52, 211, 153, .13);
    color: var(--accent);
    border-color: rgba(52, 211, 153, .3);
}

.badge.warn {
    background: rgba(251, 191, 36, .13);
    color: var(--amber);
    border-color: rgba(251, 191, 36, .3);
}

.badge.danger {
    background: rgba(248, 113, 113, .13);
    color: var(--red);
    border-color: rgba(248, 113, 113, .3);
}

.badge.info {
    background: rgba(96, 165, 250, .13);
    color: var(--blue);
    border-color: rgba(96, 165, 250, .3);
}

.badge.rx {
    background: rgba(167, 139, 250, .13);
    color: var(--violet);
    border-color: rgba(167, 139, 250, .3);
}

/* ---------- Alerts ---------- */

.alert {
    border-radius: var(--radius-sm);
    padding: 13px 16px;
    font-size: 13.6px;
    line-height: 1.6;
    border: 1px solid;
    margin-bottom: 16px;
}

.alert-warn {
    background: rgba(180, 83, 9, .08);
    border-color: rgba(180, 83, 9, .3);
    color: #92400e;
}

.alert-info {
    background: rgba(37, 99, 235, .07);
    border-color: rgba(37, 99, 235, .28);
    color: #1e40af;
}

.alert-danger {
    background: rgba(220, 38, 38, .07);
    border-color: rgba(220, 38, 38, .3);
    color: #991b1b;
}

.alert b {
    display: block;
    margin-bottom: 3px;
}

/* ---------- AI block ---------- */

.ai-box {
    background: linear-gradient(135deg, rgba(52, 211, 153, .07), rgba(96, 165, 250, .05));
    border: 1px solid rgba(52, 211, 153, .26);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 16px;
}

.ai-head {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 640;
    font-size: 15px;
    margin-bottom: 14px;
    color: var(--accent);
}

.ai-out {
    font-size: 14.2px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ai-out:empty {
    display: none;
}

.ai-loading {
    display: none;
    align-items: center;
    gap: 10px;
    color: var(--text-dim);
    font-size: 13.6px;
    padding: 12px 0;
}

.ai-loading.on {
    display: flex;
}

.spinner {
    width: 15px;
    height: 15px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

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

/* ---------- Result list ---------- */

.result {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 15px;
    margin-bottom: 11px;
}

.result-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 9px;
}

.result-head h3 {
    font-size: 15.2px;
    font-weight: 630;
}

.result-meta {
    font-size: 12.6px;
    color: var(--text-mute);
    margin-bottom: 9px;
}

.result-body {
    font-size: 13.6px;
    color: var(--text-dim);
    line-height: 1.65;
}

.empty {
    text-align: center;
    padding: 46px 20px;
    color: var(--text-mute);
}

.empty-ico {
    font-size: 38px;
    margin-bottom: 12px;
    opacity: .5;
}

.empty p {
    font-size: 14px;
}

/* ---------- Macro bars ---------- */

.macro {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 7px;
    font-size: 12.8px;
}

.macro span:first-child {
    width: 76px;
    color: var(--text-dim);
    flex-shrink: 0;
}

.macro-bar {
    flex: 1;
    height: 7px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

.macro-bar i {
    display: block;
    height: 100%;
    border-radius: 4px;
}

.macro b {
    width: 56px;
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ---------- Chips ---------- */

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 10px;
}

.chip {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12.6px;
    cursor: pointer;
    transition: all .14s;
}

.chip:hover {
    border-color: var(--accent-dim);
    color: var(--accent);
}

/* ---------- Placeholder ---------- */

.placeholder {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 42px 26px;
    text-align: center;
    color: var(--text-mute);
}

.placeholder h3 {
    color: var(--text-dim);
    font-size: 16px;
    margin-bottom: 7px;
    font-weight: 600;
}

.placeholder p {
    font-size: 13.6px;
    max-width: 460px;
    margin: 0 auto;
}

/* ---------- Footer ---------- */

.footer {
    border-top: 1px solid var(--border);
    padding: 20px 34px;
    color: var(--text-mute);
    font-size: 12.4px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* ---------- Responsive ---------- */

@media (max-width: 940px) {
    .topbar {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--shadow);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        padding: 22px 18px 50px;
    }

    .page-head h1 {
        font-size: 23px;
    }

    .footer {
        padding: 18px;
    }
}

.backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .58);
    z-index: 35;
}

.backdrop.on {
    display: block;
}
