:root {
  /* Coors Light–inspired palette for internal tooling */
  --bg: #eef1f4;
  --surface: #ffffff;
  --border: #d4d9df;
  --text: #0d2240;
  --muted: #6a7280;
  --accent: #0a8fd6;
  --accent-soft: #dff0fb;
  --neg: #c0392b;
  --pos: #0a8fd6;
  --radius: 6px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.25rem;
}
.topbar .brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--accent);
  font-size: 1.1rem;
}
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.topbar nav a { text-decoration: none; color: var(--text); }
.topbar nav a:hover { color: var(--accent); }
.topbar .logout { margin-left: auto; }
.topbar .logout button {
  background: none; border: 1px solid var(--border);
  padding: 0.3rem 0.7rem; border-radius: var(--radius); cursor: pointer;
}

main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem; }
h1 { margin-top: 0; font-size: 1.5rem; }
h2 { font-size: 1.1rem; margin-top: 2rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.banner {
  background: var(--accent-soft); border: 1px solid var(--accent);
  padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem;
}
.error { color: var(--neg); }

table.data {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
table.data th, table.data td {
  text-align: left; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border);
}
table.data th { background: #fafaf7; font-weight: 600; font-size: 0.85rem; color: var(--muted); }
table.data tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.num.neg { color: var(--neg); }
.num.pos { color: var(--pos); }

.filter-bar { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.filter-bar label { display: inline-flex; gap: 0.4rem; align-items: center; }

.inline-form { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.inline-form input, .inline-form select, .upload-card input, .upload-card button, .filter-bar select, table.data select {
  padding: 0.4rem 0.55rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font: inherit;
}
button, .inline-form button, .upload-card button {
  padding: 0.4rem 0.9rem; border: 1px solid var(--accent); background: var(--accent); color: white;
  border-radius: var(--radius); cursor: pointer;
}
button:hover { filter: brightness(1.05); }

.upload-card {
  background: var(--surface); border: 1px dashed var(--border);
  padding: 1rem; border-radius: var(--radius);
  display: flex; gap: 0.75rem; align-items: center;
}

.gst-cell { display: inline-flex; gap: 0.5rem; align-items: center; }
.gst-toggle { padding: 0.2rem 0.55rem; font-size: 0.8rem; border-radius: 999px; cursor: pointer; }
.gst-toggle.off { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.gst-toggle.on { background: var(--accent); color: white; border: 1px solid var(--accent); }
.gst-amount { font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--muted); }

.row-updated { padding: 0.5rem 0.75rem; background: var(--accent-soft); }

/* Login */
.login-page {
  min-height: 100vh; display: grid; place-items: center; background: var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  padding: 2rem; border-radius: var(--radius); width: 320px; max-width: 90vw;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.login-card h1 { margin: 0 0 0.25rem; color: var(--accent); text-align: center; line-height: 1.15; }
.login-card .brand-sub { font-size: 0.7em; font-weight: 500; color: var(--muted); }

/* Receipts */
.receipt-clip { text-decoration: none; margin-left: 0.4rem; opacity: 0.6; }
.receipt-clip:hover { opacity: 1; }
.email-badge { font-size: 0.75rem; margin-left: 0.3rem; opacity: 0.7; }
.receipt-col { white-space: nowrap; }
.receipt-col .pill { font-size: 0.75rem; padding: 0.1rem 0.55rem; }

.desc-cell { min-width: 18rem; max-width: 28rem; word-break: break-word; }
.desc-cell .desc-text { margin-bottom: 0.25rem; }
.notes-input {
  width: 100%; padding: 0.2rem 0.4rem;
  border: 1px dashed transparent; border-radius: 3px; background: transparent;
  font: inherit; font-size: 0.8rem; color: var(--muted);
}
.notes-input:hover { border-color: var(--border); background: #f9fafb; }
.notes-input:focus {
  border-color: var(--accent); border-style: solid; background: var(--surface);
  color: var(--text); outline: none;
}
.notes-input:not(:placeholder-shown) { color: var(--text); font-style: italic; }
.card-badge {
  display: inline-block; margin-left: 0.3rem; padding: 0.05rem 0.4rem;
  border-radius: 3px; background: var(--accent-soft); color: var(--accent);
  font-size: 0.7rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.cat-input {
  padding: 0.4rem 0.55rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); font: inherit; min-width: 14rem;
}
.cat-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.cat-input.cat-set { border-color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.cat-meta { margin-top: 0.2rem; }

/* P&L */
.pnl-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
.pnl-header h1 { margin: 0; }
.pnl-period { color: var(--muted); font-size: 0.95rem; }
.pnl-controls {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
  margin: 0.75rem 0 1.25rem; padding: 0.75rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.pnl-quick-links { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-left: auto; align-items: center; }
.pnl-quick-links button { padding: 0.15rem 0.7rem; }
.pnl-quarters { margin: -0.5rem 0 1rem; margin-left: 0; }
.pnl-section { margin-bottom: 1.5rem; }
.pnl-section h2 {
  font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 0.25rem;
}
.pnl-table tfoot tr.total td, .pnl-table tr.total td {
  border-top: 2px solid var(--text); background: #fafaf7;
}
.pnl-table tr.grand-total td {
  font-size: 1.1rem; padding: 0.85rem 0.75rem; background: var(--accent-soft);
}
.banner.warn { background: #fff4e0; border-color: #f0d28a; color: #8a5a00; }

/* Per-page row search */
.search-bar { display: flex; align-items: center; gap: 0.6rem; margin: 0.75rem 0; }
.search-input {
  flex: 1; max-width: 32rem; padding: 0.4rem 0.7rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); font: inherit;
}
.search-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

@media print {
  .topbar, .pnl-controls, .pnl-section a { display: revert; }
  .topbar, .pnl-controls { display: none !important; }
  body { background: white; }
  main { max-width: none; padding: 0; }
  .pnl-section h2 { color: black; }
  a { color: black; text-decoration: none; }
  .banner.warn { background: white; border: 1px solid black; color: black; }
}

.receipt-grid {
  display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; margin: 1rem 0 2rem;
}
@media (max-width: 720px) { .receipt-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
}
.card h2 { margin-top: 0; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.kv { display: grid; grid-template-columns: 8rem 1fr; gap: 0.4rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: 0.85rem; }
.kv dd { margin: 0; }

.pill {
  display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px;
  font-size: 0.78rem; text-decoration: none; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
.pill.active { background: var(--accent); color: white; border-color: var(--accent); }
.pill.matched { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.pill.pending { background: #fff4e0; color: #8a5a00; border-color: #f0d28a; }
.pill.personal { background: #f0e8f8; color: #5a3a8a; border-color: #d6c8e8; }

.ocr-raw {
  background: #f4f6f8; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem; font-size: 0.8rem; overflow: auto; max-height: 300px;
}

/* Categorization suggestions + rules */
.suggestion {
  margin-top: 0.4rem; padding: 0.4rem 0.6rem; background: var(--accent-soft);
  border: 1px solid #b8d9ee; border-radius: var(--radius); font-size: 0.85rem;
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
}
.suggestion form { display: inline-flex; gap: 0.4rem; align-items: center; }
.suggestion button { padding: 0.2rem 0.6rem; font-size: 0.8rem; }

.link-btn {
  background: none; border: none; color: var(--accent); font-size: 0.75rem;
  cursor: pointer; padding: 0.2rem 0.3rem; margin-left: 0.3rem;
}
.link-btn:hover { text-decoration: underline; }

code {
  background: #f4f6f8; padding: 0.1rem 0.35rem; border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em;
}
.login-card input { padding: 0.55rem 0.65rem; border: 1px solid var(--border); border-radius: var(--radius); }
.login-card button { padding: 0.55rem; }

.readonly-bar {
  background: #fff4e0; color: #8a5a00; border-bottom: 1px solid #f0d28a;
  padding: 0.5rem 1rem; text-align: center; font-size: 0.9rem;
}
