:root {
    --ink: #1d2733;
    --muted: #5f6b7a;
    --line: #d9dee5;
    --bg: #f5f7fa;
    --panel: #ffffff;
    --brand: #1f4e79;
    --brand-ink: #ffffff;
    --section: #e8eef5;
    --ok-bg: #c6efce; --ok: #006100;
    --watch-bg: #ffeb9c; --watch: #9c6500;
    --risk-bg: #ffc7ce; --risk: #9c0006;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif; color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }

.topbar { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; justify-content: space-between; padding: .6rem 1rem; background: var(--brand); color: var(--brand-ink); }
.topbar a, .topbar .linklike { color: var(--brand-ink); }
.brand a { font-weight: 600; text-decoration: none; font-size: 1.05rem; }
.site-name { margin-left: .75rem; padding-left: .75rem; border-left: 1px solid rgba(255,255,255,.4); }
.usernav { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; font-size: .9rem; }
.usernav .who { opacity: .8; }
.switcher { position: relative; }
.switcher summary { cursor: pointer; }
.switcher ul { position: absolute; right: 0; z-index: 5; list-style: none; margin: .3rem 0 0; padding: .3rem 0; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; min-width: 14rem; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.switcher li a { display: block; padding: .35rem .8rem; color: var(--ink); text-decoration: none; }
.switcher li a:hover { background: var(--bg); }

.page { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

form.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }
button, .button { display: inline-block; background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 4px; padding: .5rem 1rem; font: inherit; cursor: pointer; text-decoration: none; }
button.small { padding: .25rem .6rem; font-size: .82rem; }
button.danger { background: #a4262c; }
input[type=email], input[type=password], input[type=text] { display: block; width: 100%; max-width: 26rem; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 4px; font: inherit; margin-top: .2rem; }
.stack { display: flex; flex-direction: column; gap: .6rem; }
.check { display: inline-flex; gap: .35rem; align-items: center; margin-right: .8rem; }
fieldset { border: 1px solid var(--line); border-radius: 4px; padding: .5rem .8rem; }
.field-error, .validation-message { color: var(--risk); font-size: .85rem; }

.account { max-width: 30rem; margin: 2rem auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1.5rem; }
.notice { padding: .6rem .8rem; border-radius: 4px; margin: .5rem 0 1rem; }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.notice-error { background: var(--risk-bg); color: var(--risk); }

.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: .8rem; }
.card { display: flex; flex-direction: column; gap: .2rem; padding: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--ink); }
.card span { color: var(--muted); font-size: .85rem; }

.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1.25rem; margin-bottom: 1.5rem; }
.kpi-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.subtitle { margin: 0; color: var(--muted); }
.asof { background: #fff8e1; border: 1px solid #f0d58c; border-radius: 4px; padding: .5rem .75rem; margin: 1rem 0; font-size: .9rem; }

table { border-collapse: collapse; width: 100%; }
.dashboard, .grid { background: var(--panel); margin-top: .75rem; }
.dashboard th, .dashboard td, .grid th, .grid td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.dashboard thead th, .grid thead th { background: var(--brand); color: var(--brand-ink); font-weight: 600; font-size: .88rem; }
.dashboard .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dashboard tr.section td { background: var(--section); font-weight: 600; font-size: .82rem; letter-spacing: .03em; }
.grid tr.flag td { background: #fff4f4; }
.grid td.actions { white-space: nowrap; }
.grid td.actions form { display: inline-block; margin: 0 .25rem .25rem 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: .2rem .4rem; align-items: center; }

.status { display: inline-block; min-width: 3.5rem; text-align: center; padding: .1rem .5rem; border-radius: 3px; font-size: .85rem; font-weight: 600; }
.status-ok { background: var(--ok-bg); color: var(--ok); }
.status-watch { background: var(--watch-bg); color: var(--watch); }
.status-risk { background: var(--risk-bg); color: var(--risk); }
.status-none { color: var(--muted); font-weight: 400; }
.tag { display: inline-block; font-size: .75rem; padding: .05rem .45rem; border-radius: 3px; background: var(--section); color: var(--brand); margin-top: .2rem; }
.tag-on { background: var(--ok-bg); color: var(--ok); }
.tag-off { background: #eceff3; color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .75rem 1rem; margin: 1rem 0; }
.panel summary { cursor: pointer; font-weight: 600; }

@media (max-width: 640px) {
    .dashboard th:nth-child(5), .dashboard td:nth-child(5) { display: none; }
    .grid { display: block; overflow-x: auto; }
}

@media print {
    .topbar, .foot, .button, .asof + table + p { display: none; }
    body { background: #fff; }
    .kpi { border: 0; padding: 0; }
}
