:root {
    --bg: #f3efe6;
    --panel: #fffaf1;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #d6cfc0;
    --accent: #bb5a2b;
    --accent-2: #1e5f55;
    --danger: #9f1239;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top right, rgba(187,90,43,.12), transparent 35%),
        radial-gradient(circle at bottom left, rgba(30,95,85,.15), transparent 40%),
        var(--bg);
}
.hidden { display: none !important; }
.login-shell, .app-shell { min-height: 100vh; }
.login-shell { display: grid; place-items: center; padding: 24px; }
.login-card, .panel, .sidebar {
    background: rgba(255,250,241,.92);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 22px 60px rgba(31,41,55,.08);
}
.login-card { width: min(100%, 420px); padding: 28px; }
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .12em; color: var(--accent); }
h1, h2, h3, h4 { margin: 0; }
.input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}
.input { margin-top: 12px; }
.textarea {
    min-height: 160px;
    resize: vertical;
    font: inherit;
    line-height: 1.45;
    white-space: pre-wrap;
}
.button {
    border: 0;
    border-radius: 14px;
    padding: 11px 16px;
    font-weight: 700;
    cursor: pointer;
}
.primary { background: linear-gradient(135deg, var(--accent), #e28f4e); color: white; }
.secondary { background: #ede7db; color: var(--ink); }
.wide { width: 100%; }
.error { color: var(--danger); margin-top: 10px; min-height: 22px; }
.muted { color: var(--muted); }
.app-shell { display: grid; grid-template-columns: 280px 1fr; gap: 18px; padding: 18px; }
.sidebar { padding: 22px; display: flex; flex-direction: column; justify-content: space-between; }
.nav { display: grid; gap: 10px; margin: 24px 0; }
.nav-btn {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.nav-btn.active { background: var(--ink); color: white; }
.content { display: grid; gap: 18px; }
.tab { display: none; gap: 18px; }
.tab.active { display: grid; }
.section-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}
.inline-actions { display: flex; gap: 10px; align-items: center; }
.dashboard-hero,
.insights-grid,
.details-grid { display: grid; gap: 18px; }
.dashboard-hero { grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); }
.hero-card {
    border-radius: 24px;
    padding: 22px;
    border: 1px solid rgba(214, 207, 192, .9);
    box-shadow: 0 24px 60px rgba(31,41,55,.08);
}
.hero-primary {
    color: white;
    background:
        radial-gradient(circle at top right, rgba(255,255,255,.16), transparent 30%),
        linear-gradient(135deg, #1f2937, #bb5a2b 58%, #e6a15e);
}
.hero-primary .eyebrow,
.hero-primary .muted { color: rgba(255,255,255,.72); }
.hero-primary h2 { font-size: clamp(28px, 4vw, 40px); line-height: 1.02; margin: 12px 0; }
.hero-primary p { max-width: 58ch; margin: 0; color: rgba(255,255,255,.88); }
.hero-secondary {
    background:
        radial-gradient(circle at top left, rgba(30,95,85,.16), transparent 45%),
        rgba(255,250,241,.92);
    display: grid;
    gap: 14px;
    align-content: center;
}
.hero-kpi {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(214, 207, 192, .9);
}
.hero-kpi:last-child { padding-bottom: 0; border-bottom: 0; }
.hero-kpi strong { font-size: 24px; }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 14px; }
.stat-card {
    position: relative;
    overflow: hidden;
    background: rgba(255,255,255,.74);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
}
.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 4px;
    opacity: .95;
}
.stat-card.warm::before { background: linear-gradient(90deg, #bb5a2b, #e7a25f); }
.stat-card.green::before { background: linear-gradient(90deg, #1e5f55, #62b5a4); }
.stat-card.gold::before { background: linear-gradient(90deg, #b7791f, #f0c366); }
.stat-card.neutral::before { background: linear-gradient(90deg, #64748b, #c7d2fe); }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 8px; }
.stat-detail { margin-top: 10px; color: var(--muted); font-size: 13px; }
.insights-grid { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.insight-card {
    background: rgba(255,255,255,.76);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
    display: grid;
    gap: 8px;
}
.insight-card strong { font-size: 18px; line-height: 1.2; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.details-grid { grid-template-columns: 1fr 1fr; }
.panel { padding: 18px; overflow: auto; }
.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 8px;
}
.panel-head p { margin: 6px 0 0; }
.chart-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.chart-meta .up { color: var(--accent-2); }
.chart-meta .down { color: var(--accent); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #ece5d7; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); }
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.badge.ok { background: rgba(30,95,85,.14); color: var(--accent-2); }
.badge.bad { background: rgba(159,18,57,.12); color: var(--danger); }
.user-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tiny-input {
    width: 72px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
}
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(280px, 1fr)); gap: 16px; }
.settings-grid.single-column { grid-template-columns: 1fr; }
.setting-card {
    background: rgba(255,255,255,.72);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px;
}
.event-row, .status-row {
    padding: 12px 0;
    border-bottom: 1px solid #ece5d7;
}
.event-row:last-child, .status-row:last-child { border-bottom: 0; padding-bottom: 0; }
.event-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}
.event-aside {
    display: grid;
    gap: 8px;
    justify-items: end;
}
.status-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.status-bar {
    height: 10px;
    background: #ede7db;
    border-radius: 999px;
    overflow: hidden;
}
.status-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-2), #85c7ba);
}
.empty-state {
    padding: 20px 0 8px;
    color: var(--muted);
}
.setting-card label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.settings-grid.single-column .textarea { min-height: 220px; }

@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
    .dashboard-hero, .insights-grid, .charts-grid, .details-grid, .settings-grid { grid-template-columns: 1fr; }
}
