:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #7b8794;
  --line: #e1e5ea;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 0 24px; height: 56px; box-shadow: var(--shadow);
}
.brand { font-weight: 700; font-size: 17px; color: var(--ink); }
.topbar nav { display: flex; gap: 18px; }
.topbar nav a { color: var(--ink); font-weight: 500; }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.who { color: var(--muted); font-size: 14px; }
.logout { font-size: 14px; }
.role {
  display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 10px; font-weight: 700;
}
.role-admin { background: #fce7f3; color: #9d174d; }
.role-accounts { background: #e0e7ff; color: #3730a3; }
.role-expenses { background: #dcfce7; color: #166534; }

/* Layout */
.container { max-width: 1000px; margin: 26px auto; padding: 0 20px; }
.page-head, .detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.detail-head .sub, .sub { color: var(--muted); margin: 2px 0 0; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

/* Cards */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .cols { grid-template-columns: 1fr; } }
.auth-card, .form-card { max-width: 520px; margin: 40px auto; }
.or-divider { display: flex; align-items: center; text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; border-bottom: 1px solid var(--line); }
.or-divider span { padding: 0 12px; }

/* Forms */
label { display: block; margin: 0 0 14px; font-size: 13px; font-weight: 600; color: #52606d; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font-size: 14px;
  border: 1px solid #cbd2d9; border-radius: 7px; background: #fff; color: var(--ink);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.actions { display: flex; gap: 10px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 13px; }

/* Buttons */
.btn {
  display: inline-block; padding: 9px 15px; border-radius: 7px; border: 1px solid #cbd2d9;
  background: #fff; color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { text-decoration: none; background: #f8fafc; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Tables */
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.grid tbody tr:hover, .grid tbody tr:hover { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-draft { background: #f1f5f9; color: #94a3b8; }
.badge-await { background: #fef9c3; color: #854d0e; }
.badge-submitted { background: #dbeafe; color: #1e40af; }
.badge-queried { background: #fef3c7; color: #92400e; }
.badge-reconciled { background: #dcfce7; color: #166534; }

/* Summary pills */
.summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.summary-pill { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; box-shadow: var(--shadow); }
.summary-pill .count { font-size: 22px; font-weight: 700; margin-right: 8px; }
.summary-pill .lbl { color: var(--muted); font-size: 13px; }

.month-filter { margin-bottom: 16px; max-width: 260px; }

/* Key-value */
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-size: 14px; }

/* Notes */
.note { padding: 12px 15px; border-radius: 8px; margin: 16px 0; font-size: 14px; }
.note-query { background: #fef3c7; border: 1px solid #fde68a; color: #92400e; }
.note-comment { background: #eff6ff; border: 1px solid #dbeafe; color: #1e40af; }
.note-ok { background: #dcfce7; border: 1px solid #bbf7d0; color: #166534; }

.inline-form { display: flex; align-items: center; gap: 10px; margin: 0; }
.inline-form select { width: auto; margin-top: 0; }
.inline-form .chk { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-weight: 500; }
.inline-form .chk input { width: auto; margin: 0; }

.billing-open { display: block; margin-top: 6px; font-size: 13px; font-weight: 600; }
.billing-open a { display: inline-block; }

.ai-box { margin-top: 14px; padding: 12px 14px; border: 1px dashed #c7d2fe; background: #f5f7ff; border-radius: 8px; }
.ai-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #4338ca; margin-bottom: 8px; }

.action-bar { margin: 18px 0; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.history .ts { color: var(--muted); font-size: 13px; margin-right: 6px; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }

/* Spreadsheet grid — full width, no horizontal scroll */
.container.grid-page { max-width: none; width: 100%; padding: 20px 20px; }
.grid-tools { display: flex; gap: 10px; align-items: center; }
.month-inline select { margin-top: 0; width: auto; }
.sheet { border-collapse: collapse; width: 100%; table-layout: fixed; font-size: 13px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.sheet th { text-align: left; padding: 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); border-bottom: 1px solid var(--line); background: #f8fafc; }
.sheet td { padding: 2px 3px; border-bottom: 1px solid var(--line); border-right: 1px solid #eef1f4; vertical-align: middle; }
.sheet td:last-child { border-right: none; }
.sheet input, .sheet select { width: 100%; min-width: 0; margin: 0; border: 1px solid transparent; background: transparent; padding: 6px 5px; font-size: 13px; border-radius: 4px; }
.sheet input:hover:not([disabled]):not([readonly]), .sheet select:hover:not([disabled]) { border-color: #e2e8f0; }
.sheet input:focus, .sheet select:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 2px rgba(37,99,235,.12); }
.sheet input.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet input[disabled], .sheet select[disabled], .sheet input[readonly] { color: #334155; cursor: default; }
.sheet .cell-error input, .sheet input.cell-error { border-color: #ef4444; }
/* Fixed layout column widths (percent so they fill the viewport, no scroll) */
.c-item { width: 13%; } .c-vendor { width: 11%; } .c-bill { width: 12%; }
.c-amt { width: 7%; } .c-vat { width: 6%; } .c-date { width: 9%; } .c-assignee { width: 11%; }
.c-receipt { width: 6%; } .c-comment { width: 11%; }
.c-submit { width: 6%; text-align: center; } .c-status { width: 8%; } .c-actions { width: 12%; white-space: nowrap; text-align: center; }
.row-done td { background: #f6fdf9; }
.row-queried td { background: #fffbeb; }
.bill-in { font-size: 12px; }
.billing-open { padding: 0 2px; font-weight: 700; }
.billing-open a { text-decoration: none; }
.up-icon { cursor: pointer; font-size: 16px; padding: 2px 4px; }
.up-icon:hover { filter: brightness(1.1); }
.attach-link { text-decoration: none; font-size: 15px; padding: 2px; }
.scan-note { display: block; font-size: 10px; color: var(--muted); }
.note-row td { padding: 4px 10px; background: #fffbeb; }
.sheet .c-actions .btn, .sheet .c-submit .btn { padding: 4px 7px; font-size: 12px; }
.sheet .c-actions .btn { margin: 1px; }

/* Flashes */
.flashes { margin-bottom: 18px; }
.flash { padding: 11px 15px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-danger { background: #fee2e2; color: #991b1b; }
.flash-warning { background: #fef3c7; color: #92400e; }
.flash-info { background: #dbeafe; color: #1e40af; }
