:root {
  color-scheme: light dark;
  --bg: #f4f5f7; --fg: #1b1f24; --card: #ffffff; --muted: #667085; --line: #e3e6ea;
  --accent: #2456d9; --danger: #b42318; --ok: #15803d;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1117; --fg: #e6e8ec; --card: #171b23; --muted: #98a2b3; --line: #2a303b; --accent: #5b8def; --danger: #f87171; --ok: #4ade80; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .12em; color: var(--fg); text-decoration: none; }
.topbar nav { display: flex; gap: 1.25rem; align-items: center; }
.container { max-width: 980px; margin: 1.5rem auto; padding: 0 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; }
.card.narrow { max-width: 440px; width: 100%; margin-left: auto; margin-right: auto; }
body.centered { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }

label { display: block; margin: .75rem 0 .25rem; font-weight: 600; }
label.inline-label { margin: 0; }
input[type=text], input[type=password], input[type=file], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--fg); font: inherit;
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
button, .button {
  display: inline-block; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--fg); font: inherit; cursor: pointer; text-decoration: none; margin-top: .5rem;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; margin: 0; }
form.inline { display: inline; }
.row { display: flex; gap: .5rem; align-items: center; margin: .25rem 0 .75rem; flex-wrap: wrap; }
.row input[type=text] { flex: 1; min-width: 12rem; }
.row select { width: auto; }
.row button { margin-top: 0; }
.field { margin-bottom: .5rem; }
.field button { margin-top: .35rem; }

.flash { padding: .6rem .9rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid var(--line); background: var(--card); }
.flash.error { border-color: var(--danger); color: var(--danger); }
.flash.success { border-color: var(--ok); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.actions { white-space: nowrap; }
.actions button, .actions .button { margin-top: 0; }

/* Viewer */
body.viewer { background: #2a2e35; color: #e6e8ec; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.viewer-bar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
  padding: .6rem 1rem; background: #181b21; border-bottom: 1px solid #000; }
.viewer-bar .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .status { color: #98a2b3; font-size: .85em; white-space: nowrap; }
.pages { max-width: 1000px; margin: 1rem auto; padding: 0 .5rem; }
.page { position: relative; margin: 0 0 1rem; background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, .45); }
.page img { display: block; width: 100%; height: auto; pointer-events: none; }
.page .shield { position: absolute; inset: 0; }
.print-notice { display: none; }
@media print {
  body.viewer * { display: none !important; }
  body.viewer .print-notice { display: block !important; padding: 2rem; font-size: 1.4rem; }
}
@media (max-width: 640px) {
  .viewer-bar { flex-direction: column; gap: .15rem; }
  .viewer-bar .status { white-space: normal; }
}
