:root { color-scheme: light dark; --accent: #2f6fed; --accent-dark: #245ad0; }
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0; background: #f4f5f7; color: #1a1a1a;
}
a { color: var(--accent); }

/* top bar */
.topbar {
  background: #ffffff; border-bottom: 1px solid #e5e7eb;
  padding: 0 24px; display: flex; align-items: center; gap: 24px; height: 56px;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 15px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  padding: 8px 14px; border-radius: 7px; text-decoration: none; color: #4b5563;
  font-size: 14px; font-weight: 600;
}
.nav a:hover { background: #eef0f3; }
.nav a.active { background: var(--accent); color: #fff; }

.wrap { max-width: 860px; margin: 28px auto; padding: 0 16px; }
.card {
  background: #ffffff; border-radius: 12px; padding: 26px 30px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.10);
}
h1 { font-size: 20px; margin: 0 0 4px; }
.sub { color: #6b7280; font-size: 13px; margin: 0 0 20px; }

/* forms */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 20px; }
.full { grid-column: 1 / -1; }
label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.req { color: #d1453b; }
input, select {
  width: 100%; padding: 9px 11px; font-size: 14px; border: 1px solid #d0d3d9;
  border-radius: 7px; background: #fff; color: #1a1a1a;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.hint { font-size: 11px; color: #8a8f98; margin-top: 4px; }
.actions { margin-top: 24px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

button, .btn {
  font: inherit; font-size: 14px; font-weight: 600; padding: 10px 20px; border: 0;
  border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer;
  text-decoration: none; display: inline-block; line-height: 1.2;
}
button:hover, .btn:hover { background: var(--accent-dark); }
.btn.secondary, button.secondary { background: #e6e8ec; color: #1a1a1a; }
.btn.secondary:hover { background: #d8dbe0; }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn.danger { background: #e6e8ec; color: #b3261e; }
.btn.danger:hover { background: #f7d7d4; }

.borrowerpick { display: flex; gap: 10px; align-items: end; margin-bottom: 18px;
  padding-bottom: 18px; border-bottom: 1px solid #eceef1; }
.borrowerpick .field { flex: 1; }

/* banners */
.err { background: #fdecea; color: #a3221a; border: 1px solid #f5c6c2;
  border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }
.flash { background: #e7f5ec; color: #1a7f37; border: 1px solid #b7e0c4;
  border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }
.ok { color: #1a7f37; font-weight: 600; font-size: 16px; margin: 0 0 14px; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid #e5e7eb; vertical-align: middle; }
th { color: #6b7280; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
tr:hover td { background: #fafbfc; }
td.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: #9aa0aa; }
.right { text-align: right; }
.empty { text-align: center; color: #9aa0aa; padding: 40px 0; }
code { background: rgba(127,127,127,0.14); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.inline { display: inline; }

.head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.head-row h1 { margin: 0; }

@media (prefers-color-scheme: dark) {
  body { background: #16181d; color: #e8e8ea; }
  .topbar { background: #22252c; border-color: #30333b; }
  .brand { color: #e8e8ea; }
  .nav a { color: #b3b8c2; }
  .nav a:hover { background: #2c2f37; }
  .card { background: #22252c; box-shadow: none; }
  input, select { background: #191b20; color: #e8e8ea; border-color: #3a3d45; }
  .sub, .hint, th { color: #9aa0aa; }
  th, td { border-color: #30333b; }
  tr:hover td { background: #262932; }
  .borrowerpick { border-color: #30333b; }
  .btn.secondary, button.secondary { background: #333742; color: #e8e8ea; }
  .btn.danger { background: #333742; color: #f2938c; }
  .qr { background: #ffffff; }
}

/* auth pages */
.authbody { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; }
.authcard { width: 100%; max-width: 380px; }
.authbrand { font-weight: 700; font-size: 13px; color: #8a8f98; margin-bottom: 10px; }
.authtitle { margin: 0 0 8px; }
.authform { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }
.authform label { margin-top: 8px; }
.authform button { margin-top: 18px; }
.qr { background: #ffffff; padding: 12px; border-radius: 10px; display: inline-block; margin: 6px 0 10px; }
.qr svg { display: block; width: 200px; height: 200px; }
.secret { display: inline-block; margin: 4px 0 10px; font-size: 14px; letter-spacing: 1px; word-break: break-all; }
.small-link { display: inline-block; margin-top: 14px; font-size: 13px; text-decoration: none; }
.nav a.logout { color: #8a8f98; font-weight: 500; }
.nav a.logout:hover { background: #eef0f3; }
