:root {
    --bg: #f4f6f9; --card: #fff; --text: #1d2633; --muted: #66717f; --line: #e2e6ec;
    --brand: #1f3a5f; --brand-2: #2d5a8e; --red: #c62828; --red-bg: #fdecea; --amber: #a15c00; --amber-bg: #fff4e0;
    --green: #1b7a3d; --green-bg: #e6f4ea; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.narrow { width: 100%; max-width: 380px; }
.brand { font-weight: 700; font-size: 20px; color: var(--brand); margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
label input, label select { display: block; width: 100%; margin-top: 4px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
label.check input { width: auto; margin: 0; }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid #c9d0da; border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: var(--brand-2); }
input.num { width: 90px; text-align: right; }
.btn { font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 8px; border: 1px solid #c9d0da; background: #fff; color: var(--text); cursor: pointer; }
.btn:hover { background: #f0f3f7; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--red); border-color: #e8b4b4; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.link { border: none; background: none; color: var(--brand-2); }
.btn.wide { width: 100%; margin-top: 6px; }
.error { background: var(--red-bg); color: var(--red); padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 10px 18px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top .brand { margin: 0; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.tab { font: inherit; font-weight: 600; color: var(--muted); background: none; border: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.tab:hover { background: #eef2f7; }
.tab.active { background: var(--brand); color: #fff; }
.who { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.books-age { color: var(--muted); font-size: 13px; }
.books-age.old { color: var(--red); font-weight: 600; }
.page { max-width: 1200px; margin: 0 auto; padding: 18px; }

/* Today */
.big-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.big { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.big:hover { border-color: var(--brand-2); }
.big .n { font-size: 30px; font-weight: 700; color: var(--brand); }
.big.warn .n { color: var(--red); }
.big .l { color: var(--muted); font-weight: 600; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .sub { color: var(--muted); font-size: 13px; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: #eef2f7; color: var(--muted); white-space: nowrap; }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.green { background: var(--green-bg); color: var(--green); }
.banner { background: var(--amber-bg); color: var(--amber); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; }
.banner .grow { flex: 1; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 8px; border-bottom: 2px solid var(--line); white-space: nowrap; background: var(--card); position: sticky; top: 0; }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.r, th.r { text-align: right; }
tr.removed td { opacity: .45; text-decoration: line-through; }
tr.urgent td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.why { color: var(--muted); font-size: 12px; margin-top: 2px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.toolbar input[type=search] { min-width: 240px; }
.bulk { position: sticky; bottom: 0; background: var(--brand); color: #fff; padding: 12px 14px; border-radius: var(--radius); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.bulk input, .bulk select { padding: 7px 8px; }
.bulk .btn { padding: 7px 12px; }
.two { display: grid; grid-template-columns: 300px 1fr; gap: 14px; align-items: start; }
.side .list-row { cursor: pointer; padding: 10px; border-radius: 8px; border-top: none; }
.side .list-row:hover { background: #eef2f7; }
.side .list-row.active { background: #e3ebf5; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* Modal and toasts */
.modal { position: fixed; inset: 0; background: rgba(20, 30, 45, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal-box { background: #fff; border-radius: 12px; padding: 20px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast { background: #1d2633; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.error { background: var(--red); }

@media (max-width: 800px) {
    .two { grid-template-columns: 1fr; }
    .top { gap: 8px; padding: 8px 12px; }
    .who .btn { display: none; }
    .page { padding: 12px; }
}
