@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-Bold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
:root {
  /* Omarchy Kanagawa */
  --accent: #dcd7ba;
  --accent-hover: #c8c093;
  --selection: #363646;
  --muted: #727169;
  --bg: #1f1f28;
  --bg-bar: #17171e;
  --bg-dark: #17171e;
  --bg-darker: #111116;
  --bg-card: #223249;
  --ink: #dcd7ba;
  --fg-dim: #54546d;
  --line: #363646;
  --ok: #98bb6c;
  --warn: #e6c384;
  --err: #e82424;
  --cyan: #7aa89f;
  --font: "JetBrains Mono", "JetBrainsMono Nerd Font", ui-monospace, "Cascadia Code", monospace;
  --side-w: 220px;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font: 13px/1.55 var(--font);
  color: var(--ink);
  background: var(--bg-darker);
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Shared shell (Hostinger layout) ─────────────────────────── */
body.shell {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: 100vh;
}
.side {
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-brand {
  display: block;
  margin: 0 8px 28px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}
.side-brand:hover { text-decoration: none; color: var(--accent-hover); }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-link {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.side-link:hover {
  background: var(--selection);
  color: var(--ink);
  text-decoration: none;
}
.side-on {
  background: rgba(220, 215, 186, 0.12);
  color: var(--accent);
  font-weight: 600;
}
.side-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 8px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.side-foot button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--err);
  padding: 3px 8px;
  cursor: pointer;
  font: inherit;
}
.side-foot button:hover { background: rgba(232, 36, 36, 0.1); }

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(800px 400px at 90% -10%, rgba(126, 156, 216, 0.08), transparent 55%),
    var(--bg);
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 8px;
  border: 0;
  background: transparent;
}
.top h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0;
}
.top-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.content {
  padding: 12px 28px 40px;
  max-width: none;
}
main.wide { max-width: none; }
body.has-preview main { max-width: none; }

body.lock {
  min-height: 100vh;
  background:
    radial-gradient(700px 380px at 50% 20%, rgba(220, 215, 186, 0.08), transparent 55%),
    var(--bg-darker);
}
.lock-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.lock-card {
  width: min(360px, 100%);
  background: var(--bg-dark);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 24px 22px;
  display: grid;
  gap: 6px;
}
.lock-brand {
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}
.lock-card label {
  color: var(--muted);
  font-size: 11px;
  margin-top: 8px;
}
.lock-card input {
  width: 100%;
  margin-top: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
}
.lock-card input:focus { border-color: var(--accent); outline: none; }
.lock-card button {
  margin-top: 14px;
  background: var(--accent);
  color: var(--bg-darker);
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}
.lock-card button:hover { filter: brightness(1.05); }

.brand { display: flex; align-items: baseline; gap: 0.7rem; }
.top-right { display: flex; align-items: center; gap: 0.65rem; }
main { padding: 1.1rem 1.25rem 2rem; max-width: 72rem; }
.card {
  background: var(--bg-bar);
  border: 1px solid var(--line);
  padding: 0.9rem 1rem;
}
.narrow { max-width: 22rem; }
.login-card { margin: 4rem auto; }
h1 { font-size: 0.95rem; font-weight: 600; margin: 0 0 0.65rem; letter-spacing: 0.02em; }
label { display: block; margin: 0.55rem 0; color: var(--muted); }
input[type="text"], input[type="password"], input[type="file"] {
  width: 100%;
  margin-top: 0.25rem;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 0.4rem 0.5rem;
}
input[type="checkbox"] { accent-color: var(--accent); }
button, .btn {
  font: inherit;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.42rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  letter-spacing: 0.01em;
}
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-lg { padding: 0.55rem 1rem; }
.btn-sm { padding: 0.28rem 0.55rem; font-size: 0.8rem; font-weight: 600; }
.btn-block { width: 100%; margin-top: 0.7rem; }
.btn-ghost {
  background: var(--selection);
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 500;
}
.btn-danger {
  background: transparent;
  color: var(--err);
  border: 1px solid var(--err);
  font-weight: 600;
}
.btn-danger:hover {
  background: var(--err);
  color: var(--bg);
  border-color: var(--err);
}
.preview-actions { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.err { color: var(--err); font-size: 0.8rem; max-width: 18rem; }
.flash {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  background: var(--bg-bar);
  margin-bottom: 1rem;
}
.flash.error { border-color: var(--err); color: var(--err); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: var(--bg-bar);
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
}
.chip.warn { border-color: var(--warn); }
.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin-bottom: 0.9rem;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.tabs a {
  color: var(--muted);
  padding: 0.45rem 0.7rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.tabs a span {
  color: var(--accent);
  margin-left: 0.25rem;
}
.intake-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (max-width: 960px) {
  .intake-actions { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .intake-actions { grid-template-columns: 1fr; }
}
.intake-actions .card button,
.intake-actions .card .btn { margin-top: 0.45rem; }
.queue-bar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}
.queue-bar h1 { margin: 0; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-bar);
  font-size: 0.86rem;
  line-height: 1.5;
  table-layout: fixed;
}
th, td {
  text-align: left;
  padding: 0.48rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 500; }
.check { width: 2.2rem; }
.col-when { width: 9.6rem; }
.col-status { width: 7.5rem; }
.col-actions { width: 16.5rem; }
.clip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nowrap { white-space: nowrap; }
.actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  position: sticky;
  right: 0;
  background: var(--bg-bar);
}
.empty { padding: 1.1rem 0.55rem; }
.pill {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}
.st-in_xero .pill { color: var(--ok); }
.st-failed .pill { color: var(--err); }
.st-sending .pill { color: var(--warn); }
.st-not_a_bill .pill { color: var(--muted); }
.st-no_attachment .pill { color: var(--warn); }
.st-new .pill { color: var(--accent); }
.workspace {
  display: block;
}
.preview {
  position: fixed;
  z-index: 40;
  top: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  width: min(32rem, calc(100vw - var(--side-w) - 2rem));
  display: flex;
  flex-direction: column;
  background: var(--bg-bar);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.preview[hidden] { display: none; }
.preview-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--line);
}
.preview-bar strong {
  font-size: 0.8rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: none;
}
.preview-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex-shrink: 0;
}
.preview-actions .btn-lg { padding: 0.5rem 1.1rem; font-size: 0.95rem; }
.preview-frame, .preview-img {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: var(--bg);
}
.preview-img { object-fit: contain; padding: 0.5rem; }
.select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.queue-list {
  background: var(--bg-bar);
  border: 1px solid var(--line);
}
.queue-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
}
.queue-row:last-child { border-bottom: 0; }
.queue-row.is-previewing { background: var(--selection); }
.queue-row .check { width: auto; flex-shrink: 0; }
.queue-body { min-width: 0; flex: 1; }
.queue-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.queue-file {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1 1 12rem;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0;
  margin-left: auto;
  width: auto;
  flex: 0 0 auto;
}
.queue-meta {
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.whoami {
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.whoami strong { color: var(--ink); }
.row-actions button,
.row-actions a.btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}
.queue-pane { min-width: 0; overflow-x: auto; }
body.has-preview .queue-pane { padding-right: min(33rem, calc(100vw - var(--side-w) - 2rem)); }
@media (max-width: 960px) {
  body.shell { grid-template-columns: 1fr; }
  .side {
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px;
  }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { border-top: 0; padding-top: 8px; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
  .preview {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    border-radius: 0;
  }
  body.has-preview .queue-pane { padding-right: 0; }
}
