:root {
  --bg: #1b1d21;
  --panel: #24272c;
  --panel-2: #2b2f35;
  --line: #33373d;
  --text: #e9eaec;
  --muted: #9ba1a8;
  --amber: #f0a21c;
  --amber-dim: #7a5510;
  --stage-lead: #8a919a;
  --stage-bidding: #f0a21c;
  --stage-submitted: #4c9be8;
  --stage-awarded: #3fa96c;
  --stage-lost: #b05252;
  --danger: #d4645c;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow', -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .num { font-family: 'Barlow Semi Condensed', 'Barlow', sans-serif; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--amber); outline-offset: 1px;
}
label { display: block; margin-bottom: 12px; font-weight: 500; color: var(--muted); font-size: 13px; }
label input, label select, label textarea { margin-top: 5px; color: var(--text); font-size: 15px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; }
.login-mark { font-size: 34px; color: var(--amber); line-height: 1; }
.login-card h1 { font-size: 26px; font-weight: 700; margin: 8px 0 2px; }
.login-sub { color: var(--muted); margin-bottom: 20px; }
.form-error { background: #3a2426; border: 1px solid var(--danger); color: #f0b9b5; border-radius: 8px; padding: 9px 12px; margin-bottom: 14px; font-size: 14px; }

/* ---------- chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  border-bottom: 1px solid var(--line); padding: 10px 14px 0;
}
.topbar-title { font-family: 'Barlow Semi Condensed'; font-weight: 700; font-size: 18px; }
.topbar-title .mark { color: var(--amber); }
.entity-chips { display: flex; gap: 8px; padding: 10px 0; overflow-x: auto; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 13px;
  color: var(--muted); white-space: nowrap; font-size: 14px;
}
.chip-on { background: var(--amber); border-color: var(--amber); color: #221a05; font-weight: 600; }

main { padding: 14px 14px 90px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; padding: 13px 0 11px; color: var(--muted); font-size: 14px; font-weight: 500; border-top: 2px solid transparent; }
.tab-on { color: var(--amber); border-top-color: var(--amber); }

.fab {
  position: fixed; right: 16px; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 21;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--amber); color: #221a05; font-size: 30px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- pipeline board ---------- */
.board {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -14px; padding: 0 14px 8px;
}
.stage-col {
  flex: 0 0 84%; max-width: 320px; scroll-snap-align: start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; align-self: flex-start;
}
@media (min-width: 900px) {
  .board { flex-wrap: nowrap; }
  .stage-col { flex: 0 0 280px; max-width: 280px; }
}
.stage-head { display: flex; align-items: baseline; gap: 8px; padding: 2px 4px 10px; }
.stage-name { font-family: 'Barlow Semi Condensed'; font-weight: 600; font-size: 16px; }
.stage-count { color: var(--muted); font-size: 13px; }
.stage-total { margin-left: auto; color: var(--muted); font-size: 13px; }

.deal-card {
  position: relative; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px 10px 16px; margin-bottom: 8px;
  width: 100%; text-align: left; display: block;
}
.deal-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  border-radius: 8px 0 0 8px; background: var(--rail, var(--stage-lead));
}
.deal-name { font-weight: 600; }
.deal-co { color: var(--muted); font-size: 13px; margin-top: 1px; }
.deal-meta { display: flex; gap: 10px; margin-top: 7px; font-size: 13px; align-items: center; flex-wrap: wrap; }
.deal-value { font-family: 'Barlow Semi Condensed'; font-weight: 600; color: var(--text); }
.deal-entity { border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; color: var(--muted); font-size: 12px; }
.deal-due { color: var(--muted); }
.due-soon { color: var(--amber); font-weight: 600; }
.due-past { color: var(--danger); font-weight: 600; }
.empty-col { color: var(--muted); font-size: 13px; padding: 6px 4px 10px; }

/* ---------- lists ---------- */
.searchbar { margin-bottom: 12px; }
.row-card {
  width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; display: block;
}
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 13px; margin-top: 1px; }
.row-actions { display: flex; gap: 14px; margin-top: 8px; }
.row-actions a { color: var(--amber); text-decoration: none; font-size: 14px; font-weight: 500; }
.list-empty { color: var(--muted); text-align: center; padding: 40px 20px; }

/* ---------- sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--panel); border: 1px solid var(--line); border-bottom: none;
  border-radius: 16px 16px 0 0; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 14px; border-bottom: 1px solid var(--line); }
}
.sheet h2 { font-size: 20px; font-weight: 700; margin-bottom: 14px; }
.sheet-row { display: flex; gap: 10px; }
.sheet-row > label { flex: 1; }
.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }

.btn { border-radius: 8px; padding: 11px 16px; font-weight: 600; }
.btn-primary { background: var(--amber); color: #221a05; }
.btn-quiet { background: var(--panel-2); border: 1px solid var(--line); }
.btn-danger-link { color: var(--danger); padding: 11px 6px; font-weight: 500; }
.btn-block { width: 100%; }

/* ---------- detail ---------- */
.detail-head { margin-bottom: 12px; }
.detail-head h2 { margin-bottom: 2px; }
.detail-sub { color: var(--muted); }
.stage-select-wrap { margin: 12px 0; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv .k { color: var(--muted); }
.notes-block { margin-top: 16px; }
.notes-block h3 { font-size: 15px; margin-bottom: 8px; }
.note-item { border-bottom: 1px solid var(--line); padding: 8px 0; font-size: 14px; }
.note-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.note-add { display: flex; gap: 8px; margin-top: 10px; }
.note-add input { flex: 1; }
.link { color: var(--amber); text-decoration: none; }

@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: up .18s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
}
