:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --ink: #1d1f1e;
  --ink-2: #555b58;
  --ink-3: #8a908c;
  --line: #e2e3de;
  --line-2: #d0d2cc;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0ec;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --bad: #a3282b;
  --bad-soft: #fbe6e6;
  --ok: #26734d;
  --ok-soft: #e2f3e9;
  --personal: #6b4fa3;
  --personal-soft: #eee8f8;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 1px rgba(0, 0, 0, .03);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 6px; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
code { background: #eef0ec; padding: 1px 4px; border-radius: 4px; }

/* top bar */
.top { display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 52px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
.top .brand { font-weight: 700; font-size: 16px; color: #fff; letter-spacing: .2px; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { color: #cfd3d0; padding: 6px 10px; border-radius: 6px; }
.top nav a.on, .top nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; text-decoration: none; }
.top .me { display: flex; align-items: center; gap: 10px; color: #cfd3d0; }
.top .me button { background: none; border: 1px solid #555; color: #cfd3d0; border-radius: 6px; padding: 3px 8px; cursor: pointer; }

main { padding: 20px; max-width: 1280px; margin: 0 auto; }
main.wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.flash { background: var(--accent-soft); border: 1px solid #bfdcd3; padding: 8px 12px; border-radius: var(--radius); margin-bottom: 14px; }
.alert { background: var(--warn-soft); border: 1px solid #f0d7a8; padding: 8px 12px; border-radius: var(--radius); margin-bottom: 14px; }
.alert.bad { background: var(--bad-soft); border-color: #efc2c2; }

/* forms */
label { display: block; font-weight: 600; font-size: 12px; color: var(--ink-2); margin-bottom: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line-2); border-radius: 6px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { margin-bottom: 10px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.check { display: flex; gap: 6px; align-items: center; font-weight: normal; color: var(--ink); font-size: 14px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 4px; margin: 0 0 10px; }
fieldset[disabled] { display: none; }
legend { font-weight: 600; padding: 0 4px; }

.btn, button.btn { display: inline-block; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--accent); }
.btn.small { padding: 3px 9px; font-size: 12px; font-weight: 600; }
.btn.danger { background: #fff; color: var(--bad); border-color: #e3b3b3; }
.linkish { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
.linkish.danger { color: var(--bad); }
form.inline { display: inline; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--ink-2); font-weight: 600; background: #fafaf8; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* badges */
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #eceeea; color: var(--ink-2); white-space: nowrap; }
.badge.personal { background: var(--personal-soft); color: var(--personal); }
.badge.group { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }

/* board */
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters .field { margin: 0; min-width: 160px; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.col { background: #ecece7; border-radius: var(--radius); padding: 8px; min-height: 200px; }
.col.lost { background: #efe9e9; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 8px; font-weight: 700; font-size: 13px; }
.col-head .n { color: var(--ink-3); font-weight: 600; }
.cards { min-height: 150px; display: flex; flex-direction: column; gap: 8px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); cursor: grab; }
.card:active { cursor: grabbing; }
.card a.title { display: block; font-weight: 700; color: var(--ink); }
.card .cust { font-size: 12px; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: 12px; color: var(--ink-2); }
.card ul.prices { list-style: none; padding: 6px 0 0; margin: 6px 0 0; border-top: 1px dashed var(--line); font-size: 12px; }
.card ul.prices li { display: flex; justify-content: space-between; gap: 8px; }
.card ul.prices li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .reason { font-size: 12px; color: var(--bad); margin-top: 4px; }
.progress { height: 4px; background: #eceeea; border-radius: 3px; overflow: hidden; width: 60px; display: inline-block; vertical-align: middle; }
.progress > i { display: block; height: 100%; background: var(--accent); }
.sortable-ghost { opacity: .4; }
.stale { color: var(--warn); font-weight: 600; }

/* opportunity page */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 4px 0; display: flex; gap: 8px; align-items: flex-start; }
.checklist li .by { font-size: 11px; color: var(--ink-3); }
.item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.item.child { margin-left: 28px; border-left: 3px solid var(--line-2); }
.item-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.item-name { font-weight: 700; }
.match { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 8px; font-size: 13px; }
.match table td, .match table th { padding: 4px 6px; }
table:not(.show-expired) tr.expired-row { display: none; }
.warnings { margin: 2px 0 0; padding-left: 18px; color: var(--warn); font-size: 12px; }
.quote { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
.quote .terms { font-size: 12px; color: var(--ink-2); display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 14px; margin: 6px 0; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
details > summary { cursor: pointer; font-weight: 600; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }

/* dashboard */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--line-2); }
.tile-label { font-size: 12px; color: var(--ink-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.tile-sub { font-size: 11px; color: var(--ink-3); }
.tasklist { list-style: none; margin: 0; padding: 0; }
.tasklist li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.tasklist li:last-child { border-bottom: none; }
.tasklist .ti { width: 20px; text-align: center; color: var(--ink-3); flex: none; }
.tasklist li.p1 .ti { color: var(--bad); }
.tasklist li.p2 .ti { color: var(--warn); }
.checkbtn { background: none; border: none; font-size: 16px; cursor: pointer; padding: 0; width: 20px; color: var(--ink-2); }

/* login */
.auth { max-width: 360px; margin: 10vh auto; }
.auth h1 { margin-bottom: 14px; }
