/* Community library owner dashboard.
   Cool paper ground, ink-navy rail, one accent (library-binding green); stamp red only
   for what needs attention. Serif for headings and figures, system sans for the rest. */

:root {
    --paper: #f3f6f4;
    --surface: #ffffff;
    --ink: #1c2738;
    --ink-2: #33415a;
    --muted: #5f6b7a;
    --rule: #dbe2dd;
    --accent: #2e6b4e;
    --accent-soft: #dcebe2;
    --alert: #b3362b;
    --alert-soft: #f7e2df;
    --rail: #1c2738;
    --rail-ink: #c9d2df;

    --serif: Charter, "Bitstream Charter", "Iowan Old Style", "Sitka Text", Cambria, Georgia, serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
    --radius: 6px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    background: var(--paper);
    color: var(--ink);
    font: 15px/1.5 var(--sans);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: var(--serif); font-weight: 600; color: var(--ink); margin: 0; }
h1 { font-size: 2rem; line-height: 1.15; letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; line-height: 1.3; }

a { color: var(--accent); }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.muted { color: var(--muted); }
.block { display: block; }
.strong { font-weight: 600; }

/* ---------- shell ---------- */

.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }

.rail {
    background: var(--rail);
    color: var(--rail-ink);
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--s5) var(--s3);
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex; align-items: center; gap: var(--s3);
    color: #fff; text-decoration: none;
    font-family: var(--serif); font-size: 1.05rem; font-weight: 600;
    padding: 0 var(--s2) var(--s5);
}

