/* LendCore — one theme across app and marketing (see DESIGN.md).
   The interface is quiet; the moments are loud.
   Display serif: 64 / 40 / 28 (600) — page titles and the sign-in name only.
   Interface sans: 19 / 17 / 15 / 13. Mono: every number, tabular.
   Weights: 400 / 500 / 600 — nothing heavier.
   Spacing: 4 / 8 / 16 / 24 / 32 / 48 / 64 / 120 (controls 40px tall by spec).
   Color: ten neutrals + one accent (actions/active state only) + three
   status colors (6px dot + word, nowhere else). */

:root {
  --n0: #FFFFFF; --n1: #F8F9FA; --n2: #F1F3F5; --n3: #E4E7EB; --n4: #CFD4DA;
  --n5: #A8B0B8; --n6: #7C858F; --n7: #545C65; --n8: #333A41; --n9: #16191C;
  --accent: #1F4B7A; --accent-hover: #17395D; --accent-wash: #EDF2F8;
  --overdue: #9B342B; --available: #2C6350; --out: #7D5610;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--n0);
  color: var(--n9);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  font-weight: 400;
}

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

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Type --- */
h1 {
  font-family: var(--serif);
  font-size: 28px; font-weight: 600; letter-spacing: -0.01em;
  line-height: 1.2; margin: 0;
}
h2 { font-size: 19px; font-weight: 600; line-height: 1.35; margin: 32px 0 8px; }
p { max-width: 68ch; }
.sub { color: var(--n7); font-size: 13px; margin: 4px 0 0; }
.num, td.num, th.num {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
a { color: inherit; text-decoration: underline; text-decoration-color: var(--n4); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--n9); }

/* --- Shell: 240px rail + centered content --- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.rail {
  background: var(--n1);
  border-right: 1px solid var(--n3);
  padding: 24px 0;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.rail .brand {
  display: block; color: inherit; text-decoration: none;
  font-size: 15px; font-weight: 600; letter-spacing: 0.04em;
  padding: 0 24px 4px;
}
.rail .org { padding: 0 24px 24px; font-size: 13px; color: var(--n7); }
.rail nav a {
  display: block; text-decoration: none;
  color: var(--n7); font-size: 13px;
  padding: 8px 24px;
  border-left: 2px solid transparent;
}
.rail nav a:hover { color: var(--n9); }
.rail nav a.active {
  color: var(--n9); font-weight: 500;
  border-left-color: var(--accent);
}
.rail .foot { margin-top: auto; padding: 16px 24px 0; }
.rail .hint { color: var(--n7); font-size: 13px; margin: 0 0 8px; }

main { padding: 32px; max-width: 1280px; width: 100%; margin: 0 auto; }

@media (max-width: 1023px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--n3); padding: 16px 0 0; }
  .rail nav { display: flex; flex-wrap: wrap; }
  .rail nav a { border-left: none; border-bottom: 2px solid transparent; padding: 8px 16px; }
  .rail nav a.active { border-bottom-color: var(--accent); }
  .rail .brand, .rail .org { padding-left: 16px; }
  .rail .foot { padding: 8px 16px 16px; }
  .rail .hint { display: none; }
  main { padding: 16px; }
}

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; flex-wrap: wrap; margin: 0 0 24px;
}

/* --- Stat strip: numbers with labels, hairline-separated, no boxes --- */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  border-top: 1px solid var(--n3); border-bottom: 1px solid var(--n3);
  margin: 0 0 32px;
}
.stat { padding: 24px 24px 24px 0; }
.stat + .stat { padding-left: 24px; border-left: 1px solid var(--n3); }
.stat .label {
  font-size: 13px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--n7);
}
.stat .value {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 40px; font-weight: 500; line-height: 1.2;
}

/* --- Tables: horizontal hairlines only --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.35; }
th, td {
  text-align: left; vertical-align: top;
  padding: 8px 16px 8px 0;
  border-bottom: 1px solid var(--n3);
}
th {
  font-size: 13px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--n7);
}
td.num, th.num { text-align: right; }
th:last-child, td:last-child { padding-right: 0; }

/* --- Status: 6px dot + word. Nothing else is colored. --- */
.status { white-space: nowrap; color: var(--n7); }
.status::before {
  content: ""; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  margin-right: 8px; vertical-align: 2px;
  background: var(--n5);
}
.status.available::before { background: var(--available); }
.status.checked_out::before, .status.open::before { background: var(--out); }
.status.overdue::before, .status.out_of_service::before { background: var(--overdue); }
.status.closed::before { background: var(--n5); }
.status.ok::before { background: var(--available); }

/* --- Forms --- */
form.stack { display: grid; gap: 16px; max-width: 560px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--n7); }
input, select, textarea {
  font: inherit; color: var(--n9); background: var(--n0);
  border: 1px solid var(--n4); border-radius: 4px;
  height: 40px; padding: 0 8px; width: 100%;
}
textarea { height: auto; min-height: 64px; padding: 8px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 599px) { .row2 { grid-template-columns: 1fr; } }
.help { font-size: 13px; color: var(--n7); max-width: 68ch; }

