:root {
    color-scheme: light;
    --bg: #f5f6f8;
    --card: #ffffff;
    --border: #dde1e6;
    --text: #1f2430;
    --muted: #6b7280;
    --active: #1c7d3f;
    --active-bg: #e4f6ea;
    --expired: #b3261e;
    --expired-bg: #fbe9e7;
    --revoked: #6b7280;
    --revoked-bg: #eceff1;
    --none-bg: #eef1f5;
    --accent: #2563eb;
    --danger: #b3261e;
    --warn: #8a5a00;
    --warn-bg: #fff4d6;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

header {
    padding: 1.25rem 2rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 { font-size: 1.1rem; margin: 0; }
header a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
header a:hover { text-decoration: underline; }

main { max-width: 1300px; margin: 2rem auto; padding: 0 1.5rem; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge.active  { color: var(--active);  background: var(--active-bg); }
.badge.expired { color: var(--expired); background: var(--expired-bg); }
.badge.revoked { color: var(--revoked); background: var(--revoked-bg); }
.badge.none    { color: var(--muted);   background: var(--none-bg); }

code { font-size: 0.82rem; background: var(--none-bg); padding: 0.1rem 0.35rem; border-radius: 4px; }

details summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; }
details { margin-top: 0.4rem; }

form.inline { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; align-items: center; }
form.inline input[type=text], form.inline input[type=date] {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
}

button, input[type=submit] {
    padding: 0.4rem 0.9rem;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
}
button.danger { background: var(--danger); }
button:hover, input[type=submit]:hover { opacity: 0.9; }

.flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash.ok { background: var(--active-bg); color: var(--active); }
.flash.error { background: var(--expired-bg); color: var(--expired); }

.login-box { max-width: 360px; margin: 4rem auto; }
.login-box input[type=password] {
    width: 100%; padding: 0.6rem; margin: 0.75rem 0; border: 1px solid var(--border); border-radius: 6px;
}
.login-box button { width: 100%; padding: 0.6rem; }

.muted { color: var(--muted); font-size: 0.85rem; }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

.stats { line-height: 1.55; white-space: nowrap; }
.stats strong { font-variant-numeric: tabular-nums; }

button.link {
    background: none;
    color: var(--accent);
    padding: 0;
    margin-top: 0.35rem;
    font-size: 0.85rem;
}
button.link:hover { text-decoration: underline; opacity: 1; }

tr.expanded > td { border-bottom-color: transparent; }
tr.detail-row > td { padding: 0 0.5rem 1rem; background: var(--card); }

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.tile {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
}
.tile h3 {
    margin: 0 0 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}
.tile dl {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.35rem 1rem;
    margin: 0;
    font-size: 0.85rem;
}
.tile dt { color: var(--muted); white-space: nowrap; }
.tile dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .alarm-text {
    margin: 0.6rem 0 0;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--muted);
}

.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.chip.on  { color: var(--active); background: var(--active-bg); }
.chip.on::before  { content: "✓ "; }
.chip.off { color: var(--muted); background: var(--none-bg); text-decoration: line-through; font-weight: 400; }
