:root {
    --bg: #f5f7fb;
    --surface: rgba(255, 255, 255, .82);
    --surface-strong: #ffffff;
    --text: #111827;
    --muted: #64748b;
    --line: rgba(15, 23, 42, .08);
    --accent: #0f766e;
    --accent-2: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 20px 50px rgba(15, 23, 42, .08);
}

[data-bs-theme="dark"] {
    --bg: #0b1120;
    --surface: rgba(17, 24, 39, .82);
    --surface-strong: #111827;
    --text: #f8fafc;
    --muted: #94a3b8;
    --line: rgba(148, 163, 184, .18);
    --shadow: 0 20px 50px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(16, 185, 129, .10), transparent 32rem),
        radial-gradient(circle at top right, rgba(37, 99, 235, .10), transparent 28rem),
        var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    transition: background-color .2s ease, color .2s ease;
}

a { color: inherit; text-decoration: none; }

.app-shell {
    width: min(1180px, 100%);
    margin: 0 auto;
    min-height: 100vh;
    padding-bottom: 92px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: max(16px, env(safe-area-inset-top)) 18px 12px;
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
}

.topbar h1 {
    margin: 0;
    font-size: clamp(1.22rem, 4vw, 1.85rem);
    font-weight: 760;
    letter-spacing: 0;
}

.eyebrow {
    color: var(--muted);
    font-size: .72rem;
    text-transform: uppercase;
    font-weight: 700;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content-wrap {
    padding: 18px;
}

.card-soft {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.metric-card {
    padding: 16px;
    min-height: 132px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.metric-card.primary {
    grid-column: 1 / -1;
    color: #fff;
    background: linear-gradient(135deg, #111827, #0f766e);
}

.metric-label {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.primary .metric-label { color: rgba(255,255,255,.74); }

.metric-value {
    margin-top: 8px;
    font-weight: 800;
    font-size: clamp(1.42rem, 7vw, 2.45rem);
    line-height: 1.05;
}

.metric-note {
    color: var(--muted);
    font-size: .86rem;
}

.primary .metric-note { color: rgba(255,255,255,.78); }

.section-title {
    margin: 28px 0 12px;
    font-size: 1rem;
    font-weight: 760;
}

.chart-panel, .form-panel, .table-panel {
    padding: 16px;
}

.chart-box {
    position: relative;
    height: 260px;
}

.log-list { display: grid; gap: 10px; }

.log-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
}

.log-row strong { display: block; font-size: .96rem; }
.muted { color: var(--muted); }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    background: color-mix(in srgb, var(--surface-strong) 72%, transparent);
}

.icon-btn, .avatar-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    background: var(--surface);
    font-weight: 800;
}

.fab {
    position: fixed;
    right: 20px;
    bottom: 86px;
    z-index: 25;
    width: 58px;
    height: 58px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 18px 38px rgba(15, 118, 110, .34);
    font-size: 1.35rem;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    z-index: 24;
    width: min(460px, calc(100% - 28px));
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 28px;
    background: color-mix(in srgb, var(--surface-strong) 86%, transparent);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 0;
    padding: 7px 4px;
    border-radius: 20px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
}

.bottom-nav a.active {
    color: var(--text);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.form-control, .form-select {
    border-radius: 8px;
    min-height: 48px;
    border-color: var(--line);
    background-color: var(--surface-strong);
    color: var(--text);
}

.btn {
    min-height: 46px;
    border-radius: 8px;
    font-weight: 760;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: 0;
}

.quick-input {
    font-size: 1.12rem;
    font-weight: 700;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.preview-item {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface-strong) 70%, transparent);
}

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    border-color: var(--line);
}

.table td, .table th { vertical-align: middle; }

.toast-card {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--success) 15%, var(--surface-strong));
    border: 1px solid color-mix(in srgb, var(--success) 24%, transparent);
}

.auth-wrap {
    min-height: calc(100vh - 120px);
    display: grid;
    align-items: center;
}

.auth-card {
    width: min(420px, 100%);
    margin: 0 auto;
    padding: 24px;
}

@media (min-width: 768px) {
    .content-wrap { padding: 28px; }
    .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .metric-card.primary { grid-column: span 2; }
    .dashboard-grid {
        display: grid;
        grid-template-columns: 1.45fr .95fr;
        gap: 18px;
        align-items: start;
    }
    .fab { right: calc((100vw - min(1180px, 100vw)) / 2 + 28px); }
}
