:root {
  --accent: #FF6B2B; --accent-bright: #FF8A50; --accent-deep: #D8541D; --accent-soft: rgba(255, 107, 43, .13);
  --bg-deep: #070B11; --bg: #0B1017; --surface: #121A26; --surface-2: #0E1520; --surface-3: #182231;
  --line: #22304A; --line-strong: #2E4162; --text: #C6D1E2; --muted: #8B9BB4; --heading: #F0F4FA;
  --ok: #46C08A; --warn: #E8B04B; --bad: #E05A5A; --radius: 10px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: Consolas, "Cascadia Mono", "Courier New", monospace;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 10px 28px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); -webkit-text-size-adjust: 100%; }
a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); color: var(--heading); font-weight: 600; margin: 0 0 .5rem; letter-spacing: .01em; }
h1 { font-size: 1.6rem; outline: none; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: .5rem .65rem; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: auto; padding: 0; margin: 0; }
select option { background: var(--surface-2); }
select.auto { width: auto; }
textarea { min-height: 90px; resize: vertical; }
textarea.short { min-height: 70px; }
label { display: block; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 .25rem; font-family: var(--mono); }
label.check { display: flex; gap: .4rem; align-items: center; text-transform: none; font-family: var(--sans); font-size: .9rem; letter-spacing: 0; color: var(--text); }
.btn { display: inline-flex; align-items: center; gap: .4rem; background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--heading); border-radius: 7px; padding: .5rem .9rem; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0B1017; font-weight: 600; }
.btn.primary:hover { background: var(--accent-bright); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn.block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: default; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: var(--mono); font-size: .85rem; }
.mb { margin-bottom: 1rem; }
.mt { margin-top: 1rem; }
.narrow { max-width: 480px; }
.wide { max-width: 820px; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .fixed { flex: 0 0 auto; }
.row > .grow { flex: 2 1 220px; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card h2 { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.err { color: var(--bad); margin: .5rem 0; }
.err:empty { margin: 0; }
.ok { color: var(--ok); }
.chip { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .74rem; font-family: var(--mono); letter-spacing: .04em; border: 1px solid var(--line-strong); color: var(--text); background: var(--surface-2); white-space: nowrap; }
.chip.stage-prospect { color: var(--muted); }
.chip.stage-contacted { border-color: #3a4f78; }
.chip.stage-replied { border-color: var(--accent); color: var(--accent-bright); }
.chip.stage-conversation, .chip.stage-proposal { border-color: var(--warn); color: var(--warn); }
.chip.stage-engaged, .chip.stage-in_market, .chip.stage-loi, .chip.stage-closed { border-color: var(--ok); color: var(--ok); }
.chip.stage-dead, .chip.stage-not_now { color: var(--muted); border-style: dashed; }
.chip.owner { background: var(--accent-soft); border-color: transparent; color: var(--accent-bright); }

/* layout */
.topbar { position: sticky; top: 0; z-index: 5; background: rgba(11, 16, 23, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .in { max-width: 1280px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem; }
.brand { font-family: var(--serif); color: var(--heading); font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; flex: 0 0 22px; }
.brand .sub { font-family: var(--mono); font-size: .72rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
nav.main { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
nav.main a { padding: .4rem .7rem; border-radius: 7px; color: var(--text); white-space: nowrap; }
nav.main a.active { background: var(--surface-3); color: var(--heading); }
nav.main a:hover { text-decoration: none; color: var(--heading); }
.user { display: flex; align-items: center; gap: .5rem; font-size: .9rem; margin-left: auto; }
.user .short { display: none; }
main { max-width: 1280px; margin: 0 auto; padding: 1.2rem 1rem 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(1200px 600px at 50% -10%, rgba(255, 107, 43, .10), transparent 60%), var(--bg-deep); }
.login .card { width: 100%; max-width: 380px; }
.login .brand { margin-bottom: 1rem; font-size: 1.3rem; }

/* today */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.kpi { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; color: inherit; }
.kpi:hover { border-color: var(--accent); text-decoration: none; }
.kpi .n { display: block; font-size: 1.5rem; font-family: var(--serif); color: var(--heading); line-height: 1.1; }
.kpi .l { display: block; font-size: .72rem; color: var(--muted); font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .55rem 0; border-top: 1px solid var(--line); display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.list li:first-child { border-top: 0; }
.list .when { font-family: var(--mono); font-size: .78rem; color: var(--muted); min-width: 70px; }
.list .co { color: var(--heading); font-weight: 600; }
.overdue { color: var(--bad); }
.due-today { color: var(--warn); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; white-space: nowrap; position: sticky; top: 0; background: var(--surface); padding: 0; }
th button.th { all: unset; display: block; width: 100%; padding: .55rem .7rem; cursor: pointer; box-sizing: border-box; }
th button.th:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
th.sorted { color: var(--accent-bright); }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--surface-3); }
td .co { color: var(--heading); font-weight: 600; }
td .sub { color: var(--muted); font-size: .82rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; align-items: center; }
.filters > * { flex: 0 1 auto; width: auto; min-width: 120px; }
.filters input[type=search] { flex: 1 1 200px; }
.count { color: var(--muted); font-family: var(--mono); font-size: .8rem; }

/* pipeline board */
.board { display: flex; gap: .7rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.col { flex: 0 0 240px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); min-height: 140px; }
.col.over { border-color: var(--accent); background: rgba(255, 107, 43, .06); }
.col h3 { padding: .6rem .7rem; margin: 0; border-bottom: 1px solid var(--line); font-size: .8rem; font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; justify-content: space-between; }
.col .cards { padding: .5rem; display: flex; flex-direction: column; gap: .5rem; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .65rem; cursor: grab; }
.pcard:hover { border-color: var(--line-strong); }
.pcard .co { color: var(--heading); font-weight: 600; display: block; }
.pcard .meta { font-size: .78rem; color: var(--muted); display: flex; justify-content: space-between; gap: .4rem; margin-top: .2rem; }
.pcard.dragging { opacity: .4; }

/* company detail */
.detail-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: 1rem; }
.detail-head h1 { margin-bottom: .2rem; }
.detail-head .controls { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.detail-head .controls select { width: auto; }
.two { display: grid; grid-template-columns: minmax(300px, 5fr) minmax(300px, 7fr); gap: 1rem; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .8rem; }
.fields .full { grid-column: 1 / -1; }
.contact-form { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--line-strong); padding: .2rem 0 .8rem .9rem; margin-left: .3rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .5rem; width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.timeline li.email_in::before, .timeline li.web_lead::before { background: var(--accent); }
.timeline li.stage::before { background: var(--ok); }
.timeline .meta { font-family: var(--mono); font-size: .75rem; color: var(--muted); display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.timeline .body { white-space: pre-wrap; word-break: break-word; margin-top: .15rem; }
.timeline .del { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font-size: .75rem; }
.timeline .del:hover { color: var(--bad); }
.contact { display: flex; justify-content: space-between; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.contact:first-child { border-top: 0; }
.fee { font-family: var(--serif); font-size: 1.3rem; color: var(--heading); }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--heading); padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); z-index: 20; max-width: 90vw; }
.toast.bad { border-color: var(--bad); }
.empty { color: var(--muted); padding: 1rem 0; }

@media (max-width: 760px) {
  .two { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
  .topbar .in { gap: .6rem; flex-wrap: wrap; padding: .5rem .8rem; }
  nav.main { order: 3; flex: 1 0 100%; }
  .brand .sub { display: none; }
  .user .name { display: none; }
  .user .short { display: inline; }
  main { padding: .8rem .8rem 4rem; }
  .col { flex-basis: 210px; }
  th button.th, td { padding: .5rem .5rem; }
  input, select, textarea { font-size: 16px; }
}
