:root {
  --bg: #f7f6f2;
  --paper: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e3e0d8;
  --accent: #1f3a5f;
  --accent-2: #c69749;
  --ok: #2f7a3f;
  --warn: #b6731a;
  --bad: #a8332b;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px; line-height: 1.55;
}
a { color: var(--accent); }
a:hover { color: var(--accent-2); }

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

.topbar { background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 24px; min-height: 64px; }
.brand { font-weight: 700; font-size: 22px; text-decoration: none; color: var(--accent); letter-spacing: 0.5px; }
.brand .dot { color: var(--accent-2); }
.mainnav { display: flex; gap: 18px; margin-left: 18px; flex: 1; flex-wrap: wrap; }
.mainnav a { text-decoration: none; color: var(--ink); padding: 6px 2px; border-bottom: 2px solid transparent; }
.mainnav a:hover { border-bottom-color: var(--accent-2); }
.userbar { display: flex; gap: 10px; align-items: center; }
.hello { color: var(--muted); font-size: 14px; }

.messages { padding: 8px 0; }
.msg { padding: 10px 14px; border-radius: 4px; margin-bottom: 8px; }
.msg-success { background: #e7f0e3; color: var(--ok); }
.msg-error, .msg-danger { background: #f4dedb; color: var(--bad); }
.msg-info { background: #e3ebf4; }

h1, h2, h3 { color: var(--accent); font-weight: 600; }
h1 { font-size: 28px; margin: 28px 0 10px; }
h2 { font-size: 22px; margin: 24px 0 10px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
h3 { font-size: 18px; margin: 18px 0 6px; }

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 4px; padding: 20px; margin-bottom: 20px;
}
.card h2:first-child { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat { background: var(--paper); border: 1px solid var(--line); padding: 14px 16px; border-radius: 4px; }
.stat .n { font-size: 32px; font-weight: 700; color: var(--accent); line-height: 1; }
.stat .l { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }

table { width: 100%; border-collapse: collapse; background: var(--paper); }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f1ede4; color: var(--accent); font-weight: 600; font-size: 14px; }
tr:hover td { background: #faf8f2; }

.btn, .btn-primary, .btn-ghost, .btn-danger {
  display: inline-block; padding: 8px 16px; border-radius: 3px; text-decoration: none;
  cursor: pointer; border: 1px solid var(--accent); background: var(--paper);
  color: var(--accent); font-family: inherit; font-size: 15px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #15273f; color: #fff; }
.btn-ghost { border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-danger:hover { background: #872820; color: #fff; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

form .row { margin-bottom: 14px; }
form label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
form input[type="text"], form input[type="email"], form input[type="password"],
form input[type="number"], form input[type="url"], form input[type="date"],
form textarea, form select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 3px; font-family: inherit; font-size: 15px; background: #fff;
}
form textarea { font-family: inherit; }
form .help { color: var(--muted); font-size: 13px; margin-top: 3px; }
form .errors { color: var(--bad); font-size: 13px; margin-top: 3px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.pill-lead { background: #e3ebf4; color: var(--accent); }
.pill-client { background: #e7f0e3; color: var(--ok); }
.pill-paused { background: #faedd6; color: var(--warn); }
.pill-former { background: #ede9e1; color: var(--muted); }
.pill-internal { background: #e8e4f5; color: #4a3b8a; }
.pill-draft { background: #ede9e1; color: var(--muted); }
.pill-ready { background: #e3ebf4; color: var(--accent); }
.pill-done { background: #e7f0e3; color: var(--ok); }
.pill-open { background: #faedd6; color: var(--warn); }
.pill-in_progress { background: #e3ebf4; color: var(--accent); }

.small { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin: 14px 0; flex-wrap: wrap; }
.searchbar input[type="search"], .searchbar input[type="text"] { min-width: 240px; }
.footer { margin-top: 60px; padding: 20px 0; border-top: 1px solid var(--line); background: var(--paper); }

.login-wrap {
  max-width: 380px; margin: 80px auto; background: var(--paper);
  border: 1px solid var(--line); border-radius: 4px; padding: 30px;
}
.login-wrap h1 { text-align: center; margin-top: 0; }

.progress { background: var(--line); border-radius: 3px; height: 8px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }

.q-block { border-left: 3px solid var(--line); padding: 6px 12px; margin: 10px 0; }
.q-block.required { border-left-color: var(--accent-2); }
.q-heading { border: none; background: #f1ede4; padding: 10px 14px; font-weight: 600; color: var(--accent); margin-top: 18px; }
.q-hidden { display: none; }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 6px 16px; }
.kv .k { color: var(--muted); font-size: 14px; }
.kv .v { word-break: break-word; }
pre.box { background: #f4f0e6; padding: 12px; border-radius: 3px; overflow-x: auto; white-space: pre-wrap; }
