:root {
  --accent: #0f6e63;
  --accent-dark: #0a4f47;
  --accent-light: #e3f1ee;
  --text: #1f2a2e;
  --muted: #5f6b70;
  --line: #d9dfe2;
  --bg: #f6f8f8;
  --card: #ffffff;
  --ok: #1a7f4b;
  --err: #a83232;
  --warn: #9a6700;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; color: var(--text); background: var(--bg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1 { font-size: 1.6rem; margin: 0.2em 0 0.6em; font-weight: 600; }
h2 { font-size: 1.2rem; margin: 1.2em 0 0.5em; font-weight: 600; }
h3 { font-size: 1rem; margin: 1em 0 0.4em; font-weight: 600; }
p { margin: 0.4em 0 0.8em; }
code { background: #eef1f2; padding: 1px 5px; border-radius: 4px; font-size: 0.92em; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 560px; }
main.wrap { padding-top: 18px; padding-bottom: 40px; }

/* header */
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; min-height: 56px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); padding: 12px 0; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--text); padding: 8px 10px; border-radius: 6px; }
.nav a:hover { background: var(--accent-light); }
.nav a.active { background: var(--accent); color: #fff; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; font: inherit; cursor: pointer; }
@media (max-width: 820px) {
  .menu-btn { display: inline-block; }
  .nav { display: none; width: 100%; flex-direction: column; padding-bottom: 10px; }
  .nav.open { display: flex; }
  .nav a { padding: 10px 12px; }
}
.foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.85rem; padding: 10px 16px 30px; border-top: 1px solid var(--line); }

/* flash */
.flash { padding: 10px 14px; border-radius: 6px; margin: 0 0 14px; border: 1px solid var(--line); background: var(--card); }
.flash-ok { border-color: #bfe3cc; background: #eef9f2; color: var(--ok); }
.flash-error { border-color: #efc4c4; background: #fcefef; color: var(--err); }
.flash-info { border-color: #cfe0ec; background: #eef5fa; }

/* cards and grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.measure { text-align: center; }
.measure .num { font-size: 2rem; font-weight: 700; color: var(--accent); display: block; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.row-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: #f0f3f4; font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: none; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--accent-light); }
.table th a { color: var(--text); text-decoration: none; }
.table th a.sorted::after { content: " \2193"; }
.table th a.sorted.asc::after { content: " \2191"; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* forms */
label { display: block; margin-bottom: 10px; font-size: 0.92rem; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel],
input[type=date], input[type=datetime-local], input[type=search], input[type=month], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; color: var(--text); background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
textarea.tall { min-height: 220px; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.88rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-light); border-color: var(--accent); }
.form-grid { display: grid; gap: 4px 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline label { margin-bottom: 0; flex: 1; min-width: 140px; }
.inline label.w-sm { flex: 0 0 150px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; }
.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 6px;
  padding: 8px 14px; font: inherit; cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { background: var(--accent-dark); color: #fff; }
.btn.secondary { background: #fff; color: var(--accent); }
.btn.secondary:hover { background: var(--accent-light); }
.btn.danger { background: #fff; color: var(--err); border-color: #e2b4b4; }
.btn.sm { padding: 4px 10px; font-size: 0.88rem; }
.btn.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; }
form.inline-form { display: inline; }

/* badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.8rem; background: #eef1f2; color: var(--text); white-space: nowrap; }
.badge.ok { background: #e4f4ea; color: var(--ok); }
.badge.warn { background: #fbf1d6; color: var(--warn); }
.badge.err { background: #f9e3e3; color: var(--err); }
.badge.accent { background: var(--accent-light); color: var(--accent-dark); }

/* tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--text); border-radius: 6px 6px 0 0; }
.tabs a.active { background: var(--card); border: 1px solid var(--line); border-bottom-color: var(--card); margin-bottom: -1px; }

/* tasks */
.tasks { list-style: none; padding: 0; margin: 0; }
.tasks li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tasks li:last-child { border-bottom: none; }
.tasks li.done { color: var(--muted); text-decoration: line-through; }
.tasks input[type=checkbox] { margin-top: 5px; }

/* notes */
.note { border-left: 3px solid var(--accent-light); padding: 4px 10px; margin: 6px 0; white-space: pre-wrap; }

/* pipeline */
.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.col { flex: 0 0 240px; background: #eef1f2; border-radius: 8px; padding: 8px; min-height: 120px; }
.col h3 { margin: 4px 4px 8px; font-size: 0.92rem; display: flex; justify-content: space-between; }
.col.over { outline: 2px dashed var(--accent); }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; cursor: grab; font-size: 0.9rem; }
.kcard a { color: var(--text); text-decoration: none; font-weight: 600; }
.kcard .muted { display: block; font-size: 0.82rem; }
.kcard.dragging { opacity: 0.5; }

/* charts */
.chart { width: 100%; max-width: 640px; height: auto; display: block; }
.chart rect { fill: var(--accent); }
.chart rect:hover { fill: var(--accent-dark); }
.chart text { font-size: 11px; fill: var(--muted); }
.chart line.target { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 4; }

/* preview */
.preview { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 16px; min-height: 120px; }
.copy { font-size: 0.85rem; }
.pager { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
@media (max-width: 600px) {
  h1 { font-size: 1.35rem; }
  .foot { flex-direction: column; gap: 4px; }
  dl.kv { grid-template-columns: 1fr; }
}
