:root {
  --navy: #001A42;
  --navy-2: #001430;
  --teal: #8BC63E;
  --teal-dark: #6FA32C;
  --green: #8BC63E;
  --cream: #F7F8F6;
  --card: #ffffff;
  --ink: #000000;
  --muted: #5A5F6A;
  --line: #F2F2F2;
  --line-strong: #C9CCCF;
  --gold: #8BC63E;
  --err: #9b1c1c;
  --ok: #3d7a12;
  --shadow: 0 10px 30px rgba(0, 26, 66, 0.08);
  --font: "IBM Plex Sans", Calibri, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1, "kern" 1;
}
header.app {
  background: var(--navy);
  color: #fff;
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: inherit;
}
.brand img {
  height: 56px;
  width: auto;
  display: block;
}
.brand span {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  border-left: 1px solid rgba(255, 255, 255, 0.22);
  padding-left: 16px;
}
header.app nav { display: flex; align-items: center; gap: 22px; }
header.app a { color: #fff; text-decoration: none; font-size: 16px; font-weight: 400; }
header.app a:hover,
header.app a.current { color: var(--green); }
header.app a.admin { opacity: 0.85; }
header.app button {
  background: #fff;
  border: 0;
  color: var(--navy);
  border-radius: 50px;
  padding: 8px 18px;
  font-weight: 500;
}
header.app button.ghost {
  background: #fff;
  color: var(--navy);
  border: 0;
}
header.app button.ghost:hover {
  background: var(--green);
  color: var(--navy);
  border-color: var(--green);
}
.ld-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: default;
  user-select: none;
  white-space: nowrap;
}
.ld-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c9cccf;
  flex-shrink: 0;
}
.ld-status.live .ld-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(139, 198, 62, 0.25); }
.ld-status.down {
  background: rgba(155, 28, 28, 0.35);
  border-color: rgba(255, 180, 180, 0.35);
}
.ld-status.down .ld-dot { background: #f0b4b4; }
.ld-status.checking .ld-dot { animation: ld-pulse 1.1s ease-in-out infinite; }
@keyframes ld-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}
.login-card {
  max-width: 420px;
  margin: 36px auto;
  text-align: center;
}
.login-mark {
  height: 118px;
  width: auto;
  display: block;
  margin: 0 auto 18px;
}
.login-card label,
.login-card input { text-align: left; }
body.login header.app .brand span { display: none; }
main { max-width: 1080px; margin: 28px auto 96px; padding: 0 18px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}
h1 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--navy);
}
.lede { color: var(--muted); margin: 0 0 22px; }
label { display: block; font-weight: 600; margin: 0 0 6px; font-size: 14px; color: var(--navy); }
input, select, button, .btn { font: inherit; }
input, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.pill {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--navy);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 500;
}
.pill.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.pill .meta { display: block; font-size: 11px; opacity: 0.75; font-weight: 500; }
.filters { display: grid; grid-template-columns: 1.4fr 1fr 1fr 0.8fr; gap: 12px; }
.loanbook-filters { grid-template-columns: 1.4fr 0.7fr 0.7fr 0.8fr; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.stat { background: #F7F8F6; border-radius: 12px; padding: 12px 14px; }
.stat .n {
  font-size: 22px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.2;
  font-variant-numeric: tabular-nums lining-nums;
}
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.search-wrap { position: relative; }
.results {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 320px;
  overflow: auto;
  z-index: 15;
  box-shadow: var(--shadow);
  display: none;
}
.results.open { display: block; }
.results button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
  color: var(--navy);
}
.results button:hover, .results button.active { background: #F7F8F6; }
.results .sub { color: var(--muted); font-size: 13px; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eaf4d8;
  color: #3d7a12;
  vertical-align: middle;
}
.badge.live { background: #eaf4d8; color: var(--teal-dark); }
.preview { margin-top: 22px; overflow-x: auto; }
.preview table { width: 100%; border-collapse: collapse; font-size: 14px; }
.preview th, .preview td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.preview th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.preview td { font-variant-numeric: tabular-nums lining-nums; }
.status { font-weight: 600; }
.status.open { color: var(--ok); }
.status.late { color: #b45309; }
.status.paid { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; }
.hint a { color: var(--navy); }
.error, .ok, .warn {
  padding: 11px 13px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.error { background: #fde8e8; color: var(--err); }
.ok { background: #e7f6ee; color: var(--ok); }
.warn { background: #fff4d6; color: #7a5b00; }
.actions.sticky {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 0 6px;
  background: linear-gradient(transparent, var(--cream) 30%);
}
button, .btn {
  background: var(--navy);
  color: #fff;
  border: 0;
  padding: 10px 20px;
  border-radius: 50px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-weight: 500;
}
button.primary { background: var(--navy); font-weight: 600; }
button.primary:hover { background: var(--green); color: var(--navy); }
button.secondary, .btn.secondary { background: var(--green); color: var(--navy); }
button.secondary:hover, .btn.secondary:hover { background: var(--navy); color: #fff; }
button.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line-strong); }
button.ghost:hover { border-color: var(--navy); }
button:disabled {
  background: #e8eaed;
  color: #8a9099;
  opacity: 1;
  cursor: not-allowed;
}
button.ghost:disabled { background: transparent; color: #a8aea2; }
.pill:disabled, .pill.locked {
  background: #eef0ea;
  color: var(--muted);
  cursor: not-allowed;
}
.drop {
  border: 2px dashed var(--line-strong);
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  background: #fff;
  color: var(--muted);
  margin: 12px 0;
}
.drop.drag { border-color: var(--green); background: #f2f7ea; }
.kbd { font-size: 12px; border: 1px solid var(--line); padding: 1px 6px; border-radius: 4px; background: #fff; }
.wait {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 26, 66, 0.5);
  z-index: 50;
  align-items: center;
  justify-content: center;
}
.wait.on { display: flex; }
.wait .box {
  background: #fff;
  padding: 22px 26px;
  border-radius: 16px;
  min-width: 280px;
  text-align: center;
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid #d5dacf;
  border-top-color: var(--green);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 28px 8px; color: var(--muted); }
@media (max-width: 800px) {
  .filters { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 24px; }
  .actions.sticky { position: static; background: none; }
  header.app { flex-wrap: wrap; padding: 14px 20px; }
  .card { padding: 18px; }
  .brand img { height: 44px; }
  .brand span { display: none; }
  .login-mark { height: 96px; }
}
