:root {
  --bg: #0c0c0e; --panel: #151518; --panel2: #1c1c21; --line: #2a2a31;
  --text: #f2f2f4; --muted: #9a9aa6; --gold: #d8b45a; --gold2: #f0d28a;
  --green: #3ecf8e; --red: #ff5d5d; --blue: #5aa2ff; --orange: #ffa94d; --purple: #b18cff;
  --r: 14px; --nav: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Avenir Next", Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; -webkit-font-smoothing: antialiased; }
a { color: var(--gold2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 24px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
h3 { font-size: 17px; margin: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.gold { color: var(--gold); } .red { color: var(--red); } .green { color: var(--green); }

/* layout */
.shell { display: flex; min-height: 100vh; }
.side { width: 220px; flex: none; border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; letter-spacing: .08em; color: var(--gold); }
.side .brand img { width: 34px; height: 34px; border-radius: 8px; }
.side a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.side a.on, .side a:hover { background: var(--panel2); color: var(--text); }
.side .grow { flex: 1; }
.main { flex: 1; min-width: 0; padding: 22px 28px 40px; max-width: 1180px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.top .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bnav { display: none; }
.ico { width: 20px; height: 20px; flex: none; }

@media (max-width: 820px) {
  .side { display: none; }
  .main { padding: 14px 14px calc(var(--nav) + 24px + env(safe-area-inset-bottom)); padding-top: calc(14px + env(safe-area-inset-top)); }
  .bnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--nav) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(12,12,14,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); z-index: 20; }
  .bnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; position: relative; }
  .bnav a.on { color: var(--gold); }
  h1 { font-size: 21px; }
}

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kpi .v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .s { font-size: 11px; color: var(--muted); margin-top: 2px; }
@media (max-width: 820px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } .kpis { grid-template-columns: repeat(2, 1fr); } }
.section { margin-bottom: 22px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; transition: border-color .15s, background .15s; }
.item:hover { border-color: #3a3a44; background: #18181c; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .right { text-align: right; flex: none; }
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; font-size: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: #44444e; }
.btn.gold { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #1a1406; border-color: transparent; }
.btn.green { background: var(--green); color: #04150d; border-color: transparent; }
.btn.red { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 13px 16px; font-size: 15px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.btnrow .btn { flex: 1; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.b-new { color: var(--gold2); border-color: #5a4a20; background: #2a2210; }
.b-contacted { color: var(--blue); border-color: #234068; background: #0f1b2c; }
.b-quoted { color: var(--purple); border-color: #44306e; background: #1c1430; }
.b-booked { color: var(--orange); border-color: #6a4317; background: #2b1c0a; }
.b-won, .b-completed { color: var(--green); border-color: #1e5a40; background: #0c2219; }
.b-lost, .b-cancelled, .b-no_show { color: var(--red); border-color: #5e2424; background: #2a1010; }
.b-scheduled { color: var(--blue); border-color: #234068; background: #0f1b2c; }
.b-in_progress { color: var(--orange); border-color: #6a4317; background: #2b1c0a; }
.b-hot { color: #fff; background: var(--red); border-color: var(--red); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 13px; font-weight: 600; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .c { opacity: .6; margin-left: 4px; }

input, select, textarea { width: 100%; background: #0f0f12; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field { margin-bottom: 10px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
@media (max-width: 340px) { .fields { grid-template-columns: 1fr; } }
.fields .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin: 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }
.search { position: relative; flex: 1; max-width: 340px; }

/* timeline */
.tl { display: flex; flex-direction: column; gap: 0; }
.tl .ev { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.tl .ev:last-child { border-bottom: 0; }
.tl .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-top: 6px; flex: none; }
.tl .ev.text .dot { background: var(--blue); } .tl .ev.call .dot { background: var(--green); } .tl .ev.status .dot { background: var(--gold); } .tl .ev.note .dot { background: var(--purple); }

/* timer */
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer.late { color: var(--red); }
.timer.ok { color: var(--green); }
.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* modal */
.mback { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; padding: 18px; animation: up .18s ease-out; }
.modal .mh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.x { background: none; border: 0; color: var(--muted); font-size: 24px; cursor: pointer; line-height: 1; padding: 4px 8px; }
@media (max-width: 820px) {
  .mback { align-items: flex-end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(16px); opacity: 0; } }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav) + 24px); transform: translateX(-50%); z-index: 60; }
#toast .t { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; animation: up .2s; box-shadow: 0 8px 30px rgba(0,0,0,.5); }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 6px; border-bottom: 1px solid var(--line); }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }
.bar { height: 8px; border-radius: 4px; background: var(--panel2); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold2)); border-radius: 4px; }

/* kanban */
.board { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 10px; }
.col { background: #111114; border: 1px solid var(--line); border-radius: var(--r); padding: 10px; min-height: 200px; }
.col h4 { margin: 0 0 8px; font-size: 13px; display: flex; justify-content: space-between; }
.col .item { padding: 10px; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.back { color: var(--muted); font-size: 14px; display: inline-block; margin-bottom: 10px; cursor: pointer; }
.statusbar { display: flex; gap: 6px; overflow-x: auto; margin: 10px 0 14px; scrollbar-width: none; }
.statusbar .chip { flex: none; }
.dayhead { font-weight: 700; margin: 14px 0 8px; display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.dayhead.today { color: var(--gold); }
.tpl { padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: #111114; }
.tpl:hover { border-color: var(--gold); }
.tpl .n { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.tpl .b { font-size: 13px; color: var(--muted); }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { width: 100%; max-width: 360px; padding: 26px; text-align: center; }
.login img { width: 84px; border-radius: 16px; margin-bottom: 10px; }
code, .mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; background: #0f0f12; padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.steps { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.6; }
.dotred { position: absolute; top: 8px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.side a .cnt { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 999px; }
@media (max-width: 820px) { .top .actions { width: 100%; } .search { max-width: none; flex-basis: 100%; } }
