:root {
    --bg: #f3f0e8;
    --card: #fffcf7;
    --ink: #1c1917;
    --muted: #78716c;
    --line: #e6e0d6;
    --sidebar: #12211e;
    --sidebar-text: #d6e4df;
    --accent: #0f6e56;
    --accent-2: #146c54;
    --gold: #9a6700;
    --shadow: 0 16px 40px rgba(28, 25, 23, .06);
    --radius: 18px;
}

[data-bs-theme="dark"] {
    --bg: #101614;
    --card: #18211e;
    --ink: #f5f5f4;
    --muted: #a8a29e;
    --line: #2c3834;
    --shadow: 0 16px 40px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Plus Jakarta Sans", sans-serif;
    background: var(--bg);
    color: var(--ink);
}

a { color: inherit; }

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

.sidebar {
    width: 268px;
    background: var(--sidebar);
    color: var(--sidebar-text);
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 4px 8px 18px;
    text-decoration: none;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #1f6f59;
    color: white;
    font-weight: 700;
}

.brand small { display: block; color: #93b0a8; font-size: 12px; }

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
}

.nav-link-item.active,
.nav-link-item:hover { background: rgba(255,255,255,.08); color: white; }

.sidebar-foot { margin-top: auto; padding: 12px; color: #93b0a8; font-size: 12px; }

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

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 28px;
}

.icon-btn, .menu-toggle {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    border-radius: 12px;
    width: 40px;
    height: 40px;
}

.content { padding: 0 28px 40px; }

.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 18px; }
.page-head h1 { font-size: 28px; margin: 0; letter-spacing: -.03em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.stat-grid, .chart-grid { display: grid; gap: 14px; }
.stat-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.chart-grid { grid-template-columns: 1.4fr .8fr; margin-bottom: 14px; }

.card-block {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.stat-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.04em; margin-top: 6px; }
.stat-note { color: var(--gold); font-size: 12px; font-weight: 600; margin-top: 4px; }

.table { --bs-table-bg: transparent; color: var(--ink); }
.table thead th { color: var(--muted); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; font-weight: 700; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select,
.form-control, .form-select {
    background: var(--card);
    color: var(--ink);
    border-color: var(--line);
    border-radius: 12px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    text-transform: capitalize;
}
.tone-success { background: #dcfce7; color: #166534; }
.tone-warning { background: #fef3c7; color: #92400e; }
.tone-danger { background: #fee2e2; color: #991b1b; }
.tone-secondary { background: #e7e5e4; color: #44403c; }
[data-bs-theme="dark"] .tone-success { background: #14532d; color: #bbf7d0; }
[data-bs-theme="dark"] .tone-warning { background: #78350f; color: #fde68a; }
[data-bs-theme="dark"] .tone-danger { background: #7f1d1d; color: #fecaca; }
[data-bs-theme="dark"] .tone-secondary { background: #44403c; color: #e7e5e4; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.filters .form-control, .filters .form-select { width: auto; min-width: 160px; }

.btn-accent { background: var(--accent); border-color: var(--accent); color: white; border-radius: 12px; }
.btn-accent:hover { background: var(--accent-2); color: white; }

.modal-content { background: var(--card); color: var(--ink); border-radius: 20px; }
.secret-box { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.guide-stack { display: grid; gap: 14px; }
.guide-stack h2 { font-size: 18px; margin: 0 0 8px; letter-spacing: -.02em; }
.guide-stack p:last-child, .guide-stack ol:last-child { margin-bottom: 0; }
.field-name { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.guide-code {
    background: #12211e;
    color: #e7f5ef;
    border-radius: 14px;
    padding: 16px;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
    margin: 12px 0 0;
    white-space: pre;
}

.guest-shell { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
.guest-story { background: #12211e; color: white; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.guest-story h1 { font-size: 56px; letter-spacing: -.05em; line-height: .95; max-width: 640px; }
.guest-form { display: grid; place-items: center; padding: 32px; }
.login-card { width: min(440px, 100%); }

.home-wrap { max-width: 1120px; margin: 0 auto; padding: 28px; }
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 32px; align-items: center; padding: 36px 0 20px; }
.hero h1 { font-size: 64px; letter-spacing: -.06em; line-height: .92; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0 40px; }

@media (max-width: 1100px) {
    .stat-grid, .steps { grid-template-columns: 1fr 1fr; }
    .chart-grid, .hero, .guest-shell { grid-template-columns: 1fr; }
    .guest-story { display: none; }
    .sidebar { position: fixed; z-index: 20; transform: translateX(-105%); transition: .2s ease; }
    .sidebar.open { transform: none; }
}
