/* Light Slate design system — approved tokens */
:root {
  --canvas: #F8FAFC;
  --panel: #FFFFFF;
  --border: #E2E8F0;
  --ink: #0F172A;
  --muted: #64748B;
  --accent: #4F46E5;
  --accent-soft: #EEF2FF;
  --ok: #059669;
  --ok-soft: #ECFDF5;
  --warn: #D97706;
  --warn-soft: #FFFBEB;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }

/* header */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: #fff; border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 20px;
  height: 56px; display: flex; align-items: center; gap: 28px;
}
.brand { font-weight: 800; font-size: 19px; color: var(--ink); letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  padding: 7px 12px; border-radius: 999px; color: var(--muted);
  font-weight: 500; font-size: 14px;
}
.topbar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.logout-form { margin: 0; }

/* layout */
.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-head .muted { margin: 0; }
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.panel.narrow { max-width: 560px; margin: 40px auto; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

/* stats */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 800px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat { display: flex; flex-direction: column; margin-bottom: 0; }
.stat-num { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }

/* table */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); padding: 8px 10px;
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table .small { font-size: 12px; color: var(--muted); }
.subject-cell { max-width: 380px; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }

/* pills */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.pill.current, .pill.paid, .pill.sent { background: var(--ok-soft); color: var(--ok); }
.pill.due_soon { background: var(--warn-soft); color: var(--warn); }
.pill.r1 { background: var(--accent-soft); color: var(--accent); }
.pill.r2 { background: var(--warn-soft); color: var(--warn); }
.pill.r3, .pill.escalated, .pill.draft { background: var(--danger-soft); color: var(--danger); }
.pill.0-30, .pill.31-60, .pill.61-90, .pill.90\+ { background: var(--warn-soft); color: var(--warn); }

/* buttons */
.btn {
  display: inline-block; border: 1px solid var(--border); background: #fff;
  color: var(--ink); border-radius: var(--radius); padding: 8px 14px;
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn:hover { border-color: #CBD5E1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4338CA; }
.btn.big { padding: 12px 22px; font-size: 16px; border-radius: 10px; }
.btn.tiny { padding: 4px 10px; font-size: 12px; }
.btn.ok { color: var(--ok); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--canvas); }

/* forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.input {
  width: 100%; margin-top: 4px; padding: 9px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; background: #fff; color: var(--ink);
}
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.input.file { padding: 6px; }
textarea.input { resize: vertical; font-family: ui-monospace, monospace; font-size: 13px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.inline-form { display: inline-flex; margin: 0; }
.auth-card { max-width: 400px; margin: 60px auto; }
.auth-card .btn { width: 100%; margin-top: 4px; }

/* flash */
.flash { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #A7F3D0; }
.flash.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #FECACA; }

/* landing */
.hero { text-align: center; padding: 70px 0 40px; }
.hero-badge {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 600; padding: 5px 14px; border-radius: 999px; margin-bottom: 20px;
}
.hero h1 { font-size: 44px; line-height: 1.1; margin-bottom: 16px; }
.hero h1 span { color: var(--accent); }
.hero-sub { max-width: 560px; margin: 0 auto 26px; color: var(--muted); font-size: 17px; }
.hero-cta { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.cta-note { color: var(--muted); font-size: 13px; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 800px) { .features { grid-template-columns: 1fr; } }
.landing-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 46px; }

/* due list / preview */
.due-list { list-style: none; margin: 0; padding: 0; }
.due-list li { padding: 9px 0; border-bottom: 1px solid var(--border); }
.due-list li:last-child { border-bottom: none; }
.muted { color: var(--muted); }
.note { font-size: 13px; }
.preview { position: relative; }
.preview-body {
  position: absolute; right: 0; top: 26px; z-index: 10; min-width: 340px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15,23,42,.12); padding: 12px;
  font-size: 12px; white-space: pre-wrap;
}
.tpl-block { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
