:root {
  --bg: #0f1419;
  --panel: #1a212b;
  --panel-2: #222c38;
  --border: #2c3846;
  --text: #e6edf3;
  --muted: #8b97a6;
  --accent: #f5a623;
  --green: #2ea043;
  --amber: #d29922;
  --red: #e5534b;
  --blue: #388bfd;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); margin-top: 8px; min-height: 18px; font-size: 13px; }

/* --- Login --- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px; width: 320px; display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 0; font-size: 26px; }
.login-card p { margin: 0 0 8px; }
.login-card input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 12px; color: var(--text); font-size: 14px;
}
.login-card button {
  background: var(--accent); color: #1a1206; border: 0; border-radius: 8px;
  padding: 11px; font-weight: 600; cursor: pointer; font-size: 14px;
}

/* --- Topbar --- */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 17px; }
.spacer { flex: 1; }
.stats { display: flex; gap: 14px; color: var(--muted); font-size: 13px; }
.stats b { color: var(--text); }
.stats .alert { color: var(--red); }
.who { color: var(--muted); font-size: 13px; }
.search {
  background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 11px; color: var(--text); font-size: 13px; width: 300px; max-width: 34vw;
}
.search:focus { outline: none; border-color: var(--blue); }
button.ghost, a.ghost {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; padding: 6px 11px; cursor: pointer; font-size: 13px; text-decoration: none;
}
button.ghost:hover, a.ghost:hover { background: var(--panel-2); }

/* --- Board --- */
.board {
  display: flex; gap: 12px; padding: 14px; overflow-x: auto; align-items: flex-start;
  height: calc(100vh - 53px);
}
.col {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  min-width: 290px; max-width: 290px; display: flex; flex-direction: column; max-height: 100%;
}
.col-head {
  padding: 10px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--panel); border-radius: 10px 10px 0 0;
}
.col-head-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.col-head .name { font-weight: 600; }
.col-head .meta { font-size: 12px; color: var(--muted); }
.col-head .amt { font-size: 17px; color: var(--accent); font-weight: 700; margin-top: 3px; }
.col.paid .col-head .amt { color: var(--green); }
.col-body { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }

/* --- Card --- */
.card {
  background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--muted);
  border-radius: 8px; padding: 10px; cursor: pointer;
}
.card:hover { border-color: var(--blue); }
.card.h-green { border-left-color: var(--green); }
.card.h-amber { border-left-color: var(--amber); }
.card.h-red { border-left-color: var(--red); }
.card.h-paid { border-left-color: var(--green); opacity: .75; }
.card .cust { font-weight: 600; margin-bottom: 2px; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }
.card .inv { color: var(--muted); font-size: 12px; }
.card .bal { font-weight: 700; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 10px;
  background: var(--border); color: var(--text);
}
.badge.new { background: #30363d; }
.badge.contacted { background: #1f3a5f; color: #9cc7ff; }
.badge.promised { background: #1f4023; color: #8fe3a0; }
.badge.disputed { background: #5a1f1f; color: #ffb3ad; }
.badge.hold { background: #4a3a12; color: #f0d68a; }

/* --- Drawer --- */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.drawer-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: 440px; max-width: 92vw;
  background: var(--panel); border-left: 1px solid var(--border); overflow-y: auto; padding: 18px;
}
.drawer-panel h2 { margin: 0 0 4px; }
.drawer-panel .field { margin: 12px 0; }
.drawer-panel label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.drawer-panel input, .drawer-panel select, .drawer-panel textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
  padding: 8px 10px; color: var(--text); font-size: 13px; font-family: inherit;
}
.drawer-panel .kv { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border); }
.drawer-panel .kv span:first-child { color: var(--muted); }
.btn-row { display: flex; gap: 8px; margin-top: 8px; }
.btn {
  background: var(--accent); color: #1a1206; border: 0; border-radius: 7px;
  padding: 9px 12px; font-weight: 600; cursor: pointer; font-size: 13px;
}
.btn.sec { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.log-entry { border-top: 1px solid var(--border); padding: 8px 0; font-size: 13px; }
.log-entry .when { color: var(--muted); font-size: 12px; }
.section-title { margin: 18px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
