:root {
    --bg: #0f1220;
    --panel: #171b2e;
    --text: #e7e9f3;
    --muted: #9aa0b5;
    --accent: #2d6fff;
    --border: #262b42;
    --input-bg: #0d1020;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.site-nav a { margin-left: 1.25rem; color: var(--muted); }
.site-nav a:hover { color: var(--text); }

.container { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; }

.hero { padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: 2rem; margin: 0 0 .5rem; }
.lead { font-size: 1.15rem; color: var(--muted); }

.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.app-card { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; color: var(--text); }
.app-card:hover { text-decoration: none; border-color: var(--accent); }
.app-card h3 { margin: 0 0 .35rem; }
.app-card p { margin: 0 0 .7rem; font-size: .92rem; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-top: 1.5rem;
}

.muted { color: var(--muted); }

.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: .6rem 1.1rem;
    border-radius: var(--radius);
    font-weight: 600;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }

.flash {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}
.flash-notice { background: #16351f; border-color: #24713a; }
.flash-error { background: #3a1620; border-color: #7a2338; }

.site-footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    text-align: center;
    padding: 1.5rem;
    font-size: .9rem;
}

/* Forms & auth */
.auth-card { max-width: 440px; margin: 1rem auto; }
.auth-card h1 { margin-top: 0; }
.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .9rem; }
.field input[type=text],
.field input[type=email],
.field input[type=password] {
    width: 100%;
    padding: .6rem .7rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    font-size: 1rem;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.btn.secondary { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.linkbtn { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { color: var(--text); text-decoration: underline; }
form.inline { display: inline; margin-left: 1.25rem; }
.divider { text-align: center; color: var(--muted); margin: 1.25rem 0; font-size: .85rem; }
.help { color: var(--muted); font-size: .9rem; }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 6px; font-size: .75rem; border: 1px solid var(--border); vertical-align: middle; }
.badge.warn { background: #3a2a16; border-color: #7a5a23; color: #e9c07a; }
.badge.ok { background: #16351f; border-color: #24713a; color: #7fd39b; }
.panel h2 { margin-top: 0; }

/* Admin */
body.admin .admin-shell { display: flex; min-height: calc(100vh - var(--mav-nav-h, 46px)); }
.admin-nav { width: 200px; border-right: 1px solid var(--border); padding: 1.25rem .75rem; flex-shrink: 0; }
.admin-nav a { display: block; padding: .5rem .75rem; border-radius: 8px; color: var(--muted); }
.admin-nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.admin-nav a.active { background: var(--accent); color: #fff; }
.admin-nav a { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.nav-count { background: #d24b32; color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .72rem; line-height: 1.5; min-width: 1.25rem; text-align: center; font-weight: 700; }
.admin-nav a.active .nav-count { background: #fff; color: var(--accent); }
.contacts-list tr.unread td { font-weight: 700; }
.contacts-list tr.unread td .help { font-weight: 400; }
.table tr.dev-row td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.stat-cards { display: flex; flex-wrap: wrap; gap: .75rem; }
.stat-card { flex: 1 1 130px; border: 1px solid var(--border); border-radius: 10px; padding: .8rem 1rem; }
.stat-num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-lbl { color: var(--muted); font-size: .82rem; margin-top: .15rem; }
.badge.info { background: #16263a; border-color: #24557a; color: #7fbfe0; }
:root[data-theme="light"] .badge.info { background: #e5eef7; border-color: #86b3d0; color: #185a86; }
.admin-main { flex: 1; padding: 1.5rem 2rem; max-width: 1000px; }
.admin-main h1 { margin-top: 0; }

.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.table.kv th { width: 160px; color: var(--muted); font-weight: 600; }
.table code { font-size: .85rem; }
.nowrap { white-space: nowrap; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { text-align: center; }
.stat .num { font-size: 2rem; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }

.toolbar { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.toolbar input[type=search] { padding: .5rem .7rem; border-radius: 8px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text); min-width: 260px; }

.action-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.action-row form { display: inline; }
.inline-form { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.inline-form label { display: flex; flex-direction: column; gap: .25rem; color: var(--muted); font-size: .85rem; }
.inline-form label.chk { flex-direction: row; align-items: center; gap: .35rem; color: var(--text); }
.inline-form input[type=text], .inline-form input[type=number], .inline-form input[type=date], .inline-form select {
    padding: .5rem .6rem; border-radius: 8px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
}
textarea { width: 100%; padding: .6rem .7rem; border-radius: 8px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text); font: inherit; }
.field select, .field textarea { width: 100%; }
.field select { padding: .5rem .6rem; border-radius: 8px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text); }
.btn.danger { background: #7a2338; }
.linkbtn.danger { color: #e58; }

@media (max-width: 720px) {
    body.admin .admin-shell { flex-direction: column; }
    .admin-nav { width: auto; display: flex; gap: .25rem; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--border); }
}

/* ── Light mode (driven by the universal bar's theme toggle → html[data-theme]) ── */
:root { color-scheme: dark; }
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f6fa;
    --panel: #ffffff;
    --text: #1a1f28;
    --muted: #5c6675;
    --accent: #2d6fff;
    --border: #dce1ea;
    --input-bg: #ffffff;
}
:root[data-theme="light"] .flash-notice { background: #e5f5ea; border-color: #7bc99a; color: #14421f; }
:root[data-theme="light"] .flash-error  { background: #fbe4ea; border-color: #e08ea0; color: #7a1226; }
:root[data-theme="light"] .badge.warn   { background: #fdf1dc; border-color: #e5c98c; color: #6f5216; }
:root[data-theme="light"] .badge.ok     { background: #e5f5ea; border-color: #86cfa0; color: #196b39; }

/* ── Landing pages ────────────────────────────────────────────────────────── */
.lp { max-width: 860px; margin: 0 auto; }
.lp section { padding: 2.4rem 0; border-bottom: 1px solid var(--border); }
.lp section:last-child { border-bottom: 0; }
.lp h2 { font-size: 1.5rem; margin: 0 0 .8rem; }
.lp p { margin: 0 0 .9rem; }

.lp-hero { text-align: center; padding-top: 3rem !important; }
.lp-eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; color: var(--muted); margin-bottom: .5rem; }
.lp-hero h1 { font-size: clamp(2.1rem, 6vw, 3.2rem); line-height: 1.1; margin: 0 0 .7rem; }
.lp-hl { color: var(--accent); }
.lp-lead { font-size: 1.15rem; color: var(--muted); max-width: 34rem; margin: 0 auto 1.6rem; }
.lp-lead strong { color: var(--text); }
.lp-cta { display: flex; flex-direction: column; align-items: center; gap: .7rem; }
.lp-btn {
    display: inline-block; background: var(--accent); color: #fff; font-weight: 700;
    padding: .85rem 1.8rem; border-radius: 999px; font-size: 1.05rem;
}
.lp-btn:hover { text-decoration: none; filter: brightness(1.1); }
.lp-trust { color: var(--muted); font-size: .85rem; }

.lp-band { background: var(--panel); border-radius: var(--radius); padding: 2rem 1.8rem !important; border: 1px solid var(--border); margin: 1.6rem 0; }
.lp-band h2 { margin-top: 0; }

.lp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .9rem; }
.lp-grid-3 { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.lp-card {
    display: flex; flex-direction: column; gap: .15rem;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.1rem; color: var(--text);
}
.lp-card:hover { text-decoration: none; border-color: var(--accent); }
.lp-size { font-size: 1.5rem; font-weight: 800; color: var(--accent); line-height: 1.1; }
.lp-card .muted, .lp-feat p { color: var(--muted); font-size: .88rem; margin: 0; }

.lp-feat { border-left: 2px solid var(--border); padding-left: .9rem; }
.lp-feat strong { display: block; margin-bottom: .2rem; }

.lp-steps { padding-left: 1.1rem; margin: 0 0 1rem; }
.lp-steps li { margin-bottom: .7rem; }

.lp-faq details {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: .8rem 1rem; margin-bottom: .55rem; background: var(--bg);
}
.lp-faq summary { cursor: pointer; font-weight: 600; }
.lp-faq details[open] summary { margin-bottom: .5rem; }
.lp-faq p { margin: 0; color: var(--muted); }

.lp-final { text-align: center; }
.lp-final h2 { margin-bottom: 1.1rem; }
.lp-final .muted { color: var(--muted); font-size: .88rem; margin-top: .9rem; }

/* Homepage copy pulled from the /home and /homebottom CMS pages. */
.hero h1 { margin-bottom: .5rem; }
.hero p:last-child { margin-bottom: 0; }
.home-bottom {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .95rem;
}
.home-bottom p:last-child { margin-bottom: 0; }

.site-footer .footer-links { margin: .35rem 0 0; display: flex; gap: 1.1rem; justify-content: center; }
.site-footer .footer-links a { color: var(--muted); }
.site-footer .footer-links a:hover { color: var(--text); }

/* Raw project data view (/account/projects/{id}) */
.datadump {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    max-height: 32rem;
    overflow-y: auto;
    font-size: .82rem;
    line-height: 1.45;
    margin: 0;
}
.datadump code { white-space: pre; }
