:root {
  color-scheme: dark;
  --bg: #0e1311;
  --surface: #151b18;
  --surface-2: #1b2320;
  --line: #26312c;
  --line-strong: #34413b;
  --text: #e6eeea;
  --muted: #8c9a94;
  --mint: #7ee3bd;
  --mint-strong: #5fd1a6;
  --mint-soft: rgba(126, 227, 189, 0.12);
  --warn: #f0c36a;
  --danger: #ff9d94;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.4 -apple-system, system-ui, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.offscreen { position: fixed; left: -9999px; top: 0; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth form { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: min(380px, 100%); display: grid; gap: 12px; }
.auth h1 { margin: 0; font-size: 20px; }
.auth p { margin: 0; color: var(--muted); }
.auth .logo { height: 30px; width: auto; justify-self: start; margin-bottom: 4px; }
.error { color: var(--danger); min-height: 1.2em; }

label.field { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
input[type=text], input[type=password], input[type=search], select, textarea {
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 9px; background: var(--bg); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--mint); box-shadow: 0 0 0 2px var(--mint-soft); }
input::placeholder, textarea::placeholder { color: #66746e; }
input[type=checkbox] { accent-color: var(--mint-strong); }
textarea { min-height: 90px; resize: vertical; font-weight: 400; }
.field input, .field select, .field textarea { font-weight: 400; }

button.primary { background: var(--mint); color: #08110d; border: 0; border-radius: 6px; padding: 8px 14px; font-weight: 700; }
button.primary:hover { background: var(--mint-strong); }
button.primary:disabled { opacity: 0.45; cursor: default; }
button.secondary { background: transparent; border: 1px solid var(--line-strong); border-radius: 6px; padding: 8px 14px; }
button.secondary:hover { border-color: var(--mint); color: var(--mint); }
button.link { background: none; border: 0; color: var(--mint); padding: 4px 6px; }
button.link:hover { text-decoration: underline; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; letter-spacing: 0.01em; }
.brand::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--mint); margin-right: 9px; box-shadow: 0 0 0 4px var(--mint-soft); }
.topbar-right { display: flex; gap: 10px; align-items: center; }
.topbar .logo { height: 20px; width: auto; margin-left: 12px; }

.periods { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.periods select { width: auto; }
.tab { border: 1px solid var(--line-strong); background: transparent; border-radius: 999px; padding: 5px 12px; }
.tab:hover { border-color: var(--mint); }
.tab.active { background: var(--mint); border-color: var(--mint); color: #08110d; font-weight: 700; }
.tab small { opacity: 0.7; margin-left: 4px; }
.tab.empty { opacity: 0.5; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 20px; }
.toolbar input[type=search] { width: 280px; }
.toolbar select { width: auto; }
.check { display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }
.spacer { flex: 1; }

.table-wrap { padding: 0 20px 40px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { position: sticky; top: 0; background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); z-index: 1; }
tr.row { cursor: pointer; }
tr.row:hover { background: #19211d; }
tr.row.selected { background: var(--mint-soft); }
tr.row.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: rgba(126, 227, 189, 0.3); } to { background: transparent; } }
td.project { font-weight: 600; }
td.small { font-size: 12px; color: var(--muted); max-width: 220px; }
.chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: #2a3430; margin-right: 3px; }
.chip.ascap { background: #1b2f4d; color: #8ab8ff; }
.chip.bmi { background: #47231f; color: #ff9d94; }
.dot { color: var(--warn); font-weight: 700; }
.small-note { font-size: 11px; color: var(--muted); }
.empty-state { padding: 40px; text-align: center; color: var(--muted); background: var(--surface); border: 1px solid var(--line); }

td select.status { width: auto; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 30px 4px 12px; background-position: right 12px center; }
.s-pending_registration { background-color: #262d2a; border-color: #4a5651; color: #c9d4cf; }
.s-registered_claim_pending { background-color: rgba(240, 195, 106, 0.14); border-color: #8a6a24; color: #f3d48a; }
.s-codes_claimed, .s-registered_no_claim { background-color: rgba(126, 227, 189, 0.14); border-color: #2f8466; color: #8cf0c7; }
.s-cant_register { background-color: rgba(255, 157, 148, 0.14); border-color: #8d3f39; color: #ffa9a1; }

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239fb0a9' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
option { background: var(--surface); color: var(--text); }
td select.davy { width: 84px; padding-left: 12px; border-radius: 999px; }
.periods select, .toolbar select { border-radius: 999px; padding-left: 14px; }

.drawer { position: fixed; top: 0; right: 0; width: min(520px, 100%); height: 100%; background: var(--surface); border-left: 1px solid var(--line-strong); box-shadow: -12px 0 32px rgba(0, 0, 0, 0.45); display: flex; flex-direction: column; z-index: 5; }
.drawer-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-body { padding: 14px 18px; overflow-y: auto; flex: 1; display: grid; gap: 12px; align-content: start; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.notice { background: rgba(240, 195, 106, 0.12); border: 1px solid #8a6a24; border-radius: 6px; padding: 8px 10px; color: #f3d48a; }
.box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.box h3 { margin: 0 0 6px; font-size: 13px; }
.code { font-size: 12px; padding: 1px 6px; border-radius: 4px; background: #2a3430; }
.code.claimed { background: rgba(126, 227, 189, 0.16); color: #8cf0c7; }
.history { display: grid; gap: 4px; font-size: 12px; color: #b5c2bc; }
.note-top { margin-top: 6px; }

.code-list { display: grid; max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.code-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 3px 8px; border-bottom: 1px solid var(--line); }
.code-label { display: flex; gap: 8px; align-items: center; flex: 1; cursor: pointer; }
.copy-btn { background: none; border: 1px solid var(--line-strong); color: var(--muted); border-radius: 5px; padding: 1px 8px; font-size: 12px; }
.copy-btn:hover { color: var(--mint); border-color: var(--mint); }
.code-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.paste-wrap { display: grid; gap: 6px; margin-top: 10px; justify-items: start; }
.paste { min-height: 70px; }
.check-results { display: grid; gap: 6px; margin-top: 10px; }
.check-row { display: grid; gap: 2px; padding: 6px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.dup { color: var(--warn); font-weight: 600; }
.fresh { color: var(--mint); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--surface-2); color: var(--text); border: 1px solid var(--mint); padding: 9px 14px; border-radius: 8px; z-index: 20; max-width: 90vw; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }

.chip.badge { background: rgba(255, 152, 67, 0.18); color: #ffb066; border: 1px solid #a35a1a; margin-left: 6px; }
.badges { display: inline-block; }
.split-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
button.small { padding: 4px 10px; font-size: 12px; }
.split-head { margin: 12px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.split-row { margin-bottom: 6px; }
.split-line { display: flex; gap: 6px; align-items: center; }
.split-sub { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; padding-left: 2px; min-height: 16px; }
select.sel-initials { width: 92px; flex: none; }
select.sel-role { width: 118px; flex: none; }
select.sel-pub { flex: 1; min-width: 0; width: auto; }
input.in-share { width: 78px; flex: none; text-align: right; }
.pct { color: var(--muted); }
.half { color: var(--mint); font-size: 12px; }
.x-btn { background: none; border: 1px solid var(--line-strong); color: var(--muted); border-radius: 5px; width: 26px; height: 26px; line-height: 1; }
.x-btn:hover { color: var(--danger); border-color: var(--danger); }
.split-totals { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; font-weight: 600; }
.split-totals > div { flex-basis: 100%; font-weight: 400; font-size: 13px; }
.ok-total { color: var(--mint); }
.bad-total { color: var(--warn); }
.warn-note { color: var(--warn); }
.tk-note { color: #ffb066; }
.copy-panel { display: grid; gap: 6px; margin: 6px 0; }
.copy-results { display: grid; gap: 2px; }
.copy-hit { text-align: left; padding: 3px 0; }
.people-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.people-row input[type=text] { min-width: 0; }
.people-row .ini { width: 44px; flex: none; }
input.in-ini { width: 70px; flex: none; }
input.in-ipi { width: 112px; flex: none; }
input.in-badge { width: 60px; flex: none; }
select.sel-pro { width: 92px; flex: none; }

.drawer.wide { width: min(700px, 100%); }
input.in-name { flex: 1; min-width: 130px; width: auto; }

.split-controls { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; margin: 8px 0; }
label.field.inline { display: inline-grid; grid-template-columns: auto 160px; align-items: center; gap: 8px; }
.auto-pub { flex: 1; font-weight: 600; }
.auto-share { color: var(--text); min-width: 78px; text-align: right; }
.other-panel { display: grid; gap: 6px; margin: 6px 0 10px; padding: 8px; border: 1px dashed var(--line-strong); border-radius: 6px; }
.drawer.wide { width: min(780px, 100%); }

.reader-banner { margin: 8px 0; padding: 8px 10px; border-radius: 6px; font-weight: 600; border: 1px solid var(--line-strong); }
.reader-banner.lvl-ok { background: rgba(126, 227, 189, 0.12); border-color: #2f8466; color: #8cf0c7; }
.reader-banner.lvl-check { background: rgba(240, 195, 106, 0.12); border-color: #8a6a24; color: #f3d48a; }
.reader-banner.lvl-problem { background: rgba(255, 157, 148, 0.12); border-color: #8d3f39; color: #ffa9a1; }
.issue { font-size: 13px; margin: 2px 0; }
.issue.lvl-ok { color: var(--mint); }
.issue.lvl-check { color: var(--warn); }
.issue.lvl-problem { color: var(--danger); }
.agr-row { margin: 4px 0; font-size: 13px; }
.agr-details { display: grid; gap: 2px; font-size: 13px; }
.raw { margin-top: 4px; white-space: pre-wrap; word-break: break-word; font-size: 12px; }
select.sel-own { width: 150px; flex: none; }

.dropzone { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px dashed var(--line-strong); border-radius: 8px; }
.box.over .dropzone { border-color: var(--mint); background: var(--mint-soft); }
.hidden-file { display: none; }
