:root {
  color-scheme: light dark;
  --bg: #f3f5f8; --surface: #fff; --text: #17202e; --muted: #5b6778; --line: #d9dfe7;
  --accent: #1d4ed8; --accent-text: #fff; --danger: #b42318; --ok: #157347; --wait: #8a5a00;
  --tint: #e8effd; --error-bg: #fdecea; --ok-bg: #e6f4ec; --wait-bg: #fdf3dc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151d; --surface: #19202b; --text: #e8edf4; --muted: #9eabbb; --line: #2e3847;
    --accent: #7aa2f7; --accent-text: #10151d; --danger: #ff8a7a; --ok: #6fd69c; --wait: #f0c674;
    --tint: #1f2c44; --error-bg: #3a1f1c; --ok-bg: #16301f; --wait-bg: #36290f;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 1rem 0 .5rem; }
.card > h2:first-child { margin-top: 0; }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding: .75rem 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.bar nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.bar nav a { text-decoration: none; padding: .25rem 0; color: var(--muted); }
.bar nav a[aria-current] { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--accent); }
.who { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; font-size: .875rem; color: var(--muted); }
.who form { margin: 0; }

main { max-width: 1000px; margin: 0 auto; padding: 1rem 16px 3rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 440px; margin: 2rem auto; }
.card.highlight { border-color: var(--accent); background: var(--tint); }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.head h1 { margin: 0; }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .8rem; word-break: break-all; }

form { margin: 0; }
label { display: block; margin-bottom: .9rem; font-weight: 600; font-size: .925rem; }
input:not([type=checkbox]), select, textarea {
  display: block; width: 100%; margin-top: .25rem; padding: .55rem .65rem; font: inherit; font-weight: 400;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem; margin: 0 0 .9rem; }
legend { font-weight: 600; font-size: .925rem; padding: 0 .25rem; }
.group { margin-bottom: .75rem; }
.group:last-child { margin-bottom: 0; }
.check { display: flex; align-items: center; gap: .5rem; margin: .15rem 0; font-weight: 400; }
.check.strong { font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }

button, .button {
  display: inline-block; padding: .55rem 1rem; font: inherit; font-weight: 600; color: var(--accent-text); background: var(--accent);
  border: 1px solid var(--accent); border-radius: 6px; cursor: pointer; text-decoration: none;
}
.button.secondary { background: transparent; color: var(--accent); }
button.danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
button.link { padding: 0; background: none; border: 0; color: var(--accent); font-weight: 400; font-size: inherit; text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.inline { margin-top: 1rem; }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .925rem; }
th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
th, td { padding: .5rem .75rem .5rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tr.unread td:first-child a { font-weight: 700; }
.row-actions { white-space: nowrap; }
.row-actions form { display: inline; margin-right: .75rem; }

.notice { background: var(--ok-bg); color: var(--text); border-radius: 8px; padding: .6rem .9rem; margin: 0 0 1rem; }
.error { background: var(--error-bg); color: var(--text); border-radius: 8px; padding: .6rem .9rem; margin: 0 0 1rem; }
.error p { margin: 0 0 .25rem; }
.error ul { margin: 0; padding-left: 1.25rem; }
.message { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: .75rem 1rem; }
.files { list-style: none; padding: 0; margin: 1rem 0 0; }
.files li { padding: .4rem 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.key { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; background: var(--bg); border-radius: 6px; padding: .5rem .75rem; overflow-wrap: anywhere; user-select: all; }
.qr { display: block; margin: 0 auto 1rem; background: #fff; border-radius: 6px; }

.tag { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.tag.new { background: var(--tint); color: var(--accent); }
.tag.pending { background: var(--wait-bg); color: var(--wait); }
.tag.accepted { background: var(--ok-bg); color: var(--ok); }
.tag.returned { background: var(--error-bg); color: var(--danger); }

@media (max-width: 640px) { .who { margin-left: 0; } .who span { flex-basis: 100%; } }
