:root {
    --bg: #f5f6f8;
    --card: #ffffff;
    --ink: #1c2430;
    --muted: #6b7684;
    --line: #e4e8ee;
    --brand: #14532d;
    --brand-2: #1f7a45;
    --accent: #b98a00;
    --danger: #b3261e;
    --ok: #1e7a3d;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(20, 30, 45, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Sidebar layout ---- */
:root { --sidebar-w: 224px; }
.nav-toggle { display: none; }          /* mobile menu checkbox (hidden) */

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

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
    background: var(--brand); color: #d7e6dc;
    display: flex; flex-direction: column;
    overflow-y: auto; z-index: 20;
}
.side-brand { padding: 18px 20px; flex: none; }
.side-brand a { color: #fff; font-weight: 700; font-size: 20px; letter-spacing: .5px; }
.side-brand a:hover { text-decoration: none; }
.side-logo { max-width: 168px; max-height: 46px; display: block; }

/* Branding settings preview + colour pickers */
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 44px; height: 38px; padding: 2px; cursor: pointer; }
.color-row input[type=text] { flex: 1; }
.brand-preview {
    background: var(--brand); border-radius: 10px; height: 90px;
    display: flex; align-items: center; padding: 0 20px;
}
.brand-preview .preview-name { color: #fff; font-weight: 700; font-size: 20px; letter-spacing: .5px; }
.brand-preview .preview-logo { max-height: 52px; max-width: 220px; }

.side-nav { flex: 1; padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 1px; }
.nav-group {
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: rgba(215,230,220,.55); margin: 16px 10px 4px;
}
.nav-item {
    display: block; color: #d7e6dc; font-weight: 500; font-size: 14px;
    padding: 8px 12px; border-radius: 7px; line-height: 1.2;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,.16); color: #fff; }

.side-foot { flex: none; padding: 10px; border-top: 1px solid rgba(255,255,255,.12); }
.side-foot form { margin: 0; }
.nav-logout {
    width: 100%; text-align: left; background: none; border: none; cursor: pointer;
    font: inherit;
}

.main { margin-left: var(--sidebar-w); }
.mobile-bar { display: none; }

/* Mobile: collapsible sidebar */
@media (max-width: 820px) {
    .main { margin-left: 0; }
    .mobile-bar {
        display: flex; align-items: center; gap: 14px;
        background: var(--brand); color: #fff; height: 52px; padding: 0 16px;
        position: sticky; top: 0; z-index: 15;
    }
    .hamburger { font-size: 22px; cursor: pointer; line-height: 1; }
    .mobile-title { font-weight: 700; font-size: 17px; }
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 2px 0 12px rgba(0,0,0,.2); }
    .nav-toggle:checked ~ .app-shell .sidebar { transform: translateX(0); }
}

.row-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }

/* Checklist run + radios */
.checklist-run .result-cell { white-space: nowrap; }
label.radio { display: inline-flex; flex-direction: row; align-items: center; gap: 4px; margin: 0 10px 0 0; color: var(--ink); font-size: 13px; }
label.radio input { width: auto; }

/* Ask BOS */
.ask-form { display: flex; gap: 8px; }
.ask-form input[type=text] { flex: 1; font-size: 15px; padding: 10px 12px; }
.examples { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.examples .chip { background: #eef2f5; color: var(--ink); cursor: pointer; text-decoration: none; }
.examples .chip:hover { background: #e0e7ec; text-decoration: none; }
.answer-card .answer-head { display: flex; gap: 6px; margin-bottom: 10px; }
.answer-text { font-size: 17px; line-height: 1.5; margin: 0 0 12px; }
.data-dump { background: #f5f6f8; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 12px; overflow-x: auto; }
.answer-note { font-size: 12px; margin-top: 12px; }

/* SOP accordion */
details.sop { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; }
details.sop summary { cursor: pointer; display: flex; align-items: center; gap: 8px; }
.sop-body { padding: 10px 4px 4px; font-size: 14px; color: var(--ink); }

.container { max-width: 1200px; margin: 0 auto; padding: 28px 32px; }
@media (max-width: 820px) { .container { padding: 20px 16px; } }
.footer { text-align: center; color: var(--muted); padding: 24px; font-size: 13px; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; margin: 0; }

/* Cards */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 20px; margin-bottom: 20px;
}
.card h2 { font-size: 16px; margin: 0 0 12px; }
.card h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* KPIs */
.kpi-grid {
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 20px;
}
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
}
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 20px; font-weight: 700; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.strong td { font-weight: 700; border-top: 2px solid var(--line); }
.badge { background: #eef2f5; color: var(--muted); padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #eaf3ec; color: var(--brand); padding: 2px 6px 2px 10px; border-radius: 999px; font-size: 12px; margin: 2px 4px 2px 0; }
.chip-x { display: inline; margin: 0; }
.chip-x button { background: none; border: none; color: var(--brand-2); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.chip-x button:hover { color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Charts */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap.chart-sm { height: 240px; }

/* Alerts panel */
.badge-warn { background: #fdefd0; color: var(--accent); }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-item { display: flex; align-items: baseline; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.alert-item:last-child { border-bottom: none; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; transform: translateY(-1px); }
.sev-warning .alert-dot { background: var(--accent); }
.sev-critical .alert-dot { background: var(--danger); }
.alert-msg { flex: 1; font-size: 13px; }
.alert-time { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Forms */
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
input, select, textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; background: #fff; color: var(--ink); font-family: inherit; }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 16px; align-items: end; }
.form-grid button { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.form-row { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
.inline { display: inline-flex; gap: 8px; align-items: center; }

.btn { padding: 8px 14px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: 14px; }
.btn:hover { border-color: var(--brand-2); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c2; }
.alert-ok { background: #e9f6ee; color: var(--ok); border: 1px solid #bfe4cd; }
.muted { color: var(--muted); }

/* Auth */
.centered { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { width: 340px; text-align: center; }
.auth-card h1 { color: var(--brand); margin: 0 0 4px; }
.auth-card form { text-align: left; margin-top: 16px; }
.auth-card label { color: var(--ink); }
.auth-card .btn-primary { width: 100%; margin-top: 8px; }