/* --- Buttons: primary and secondary. Nothing else. --- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-size: 15px; cursor: pointer; text-decoration: none;
  height: 40px; padding: 0 16px; border-radius: 4px;
  background: var(--n0); color: var(--n9); border: 1px solid var(--n4);
  transition: background-color 160ms ease-out, border-color 160ms ease-out;
}
button:hover, .btn:hover { background: var(--n1); }
button.primary, .btn.primary {
  background: var(--accent); color: var(--n0); border-color: var(--accent);
  font-weight: 500;
}
button.primary:hover, .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled { color: var(--n5); border-color: var(--n3); background: var(--n1); cursor: not-allowed; }
button.primary:disabled { background: var(--n3); border-color: var(--n3); color: var(--n6); }

/* --- Filters recede: 13px, 32px tall — the table is the loud element --- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 16px; font-size: 13px; }
.filters input, .filters select { width: auto; }
.filters input, .filters select, .filters button, .filters .btn { height: 32px; font-size: 13px; }
/* Segmented text filter (loans Open/Closed/All): active state, not a button */
.seg { display: flex; gap: 16px; font-size: 13px; margin: 0 0 16px; }
.seg a { text-decoration: none; color: var(--n7); padding: 4px 0; border-bottom: 2px solid transparent; }
.seg a:hover { color: var(--n9); }
.seg a.active { color: var(--n9); font-weight: 500; border-bottom-color: var(--accent); }

/* --- System status line (flash / undo toast) --- */
.flash {
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--n3); border-radius: 4px;
  background: var(--n1); padding: 8px 16px; margin: 0 0 24px;
  font-size: 13px;
}
.flash form { margin-left: auto; }
.flash button { height: 24px; padding: 0 8px; font-size: 13px; }

.error {
  border: 1px solid var(--n3); border-left: 2px solid var(--overdue);
  border-radius: 4px; padding: 8px 16px; margin: 0 0 24px;
  font-size: 13px; max-width: 68ch;
}

.empty {
  border: 1px solid var(--n3); border-radius: 4px;
  padding: 48px 24px; text-align: center; color: var(--n7); font-size: 13px;
}

fieldset { border: 1px solid var(--n3); border-radius: 4px; padding: 16px; margin: 0; }
legend { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; color: var(--n7); padding: 0 4px; }

/* --- Command palette (Cmd/Ctrl-K) --- */
.palette {
  position: fixed; inset: 0; background: rgba(22, 25, 28, 0.32);
  display: flex; justify-content: center; align-items: flex-start;
  padding: 64px 16px 0; z-index: 10;
}
.palette[hidden] { display: none; }
.palette-panel {
  background: var(--n0); border: 1px solid var(--n3); border-radius: 4px;
  width: 100%; max-width: 560px;
}
.palette-panel input { border: none; border-bottom: 1px solid var(--n3); border-radius: 4px 4px 0 0; }
.palette-panel input:focus { box-shadow: none; border-color: var(--n3); }
.palette-panel ul { list-style: none; margin: 0; padding: 8px 0; max-height: 320px; overflow-y: auto; }
.palette-panel li { padding: 8px 16px; font-size: 13px; cursor: pointer; }
.palette-panel li[aria-selected="true"] { background: var(--accent-wash); }
.palette-panel li .k { color: var(--n7); float: right; font-size: 13px; }

/* --- Sign-in --- */
.demo-note {
  border: 1px solid var(--n3); border-left: 2px solid var(--accent);
  border-radius: 4px; padding: 8px 16px; margin: 0;
  font-size: 13px; color: var(--n7);
}
.signin { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.signin .intro { background: var(--n1); padding: 120px 64px 64px; }
.signin .intro h1 { font-family: var(--serif); font-size: 40px; font-weight: 600; letter-spacing: -0.01em; }
.signin .intro p { font-size: 15px; color: var(--n7); margin: 8px 0 0; }
.signin .pane { display: flex; align-items: center; justify-content: center; padding: 24px; }
.signin form { width: 100%; max-width: 360px; display: grid; gap: 16px; }
@media (max-width: 899px) {
  .signin { grid-template-columns: 1fr; min-height: auto; }
  .signin .intro { padding: 24px; }
  .signin .pane { align-items: flex-start; padding: 24px; }
}

/* --- Label sheet: 30 per page (3 x 10) --- */
.label-sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.label-cell {
  border: 1px solid var(--n3); border-radius: 4px; padding: 8px;
  display: flex; gap: 8px; align-items: center; height: 88px; overflow: hidden;
}
.label-cell img { width: 64px; height: 64px; }
.label-cell .meta { font-size: 13px; line-height: 1.35; }
.label-cell .meta .code { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--n7); }
@media (max-width: 599px) { .label-sheet { grid-template-columns: 1fr 1fr; } }

/* --- Print: label sheet and list views --- */
@media print {
  .rail, .filters, .page-head .btn, .page-head button, .flash, .palette,
  .no-print, form.stack button { display: none !important; }
  .shell { display: block; }
  main { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
  a { text-decoration: none; }
  th, td { border-bottom-color: #ccc; }
  .label-cell { break-inside: avoid; border-color: #ccc; }
  .label-cell:nth-child(30n) { page-break-after: always; }
}
