:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --brand: #1d4ed8;
  --brand-ink: #ffffff;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --blue: #1d4ed8;
  --blue-bg: #dbeafe;
  --green: #15803d;
  --green-bg: #dcfce7;
  --danger: #b91c1c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--ink);
  color: #fff;
}
.brand { font-weight: 700; font-size: 18px; }
.brand span { font-weight: 400; color: #94a3b8; margin-left: 6px; }
.acting-as { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.acting-as select { padding: 4px 8px; border-radius: 6px; border: none; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 24px 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.card h2 { margin-top: 0; font-size: 16px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.filters label { font-size: 13px; color: var(--muted); }
.filters select { margin-left: 6px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); }
.bulk-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#selectedCount { font-size: 12px; color: var(--muted); margin-right: 4px; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: #f8fafc; }

/* Column widths tuned so the whole table fits without horizontal scrolling. */
#expensesTable th:nth-child(1), #expensesTable td:nth-child(1) { width: 32px; }
#expensesTable th:nth-child(2), #expensesTable td:nth-child(2) { width: 88px; font-variant-numeric: tabular-nums; font-size: 12px; }
#expensesTable th:nth-child(3), #expensesTable td:nth-child(3) { width: 130px; white-space: normal; }
#expensesTable th:nth-child(4), #expensesTable td:nth-child(4) { width: auto; }
#expensesTable th:nth-child(5), #expensesTable td:nth-child(5),
#expensesTable th:nth-child(6), #expensesTable td:nth-child(6) { width: 80px; text-align: right; }
#expensesTable th:nth-child(7), #expensesTable td:nth-child(7) { width: 150px; white-space: normal; }
#expensesTable th:nth-child(8), #expensesTable td:nth-child(8) { width: 90px; }
#expensesTable th:nth-child(9), #expensesTable td:nth-child(9) { width: 36px; }

.wrap-cell { white-space: normal; word-break: break-word; overflow: visible; text-overflow: clip; }

.files-cell { white-space: normal; overflow: visible; }
.files-cell a { display: inline-block; margin-right: 4px; font-weight: 600; }
.file-count-zero { color: var(--muted); }
.btn-icon {
  border: none; background: #eef2ff; color: var(--brand); border-radius: 6px;
  font-size: 11px; padding: 2px 6px; cursor: pointer; margin-left: 4px;
}
.hidden-file-input { display: none; }

.badge { padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge.submitted { background: var(--amber-bg); color: var(--amber); }
.badge.validated { background: var(--blue-bg); color: var(--blue); }
.badge.paid { background: var(--green-bg); color: var(--green); }

.totals { padding: 12px 4px; text-align: right; font-size: 13px; color: var(--muted); }
.totals b { color: var(--ink); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form-grid .full { grid-column: 1 / -1; }
input, select { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px; font-family: inherit; color: var(--ink); background: #fff; }

.btn { border: none; border-radius: 8px; padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.secondary { background: #e2e8f0; color: var(--ink); }
.btn.success { background: #15803d; color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { background: #fee2e2; color: var(--danger); }

.msg { font-size: 12px; color: var(--muted); margin-left: 10px; }
.msg.ok { color: var(--green); }
.msg.err { color: var(--danger); }

a { color: var(--brand); }

#expensesBody tr { cursor: pointer; }

.modal-overlay[hidden] { display: none; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 100;
}
.modal-panel {
  background: var(--card); border-radius: 12px; width: 100%; max-width: 720px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-head .btn-icon { background: #f1f5f9; font-size: 14px; padding: 4px 9px; }
.modal-body { padding: 20px; max-height: 65vh; overflow-y: auto; }
.modal-body h3 { font-size: 13px; color: var(--muted); margin: 4px 0 8px; text-transform: uppercase; letter-spacing: .03em; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}
.modal-foot .msg { margin-right: auto; margin-left: 0; }

.detail-meta { font-size: 12px; color: var(--muted); }

.file-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; align-items: center; justify-content: space-between; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.file-list li a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 8px; }
.file-list .empty { color: var(--muted); font-style: italic; background: none; border: none; padding: 4px 0; }

.add-file-label {
  display: inline-block; background: #eef2ff; color: var(--brand); border-radius: 8px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.add-file-label input { display: none; }

.activity-list { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.activity-list b { color: var(--ink); }

[readonly], select:disabled { background: #f8fafc; color: var(--muted); }
