:root {
  --ground: #F6F5F7;
  --surface: #FFFFFF;
  --line: #E6E3E9;
  --line-soft: #F0EEF2;
  --ink: #1C1A1F;
  --ink-2: #3A3640;
  --muted: #615C68;
  --accent: #C2185B;
  --accent-ink: #A3134C;
  --accent-tint: #FCE8F0;
  --danger: #B3261E;
  --danger-ink: #8C1D18;
  --danger-tint: #FDECEC;
  --radius: 12px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.45; }
a { color: var(--accent-ink); }
a:hover { color: #7E0E3A; }
h1 { margin: 0; font-family: var(--display); font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Karkas */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.side { flex: 1 1 220px; max-width: 100%; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 700; font-size: 14px; }
.brand b { font-family: var(--display); font-size: 16px; display: block; }
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; text-decoration: none; }
.menu a:hover { background: var(--ground); color: var(--ink); }
.menu a[aria-current="page"] { background: var(--accent-tint); color: var(--accent-ink); font-weight: 600; }
.menu a span.grow { flex: 1; }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.badge.red { background: var(--danger); }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line-soft); }
.me form { margin-left: auto; }
.content { flex: 999 1 560px; min-width: 0; padding: 28px 32px 40px; display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 640px) {
  .side { flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--line); gap: 12px; padding: 12px; }
  .menu { flex-direction: row; flex-wrap: wrap; }
  .menu a { min-height: 40px; }
  .me { margin-top: 0; }
  .content { padding: 16px; }
}