.nav {
    display: flex; align-items: center; gap: var(--s3);
    padding: 9px var(--s3);
    border-radius: var(--radius);
    color: var(--rail-ink);
    text-decoration: none;
}
.nav:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav.active { background: rgba(255, 255, 255, 0.1); color: #fff; box-shadow: inset 3px 0 0 #7fc3a0; }
.nav .icon { flex: none; }

.status {
    margin-top: auto;
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: var(--s2);
    align-items: center;
    padding: var(--s3);
    font-size: 0.8rem;
    color: var(--rail-ink);
}
.status .updated, .status .zone { grid-column: 1 / -1; color: #93a0b3; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #93a0b3; }
.dot.on { background: #7fc3a0; box-shadow: 0 0 0 3px rgba(127, 195, 160, 0.2); }
.dot.off { background: #e0a43a; }

.content { padding: var(--s6) var(--s6) var(--s7); max-width: 1400px; min-width: 0; }

.page-head { margin-bottom: var(--s5); }
.page-head p { margin: var(--s1) 0 0; }

/* ---------- headline strip ---------- */

.stats {
    display: flex;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    margin-bottom: var(--s5);
}

.stat {
    flex: 1 1 150px;
    display: flex; flex-direction: column;
    padding: var(--s4) var(--s5);
    border-left: 1px solid var(--rule);
    min-width: 0;
}
.stat:first-child { border-left: 0; }

.stat-value {
    font-family: var(--serif);
    font-size: 2.1rem;
    line-height: 1.1;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
}
.stat-label { font-weight: 600; color: var(--ink-2); margin-top: var(--s1); }
.stat-detail { color: var(--muted); font-size: 0.85rem; }
.stat.alert .stat-value { color: var(--alert); }

/* ---------- panels & grids ---------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: var(--s4) var(--s5) var(--s5);
    margin-bottom: var(--s5);
    min-width: 0;
}

.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
    flex-wrap: wrap;
    margin-bottom: var(--s3);
}

.grid-main { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 0 var(--s5); }

.charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 0 var(--s5);
}

/* ---------- bar chart ---------- */

.chart { margin: 0; }
.chart figcaption { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s3); flex-wrap: wrap; }
.chart figcaption .muted { font-size: 0.85rem; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bars li {
    display: grid;
    grid-template-columns: minmax(90px, 9rem) 1fr minmax(3.5rem, auto);
    align-items: center;
    gap: var(--s3);
    font-size: 0.9rem;
}
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.bar-track { height: 14px; background: #eef2ef; border-radius: 3px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; }
.bars li.alert .bar-fill { background: var(--alert); }
.bar-value { text-align: right; font-weight: 600; }
.axis { margin: var(--s2) 0 0; font-size: 0.78rem; color: var(--muted); text-align: right; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.82rem;
    padding: var(--s2) var(--s3);
    border-bottom: 1px solid var(--rule);
    white-space: nowrap;
}
td { padding: 9px var(--s3); border-bottom: 1px solid #edf1ee; vertical-align: top; }
tbody tr:hover td { background: #f7faf8; }
th:first-child, td:first-child { padding-left: 0; }
.num { text-align: right; }
.alert-text { color: var(--alert); font-weight: 600; }

.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}
.tag.alert { background: var(--alert-soft); color: var(--alert); }

/* ---------- controls ---------- */

.search { display: flex; gap: var(--s2); }
input[type="search"], select {
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid #c8d1cb;
    border-radius: var(--radius);
    padding: 6px 10px;
    min-width: 0;
}
input[type="search"] { width: 16rem; }
input[type="search"]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

.select { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: 0.9rem; }

.btn {
    font: inherit;
    font-weight: 600;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius);
    padding: 6px 14px;
    cursor: pointer;
}
.btn:hover { background: #245a40; }
.btn:disabled { opacity: 0.6; cursor: progress; }

.list-foot { display: flex; align-items: center; justify-content: space-between; margin-top: var(--s3); font-size: 0.88rem; }

/* ---------- states ---------- */

.empty { color: var(--muted); margin: var(--s2) 0; }
.error {
    background: var(--alert-soft);
    color: var(--alert);
    border: 1px solid #ebc3bd;
    border-radius: var(--radius);
    padding: var(--s3) var(--s4);
}
.skeleton { display: grid; gap: 8px; padding: var(--s1) 0; }
.skeleton span { height: 14px; border-radius: 3px; background: linear-gradient(90deg, #eef2ef, #f7f9f8, #eef2ef); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.skeleton span:nth-child(2) { width: 80%; }
.skeleton span:nth-child(3) { width: 60%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- activity feed ---------- */

.feed ol { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.feed li {
    display: grid;
    grid-template-columns: 4.5rem 1fr;
    column-gap: var(--s3);
    padding: var(--s2) 0;
    border-bottom: 1px solid #edf1ee;
    font-size: 0.9rem;
}
.feed li time { color: var(--muted); }
.feed li small { grid-column: 2; color: var(--muted); }
.feed li.removed span { color: var(--ink-2); }

/* ---------- toasts ---------- */

.toasts {
    position: fixed; right: var(--s5); bottom: var(--s5);
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: var(--s2);
    width: min(360px, calc(100vw - 2 * var(--s5)));
    z-index: 20;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: var(--s3) var(--s4);
    box-shadow: 0 6px 20px rgba(28, 39, 56, 0.12);
    animation: toast-in 0.25s ease-out;
    font-size: 0.9rem;
}
.toast.removed { border-left-color: var(--alert); }
.toast.updated { border-left-color: #6d8fb8; }
.toast p { margin: var(--s1) 0 0; }
.toast .changed { color: var(--muted); font-size: 0.82rem; }
.toast-head { display: flex; align-items: baseline; gap: var(--s2); }
.toast-head time { color: var(--muted); font-size: 0.8rem; margin-left: auto; }
.close { border: 0; background: none; font-size: 1.1rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#blazor-error-ui {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0;
    background: #fff4d6; color: var(--ink);
    padding: var(--s3) var(--s5);
    border-top: 1px solid #e8d48f;
    z-index: 30;
}
#blazor-error-ui .reload { margin-left: var(--s3); }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
    .grid-main { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; }
    .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: var(--s3); }
    .brand { padding: var(--s2); width: 100%; }
    .nav span { display: none; }
    .status { margin-top: 0; width: 100%; }
    .content { padding: var(--s5) var(--s4); }
    .stat { border-left: 0; border-top: 1px solid var(--rule); }
    input[type="search"] { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
