:root {
  --paper: #F6F3EC;
  --ink: #23271F;
  --line: #DAD4C4;
  --line-soft: #E9E4D6;
  --muted: #8A8371;
  --accent: #4C6B57;
  --danger: #9C4A3C;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
.loading { padding: 40px; color: var(--muted); font-style: italic; }
.page { max-width: 980px; margin: 0 auto; padding: 20px 20px 60px; }
h1, h2 { font-family: Georgia, "Iowan Old Style", serif; font-weight: 600; margin: 0; }
h1 { font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin-bottom: 14px; }
.muted { color: var(--muted); }
.error-text { color: var(--danger); font-size: 13px; margin: -6px 0 12px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 22px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.brand { font-family: Georgia, serif; font-size: 18px; display: flex; align-items: center; gap: 6px; }
.brand-mark { color: var(--accent); font-size: 20px; }
.identity-chip { display: flex; align-items: center; gap: 14px; }
.identity-text { display: flex; flex-direction: column; align-items: flex-end; font-size: 13px; line-height: 1.4; }
.identity-role { color: var(--muted); font-size: 12px; }

.card { max-width: 420px; margin: 60px auto; background: #fff; border: 1px solid var(--line); padding: 32px; border-radius: 4px; }
.card h1 { margin-bottom: 6px; }
.card p { margin: 0 0 22px; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 13px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
input, select, textarea {
  font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 3px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.hq-row { display: flex; gap: 8px; align-items: center; }

.btn-primary { background: var(--ink); color: #fff; border: none; padding: 10px 18px; border-radius: 3px; font: inherit; cursor: pointer; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary { background: #fff; border: 1px solid var(--ink); padding: 8px 14px; border-radius: 3px; font: inherit; cursor: pointer; }
.btn-link { background: none; border: none; color: var(--accent); font: inherit; font-size: 12.5px; cursor: pointer; padding: 2px 4px; text-decoration: underline; text-underline-offset: 2px; }
.btn-link:hover { color: var(--ink); }
.btn-link.danger { color: var(--danger); }
.btn-link.muted { color: var(--muted); }

.view-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.stat-row { display: flex; gap: 22px; }
.stat { display: flex; flex-direction: column; text-align: right; }
.stat strong { font-size: 20px; font-family: Georgia, serif; }
.stat span { font-size: 11px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 20px; margin-bottom: 20px; }
.divider { height: 1px; background: var(--line-soft); margin: 20px 0; }

.emp-list { list-style: none; margin: 12px 0 0; padding: 0; font-size: 13px; max-height: 280px; overflow-y: auto; overflow-x: hidden; border-top: 1px solid var(--line-soft); }
.emp-list li { padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.emp-list li:last-child { border-bottom: none; }
.emp-row-main { display: flex; justify-content: space-between; align-items: center; }
.emp-companies { font-size: 12px; margin-top: 2px; }

.combobox-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  background: #fff; border: 1px solid var(--line); border-top: none;
  max-height: 220px; overflow-y: auto; box-shadow: 0 6px 14px rgba(0,0,0,0.08);
}
.combobox-item { padding: 8px 10px; font-size: 13px; cursor: pointer; }
.combobox-item:hover { background: #FBF9F4; }
.combobox-empty { padding: 8px 10px; font-size: 13px; }

.checkbox-list { margin-top: 8px; padding: 10px; background: #FBF9F4; border-radius: 3px; }
.checkbox-row { display: block; font-size: 13px; padding: 3px 0; }

.selectable-item { cursor: pointer; border-radius: 3px; padding: 6px 8px; transition: background 0.1s; }
.selectable-item:hover { background: #FBF9F4; }
.selectable-item.selected { background: #E4EFE6; box-shadow: inset 0 0 0 1px var(--accent); }
.assoc-summary { font-size: 13px; line-height: 1.6; background: #FBF9F4; padding: 10px 12px; border-radius: 3px; }

.bulk-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 20px; margin-bottom: 16px; }
.bulk-chip { background: #FBF9F4; border: 1px solid var(--line-soft); border-radius: 12px; padding: 4px 10px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters select, .filters input { width: auto; }
.filters input { flex: 1; min-width: 160px; }

table.ledger-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ledger-table th { text-align: left; font-weight: 600; font-size: 11px; color: var(--muted); padding: 0 8px 8px; border-bottom: 1px solid var(--line); }
.ledger-table td { padding: 9px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.ledger-table .num { text-align: right; }
.ledger-table th.num { text-align: right; }
.ledger-table input { width: auto; }
.ledger-table .actions { text-align: right; white-space: nowrap; }
.note-row td { background: #FBF9F4; font-size: 12.5px; color: var(--muted); padding: 6px 8px 12px; }
.reject-inline { display: flex; gap: 8px; align-items: center; }

.pill { display: inline-block; padding: 3px 9px; border-radius: 10px; font-size: 11.5px; font-weight: 600; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 4px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,0.15); }

.role-toggle { display: flex; gap: 10px; margin-bottom: 16px; }
.role-btn { flex: 1; text-align: left; padding: 12px; border: 1px solid var(--line); background: #fff; border-radius: 3px; cursor: pointer; font: inherit; }
.role-btn small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; font-weight: normal; }
.role-btn.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.overflow-x { overflow-x: auto; }
