/* RBV Books — single-file design system. No frameworks, CSP-friendly. */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1a2233;
  --ink-soft: #5b6575;
  --line: #e3e7ee;
  --brand: #1f4e79;
  --brand-ink: #ffffff;
  --accent: #0e7c5a;
  --danger: #b3372f;
  --warn: #9a6a03;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink);
}
h1 { font-size: 1.45rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--ink-soft); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: 0 0 220px; background: #16324a; color: #cfd9e4;
  display: flex; flex-direction: column; padding: 1rem .75rem;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: baseline; gap: .45rem; padding: .25rem .5rem 1rem; }
.brand-mark { background: #fff; color: #16324a; font-weight: 800; border-radius: 6px; padding: .1rem .4rem; font-size: .95rem; }
.brand-name { font-weight: 600; color: #fff; letter-spacing: .02em; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  color: #cfd9e4; padding: .45rem .6rem; border-radius: 7px; font-size: .95rem;
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav-section { margin: .9rem .6rem .2rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #8fa1b3; }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; padding: .75rem .6rem 0; border-top: 1px solid rgba(255,255,255,.12); font-size: .88rem; }
.badge { background: var(--danger); color: #fff; font-size: .72rem; border-radius: 99px; padding: 0 .45rem; line-height: 1.5; }
.main { flex: 1; padding: 1.5rem 2rem 3rem; max-width: 1200px; }

/* Auth screens */
.auth-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 1rem; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; width: 100%; max-width: 400px; }
.auth-card h1 { text-align: center; }

/* Cards, stats */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; }
.stat .label { font-size: .8rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 1.35rem; font-weight: 650; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat .value.pos { color: var(--accent); }
.stat .value.neg { color: var(--danger); }

/* Tables */
table.data { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: #f0f2f6; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Forms */
form.stack label, .field label { display: block; font-size: .85rem; font-weight: 600; margin: .8rem 0 .25rem; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=file], select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid #c8cfda; border-radius: 7px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b3c9de; border-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1.25rem; }
.form-actions { margin-top: 1.4rem; display: flex; gap: .6rem; align-items: center; }
.errorlist { color: var(--danger); margin: .2rem 0 0; padding-left: 1.1rem; font-size: .85rem; }
.helptext { display: block; color: var(--ink-soft); font-size: .8rem; margin-top: .15rem; }

/* Buttons */
button, .btn {
  display: inline-block; border: 1px solid transparent; border-radius: 7px; cursor: pointer;
  padding: .5rem 1rem; font: inherit; font-weight: 600; background: var(--brand); color: var(--brand-ink);
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--ink); border-color: #c8cfda; }
.btn-danger { background: var(--danger); }
.btn-small { padding: .25rem .6rem; font-size: .85rem; }
button.linklike { background: none; border: none; color: inherit; padding: 0; font-weight: 400; cursor: pointer; text-decoration: underline; }

/* Pills / status */
.pill { display: inline-block; border-radius: 99px; font-size: .78rem; font-weight: 600; padding: .1rem .6rem; }
.pill-green { background: #e2f4ec; color: #0d6b4e; }
.pill-red { background: #fbe7e5; color: #99302a; }
.pill-amber { background: #fdf1d8; color: #8a5f04; }
.pill-gray { background: #eceff3; color: #5b6575; }
.pill-blue { background: #e3edf6; color: #1f4e79; }

/* Messages */
.messages { margin-bottom: 1rem; }
.message { border-radius: 8px; padding: .6rem .9rem; margin-bottom: .5rem; border: 1px solid; }
.message-success { background: #e2f4ec; border-color: #b7e2d0; color: #0d6b4e; }
.message-error, .message-danger { background: #fbe7e5; border-color: #f2c4c0; color: #99302a; }
.message-warning { background: #fdf1d8; border-color: #f0dda9; color: #8a5f04; }
.message-info { background: #e3edf6; border-color: #c4d8ea; color: #1f4e79; }

/* Utility */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin-bottom: 1rem; }
.toolbar form { display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; }
.toolbar .field { min-width: 140px; }
.toolbar .field label { margin-top: 0; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.right { text-align: right; }
.mt { margin-top: 1.25rem; }
.qr { background: #fff; padding: .75rem; border: 1px solid var(--line); border-radius: var(--radius); display: inline-block; }
.dropzone { border: 2px dashed #c8cfda; border-radius: var(--radius); padding: 2rem; text-align: center; color: var(--ink-soft); background: #fff; }
.dropzone.dragover { border-color: var(--brand); background: #eef4fa; }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: column; }
  .main { padding: 1rem; }
}

@media print {
  .sidebar, .toolbar, .form-actions, .messages { display: none !important; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { box-shadow: none; border: none; }
}
