/* SabiMetric design system — light theme (default) with a dark toggle.
   Sidebar chrome stays a constant deep teal in both modes; content-area
   tokens below are the ones that flip. */

:root {
    --bg: #f9f7f2;
    --surface: #ffffff;
    --surface-2: #f2efe7;
    --border: #e7e2d8;
    --text: #1f2a24;
    --text-muted: #6b7268;
    --primary: #0f6e5f;
    --primary-hover: #0c5a4e;
    --primary-soft: #e3f0ec;
    --accent: #d98e28;
    --accent-hover: #bd7d1f;
    --accent-soft: #fbeed9;
    --success: #1e8e5a;
    --success-soft: #e3f3ea;
    --danger: #c0392b;
    --danger-soft: #fbe6e3;
    --info: #2e86ab;
    --info-soft: #e4f0f5;
    --shadow: 0 1px 3px rgba(31, 42, 36, 0.08), 0 1px 2px rgba(31, 42, 36, 0.06);
    --shadow-lg: 0 12px 24px rgba(31, 42, 36, 0.12);
    --sidebar-bg: #0b3d33;
    --sidebar-bg-active: #0f6e5f;
    --sidebar-text: #e7f3ef;
    --sidebar-text-muted: #9fc3b8;
    --radius: 10px;
}

:root[data-theme="dark"] {
    --bg: #10201c;
    --surface: #16302a;
    --surface-2: #1d3b33;
    --border: #2a473e;
    --text: #e7f3ef;
    --text-muted: #9fc3b8;
    --primary: #2fa98c;
    --primary-hover: #3dbe9e;
    --primary-soft: #1c3b34;
    --accent: #e3a64a;
    --accent-hover: #edb868;
    --accent-soft: #3a2f1c;
    --success: #3dbe9e;
    --success-soft: #163a2e;
    --danger: #e0665a;
    --danger-soft: #3a201d;
    --info: #5fb2d6;
    --info-soft: #17323d;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
p { line-height: 1.6; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .65rem 1.3rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    font-size: .95rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-accent { background: var(--accent); color: #241a06; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: .4rem .85rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.link-btn { background: none; border: none; padding: 0; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }

/* ---------- App shell (authenticated pages) ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: left .2s ease;
}
.sidebar-brand {
    padding: 1.4rem 1.5rem;
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: .02em;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand span { color: var(--accent); }
.sidebar-nav { flex: 1; padding: 1.25rem .9rem; overflow-y: auto; }
.sidebar-section { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-text-muted); padding: 0 .6rem; margin: 0 0 .6rem; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .8rem;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    margin-bottom: .25rem;
    font-size: .95rem;
    font-weight: 500;
    transition: background-color .15s ease;
}
.sidebar-link:hover { background: rgba(255,255,255,.08); }
.sidebar-link.active { background: var(--sidebar-bg-active); font-weight: 700; }
.sidebar-icon { width: 1.1rem; text-align: center; flex-shrink: 0; }
.sidebar-footer { padding: 1rem .9rem 1.4rem; border-top: 1px solid rgba(255,255,255,.08); }

.main-content { margin-left: 260px; width: calc(100% - 260px); }
.topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 90;
}
.content { padding: 2rem clamp(1rem, 4vw, 2.5rem); max-width: 1200px; }

.sidebar-toggle-btn { background: none; border: none; font-size: 1.3rem; color: var(--text); cursor: pointer; }

@media (max-width: 991px) {
    .sidebar { left: -260px; }
    .sidebar.show { left: 0; }
    .main-content { margin-left: 0; width: 100%; }
    .topbar { display: flex; }
    .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 95; }
    .sidebar-backdrop.show { display: block; }
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    color: var(--sidebar-text);
    border-radius: 999px;
    padding: .4rem .7rem;
    font-size: .82rem;
    cursor: pointer;
    width: 100%;
    justify-content: center;
}
.theme-toggle:hover { background: rgba(255,255,255,.14); }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card-flush { padding: 0; overflow: hidden; }
.card-header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.3rem; }
.stat-card.accent { border-left-color: var(--accent); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.info { border-left-color: var(--info); }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-bottom: .3rem; }
.stat-value { font-size: 1.9rem; font-weight: 800; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .25rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--accent-soft); color: var(--accent-hover); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem .6rem; border-bottom: 1px solid var(--border); font-size: .92rem; }
th { color: var(--text-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--surface-2); }
.text-positive { color: var(--success); font-weight: 700; }
.text-negative { color: var(--danger); font-weight: 700; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .9rem; }
.help-text { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"],
textarea, select {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.field { margin-bottom: 1.1rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.checkbox-field { display: flex; align-items: center; gap: .5rem; }
.checkbox-field input { width: auto; }
ul.errorlist { list-style: none; padding: 0; margin: .3rem 0 0; color: var(--danger); font-size: .82rem; }

/* ---------- Alerts / messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.messages li { background: var(--info-soft); color: var(--info); padding: .7rem 1rem; border-radius: 8px; margin-bottom: .5rem; font-size: .9rem; }

/* ---------- Progress ---------- */
.progress-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 999px; }

/* ---------- Auth pages ---------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 2.2rem; }
.auth-logo { text-align: center; font-size: 1.4rem; font-weight: 800; margin-bottom: 1.6rem; }
.auth-logo span { color: var(--accent); }
.auth-foot { text-align: center; margin-top: 1.2rem; font-size: .9rem; color: var(--text-muted); }
.role-toggle { display: flex; gap: .6rem; margin-bottom: 1.1rem; }
.role-option { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: .7rem; text-align: center; cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.role-option input { display: none; }
.role-option.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ---------- Public landing (kept minimal) ---------- */
.hero { text-align: center; padding: 4rem 1rem; }
.hero h1 { font-size: 2.4rem; }
.hero p { color: var(--text-muted); font-size: 1.1rem; max-width: 640px; margin: 0 auto 1.5rem; }
.public-nav { display: flex; align-items: center; justify-content: space-between; padding: 1rem 2rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.public-nav a.brand { font-weight: 800; font-size: 1.2rem; text-decoration: none; color: var(--text); }
.public-nav a.brand span { color: var(--accent); }
.public-nav nav a { margin-left: 1.25rem; text-decoration: none; color: var(--text); font-size: .95rem; }

/* ---------- Wizard steps ---------- */
.step-card { border-left: 4px solid var(--border); }
.step-card.step-active { border-left-color: var(--accent); }
.step-badge { display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); color: #241a06; font-weight: 800; font-size: .85rem; margin-right: .6rem; }
.question-row { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: .8rem; }
.question-row .field-row { align-items: end; }

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); }
.mt-1 { margin-top: 1rem; } .mb-1 { margin-bottom: 1rem; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 2rem 0 1rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.share-box { display: flex; gap: .6rem; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .7rem 1rem; font-size: .85rem; word-break: break-all; }
