:root {
  --bg: #f4f5f3;
  --card: #ffffff;
  --ink: #16181a;
  --ink-2: #3f4448;
  --muted: #6b7280;
  --line: #dcdfe3;
  --accent: #1f6f3f;
  --warn: #9a6700;
  --warn-bg: #fff8e5;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --ok-bg: #eaf5ee;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.45; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1 1 0; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; width: 320px; display: grid; gap: 12px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 18px;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 15px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button { border: 0; background: none; padding: 7px 12px; border-radius: 7px;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tabs button:hover { background: var(--bg); }
.tabs button.active { background: var(--ok-bg); color: var(--accent); }
.pill { display: inline-flex; align-items: center; justify-content: center; min-width: 18px;
  height: 18px; padding: 0 5px; margin-left: 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; }
.pill.zero { background: var(--line); color: var(--muted); }
.link { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; }

main.tab { padding: 18px; max-width: 1180px; margin: 0 auto; }

/* controls */
input, select, textarea { width: 100%; padding: 7px 9px; margin-top: 3px; font: inherit;
  font-size: 13px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); }
select { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
label { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
button.primary, button.ghost, .btn { font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 13px; border-radius: 7px; cursor: pointer; border: 1px solid var(--line); background: #fff; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.danger { color: var(--danger); border-color: #f0c8c4; }
button.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
button:disabled { opacity: .45; cursor: default; }
button.small { padding: 5px 10px; font-size: 12.5px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.card.pad { padding: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfa; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.acts { text-align: right; white-space: nowrap; }
td.acts button { margin-left: 6px; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; }

/* the month bar */
.monthbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.monthbar h1 { min-width: 200px; }
.totals { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.tot { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; min-width: 130px; }
.tot b { display: block; font-size: 20px; }
.tot span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tot.owing { border-color: #f0c8c4; background: var(--danger-bg); }
.tot.owing b { color: var(--danger); }

/* how a month stands */
.state { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  border: 1px solid; display: inline-block; }
.state.paid { background: var(--ok-bg); border-color: #b9d8c6; color: #14532d; }
.state.due { background: #fff; border-color: var(--line); color: var(--muted); }
.state.chased { background: var(--warn-bg); border-color: #e6cf95; color: var(--warn); }
.state.written_off { background: var(--bg); border-color: var(--line); color: var(--muted); }

/* the yard */
.maptools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.maptools .sep { width: 1px; height: 20px; background: var(--line); }
.mapkey { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; flex-wrap: wrap; }
.mapkey i.sw { display: inline-block; width: 14px; height: 12px; border-radius: 3px; margin-right: 5px;
  vertical-align: -1px; border: 1px solid rgba(0,0,0,.15); }
.sw.let { background: #cfe6d8; } .sw.owing { background: #f7d2cd; }
.sw.empty { background: #ffffff; } .sw.gate { background: #d8e4ef; }
.yardwrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: auto; padding: 10px; }
.yard { position: relative; width: 1400px; height: 760px;
  background-image: linear-gradient(rgba(0,0,0,.05) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px);
  background-size: 24px 24px; border-radius: 6px; }
.box { position: absolute; border: 1.5px solid #9aa5ad; border-radius: 5px; background: #fff;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  cursor: grab; user-select: none; padding: 3px; overflow: hidden; }
.box:active { cursor: grabbing; }
.box .bname { font-weight: 700; font-size: 12.5px; line-height: 1.1; }
.box .bwho { font-size: 10.5px; color: var(--ink-2); line-height: 1.15; text-align: center;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.box.let { background: #cfe6d8; border-color: #6ea787; }
.box.owing { background: #f7d2cd; border-color: #d08b83; }
.box.owing .bname::after { content: " !"; color: var(--danger); }
.box.gate { background: #d8e4ef; border-color: #7ba7cf; border-style: dashed; }
.box.picked { outline: 3px solid var(--accent); outline-offset: 1px; z-index: 5; }

/* the side drawer */
.drawer { position: fixed; top: 0; right: 0; width: min(460px, 100%); height: 100%;
  background: var(--card); border-left: 1px solid var(--line); z-index: 40;
  display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,.08); }
.drawer-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 18px; overflow: auto; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.18); z-index: 30; }
.hist { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.hist li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.hist .when { color: var(--muted); font-size: 11.5px; }

/* messages, and the letter before it goes */
.msg { border: 1px solid; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }
.msg.ok { background: var(--ok-bg); border-color: #b9d8c6; color: #14532d; }
.msg.warn { background: var(--warn-bg); border-color: #e6cf95; color: var(--warn); }
.msg.error { background: var(--danger-bg); border-color: #f0c8c4; color: var(--danger); }
.letter { width: 100%; min-height: 300px; font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12.5px; line-height: 1.5; }
.confirm { background: var(--danger-bg); border: 1px solid #e3b4b0; border-radius: 8px;
  padding: 10px 12px; margin: 8px 0; font-size: 13px; }
.confirm .row { margin-top: 8px; }
.confirm .yes { background: #8b1f1f; border-color: #8b1f1f; color: #fff; }
