:root {
  --bg: #0f1419;
  --panel: #171d25;
  --panel-2: #1e2630;
  --border: #2a3441;
  --text: #e8eef5;
  --muted: #8b9bb0;
  --accent: #c9a227;
  --accent-2: #7eb8da;
  --ok: #3d9a6a;
  --err: #c45c5c;
  --warn: #c4893a;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a2433 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1c1a12 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--accent); text-decoration: none; }
nav { display: flex; gap: 0.9rem; align-items: center; flex-wrap: wrap; font-size: 0.95rem; }
nav a { color: var(--muted); }
nav a:hover { color: var(--text); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.2rem 4rem; }
.foot {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.2rem 2rem;
  color: var(--muted);
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}

h1, h2, h3 { font-weight: 650; letter-spacing: -0.02em; }
h1 { font-size: 1.75rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.25rem; margin: 0 0 0.75rem; }
.lead { color: var(--muted); margin: 0 0 1.25rem; max-width: 52ch; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
}

.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 800px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

.stat strong { display: block; font-size: 1.35rem; color: var(--accent); }
.stat span { color: var(--muted); font-size: 0.85rem; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="file"],
select,
textarea {
  width: 100%;
  background: #0c1015;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font: inherit;
}
textarea { min-height: 100px; resize: vertical; font-family: var(--mono); font-size: 0.9rem; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(201, 162, 39, 0.35);
  border-color: var(--accent);
}

.field { margin-bottom: 0.9rem; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #14110a;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover, button.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid transparent; }
.btn.danger { background: var(--err); color: #fff; }
button.linkish {
  background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0;
}
button.linkish:hover { color: var(--text); text-decoration: underline; }
form.inline { display: inline; margin: 0; }

.flash {
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}
.flash.ok { background: rgba(61, 154, 106, 0.15); border: 1px solid rgba(61,154,106,0.4); }
.flash.err { background: rgba(196, 92, 92, 0.15); border: 1px solid rgba(196,92,92,0.4); }

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--panel);
}
th, td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  background: #121820;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}
tr:hover td { background: rgba(255,255,255,0.02); }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.badge.warn { color: #f0c48a; border-color: rgba(196,137,58,0.5); background: rgba(196,137,58,0.12); }
.badge.ok { color: #8fd4b0; border-color: rgba(61,154,106,0.45); background: rgba(61,154,106,0.12); }
.badge.maint { color: #9ec9e8; border-color: rgba(126,184,218,0.45); background: rgba(126,184,218,0.12); }

.drop {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  background: rgba(0,0,0,0.15);
}
.drop strong { color: var(--accent); }

.login-box {
  max-width: 400px;
  margin: 3rem auto;
}
.pin-input {
  font-size: 1.25rem;
  letter-spacing: 0.2em;
  text-align: center;
  font-family: var(--mono);
}

.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; }
.filters .field { margin: 0; min-width: 120px; flex: 1 1 120px; }
.filters .field.grow { flex: 2 1 180px; }

.actions { display: flex; gap: 0.25rem; flex-wrap: nowrap; align-items: center; justify-content: flex-end; }
.actions form { margin: 0; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  color: var(--muted);
  border: 1px solid transparent;
  text-decoration: none;
  transition: color .12s ease, background .12s ease, border-color .12s ease;
}
a.icon-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
  border-color: var(--border);
  text-decoration: none;
}
.icon-btn.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.icon-btn svg { display: block; }
button.icon-btn {
  background: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
button.icon-btn.danger:hover {
  color: var(--err);
  border-color: rgba(196, 92, 92, 0.45);
  background: rgba(196, 92, 92, 0.12);
}
.sr-only-form {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.actions a + a { margin-left: 0; }

code, .mono { font-family: var(--mono); font-size: 0.88em; }
.help {
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(0,0,0,0.2);
  border-left: 3px solid var(--accent);
  padding: 0.7rem 0.9rem;
  margin: 0.8rem 0 1rem;
  border-radius: 0 8px 8px 0;
}

/* Multi-select batch UI */
.col-check {
  width: 2.25rem;
  text-align: center;
  vertical-align: middle;
}
.col-check input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}
.receipts-table tr.is-selected td {
  background: rgba(201, 162, 39, 0.08);
}
.batch-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(201,162,39,0.12) 0%, rgba(23,29,37,0.95) 100%);
  position: sticky;
  top: 3.4rem;
  z-index: 5;
}
.batch-bar[hidden] { display: none !important; }
.batch-bar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 0 0 auto;
}
.batch-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
}
.batch-group {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex: 0 1 auto;
}
.batch-group select,
.batch-group input[type="text"] {
  width: auto;
  min-width: 9rem;
  max-width: 12rem;
  margin: 0;
  padding: 0.45rem 0.6rem;
}
.batch-bar .btn {
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
  white-space: nowrap;
}
@media (max-width: 800px) {
  .batch-bar {
    top: 0;
    position: relative;
  }
  .batch-bar-actions {
    justify-content: flex-start;
  }
}

.source-frame {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0c1015;
  display: block;
}
object.source-frame {
  background: #e8eef5;
}
.source-frame.tall { min-height: 70vh; }
.source-img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
}
.source-text {
  white-space: pre-wrap;
  margin: 0;
  max-height: 70vh;
  overflow: auto;
  padding: 0.75rem;
  background: #0c1015;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.source-card { overflow: hidden; }