.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.head p { margin: 4px 0 0; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.between { justify-content: space-between; }

/* Elementlar */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: #CFCAD5; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #A3134C; color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent-ink); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.icon-btn { width: 44px; height: 44px; padding: 0; border-radius: 10px; background: var(--accent-tint); color: var(--accent-ink); border: 0; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn.hot { background: var(--accent); color: #fff; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

input[type=text], input[type=search], input[type=password], input[type=tel], input[type=datetime-local], select, textarea {
  min-height: 44px; padding: 0 12px; border: 1px solid #D9D5DE; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; width: 100%;
}
textarea { padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field { display: flex; flex-direction: column; gap: 6px; }
.search { position: relative; min-width: 240px; }
.search input { padding-left: 38px; }
.search .icon { position: absolute; left: 12px; top: 13px; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.card.flush > h2 { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card.dashed { border-style: dashed; }

.alert { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 10px; background: var(--danger-tint); color: var(--danger-ink); }
.alert .grow { flex: 1; min-width: 200px; }
.alert a { color: var(--danger-ink); font-weight: 600; }
.flash { padding: 12px 16px; border-radius: 10px; background: #E3F4E8; color: #17663A; font-weight: 500; }
.flash.error { background: var(--danger-tint); color: var(--danger-ink); }

/* Statuslar */
.chip { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-new { background: #E8EEFB; color: #1E4FB8; }
.st-coming { background: #E3F4E8; color: #17663A; }
.st-thinking { background: #FDF1DC; color: #8A5300; }
.st-no_answer { background: #EFEAFB; color: #5B3FA8; }
.st-not_coming { background: #F0EFF2; color: #57525F; }
.st-stale { background: #FDE2E0; color: #A4211A; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-new { background: #2F62D8; } .dot-coming { background: #1F8A4C; } .dot-thinking { background: #D98A00; }
.dot-no_answer { background: #7A5CC8; } .dot-not_coming { background: #8E8896; } .dot-stale { background: #D93025; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-size: 13px; font-weight: 500; text-decoration: none; }
.pill .n { color: var(--muted); }
.pill[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.pill[aria-current="true"] .n { color: #fff; opacity: .8; }
.pill.danger { border-color: #F3C4C1; background: #FFF5F5; color: var(--danger); font-weight: 600; }
.selects { display: flex; flex-wrap: wrap; gap: 8px; }
.selects select { min-height: 40px; width: auto; font-size: 13px; }

/* Jadval */
.table-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.stale { background: #FFF6F6; }
td.r, th.r { text-align: right; }
.lead-name { color: var(--ink); font-weight: 600; text-decoration: none; }
.lead-name:hover { color: var(--accent-ink); text-decoration: underline; }
.who { display: flex; align-items: center; gap: 8px; }
.ava { width: 26px; height: 26px; border-radius: 50%; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; background: #EEF0F4; color: #4A5163; }
.ava.a0 { background: #F3E8FA; color: #6A2C91; } .ava.a1 { background: #E6F4EC; color: #1F6B42; } .ava.a2 { background: #E6EEF9; color: #24508F; } .ava.a3 { background: #FDF1DC; color: #8A5300; }
.ava.lg { width: 36px; height: 36px; font-size: 14px; }
.warn-text { color: var(--danger); font-weight: 600; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* Kartochka */
.cols { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 20px; }
.col-main { flex: 2 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.col-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr)); gap: 10px; }
.status-opt input { position: absolute; opacity: 0; pointer-events: none; }
.status-opt > span { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 600; cursor: pointer; }
.status-opt input:checked + span { border-width: 2px; }
.status-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.status-opt.coming input:checked + span { border-color: #1F8A4C; background: #E3F4E8; color: #135C33; }
.status-opt.thinking input:checked + span { border-color: #D98A00; background: #FDF1DC; color: #6E4200; }
.status-opt.no_answer input:checked + span { border-color: #7A5CC8; background: #EFEAFB; color: #4A3290; }
.status-opt.not_coming input:checked + span { border-color: #8E8896; background: #F0EFF2; color: #3A3640; }
.extra { display: none; }
.extra.show { display: flex; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
dl.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; column-gap: 16px; row-gap: 10px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.timeline li:last-child { border-bottom: 0; }
.timeline .t { flex: 0 0 92px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.note { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--ground); color: var(--ink-2); white-space: pre-wrap; }
.tag { display: inline-flex; padding: 2px 8px; border-radius: 6px; background: #EEF0F4; color: #4A5163; font-size: 11px; font-weight: 600; }

/* Hisobot */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .v { font-family: var(--display); font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi.bad { background: #FFF6F6; border-color: #F3C4C1; color: var(--danger-ink); }
.kpi.bad .v { color: var(--danger); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.seg a { min-height: 36px; padding: 0 14px; display: inline-flex; align-items: center; border-radius: 7px; color: var(--ink-2); font-size: 13px; font-weight: 500; text-decoration: none; }
.seg a[aria-current="true"] { background: var(--ink); color: #fff; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 20px; }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar { display: grid; grid-template-columns: 150px 1fr 56px; align-items: center; gap: 12px; }
.bar .track { height: 14px; border-radius: 4px; background: #F2EFF4; }
.bar .fill { height: 100%; border-radius: 4px; background: var(--accent); }
.bar .fill.gray { background: #57525F; }
.bar b { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td, tr.total th { background: #FAF9FB; font-weight: 700; border-top: 1px solid var(--line); }

/* Qo'ng'iroqlar (telefon uchun qulay) */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 14px 16px; display: flex; align-items: center; gap: 12px; }
.item.urgent { border-color: #F3C4C1; }
.item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.item .grow a { font-size: 15px; }
.section-title { margin: 8px 4px 0; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.section-title.red { color: var(--danger); }

dialog:not([open]) { display: none; }
dialog::backdrop { background: rgba(28, 26, 31, .35); }
tbody th { border-bottom: 1px solid var(--line-soft); }
.user-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr 80px 90px 1.1fr 110px; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.user-grid.head-row { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; border-bottom: 1px solid var(--line); padding-top: 12px; padding-bottom: 12px; }
.user-grid:last-child { border-bottom: 0; }

/* Kirish */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login { width: 100%; max-width: 380px; }
