:root {
  --brand: #12968A;
  --primary: #0E7C72;
  --primary-dark: #0B6158;
  --dark: #0C2A27;
  --dark-2: #123C38;
  --bg: #F4F6F5;
  --surface: #FFFFFF;
  --line: #E6ECEA;
  --line-2: #D5DEDC;
  --muted-bg: #EBF0EE;
  --text: #10201E;
  --text-2: #23403B;
  --muted: #5B706C;
  --mint: #E3F4F1;
  --red: #B42318;  --red-bg: #FDECEC;
  --orange: #A6520A; --orange-bg: #FFF3E0;
  --blue: #1D4F91; --blue-bg: #E8F0FB;
  --radius: 16px;
  --font: Inter, system-ui, -apple-system, sans-serif;
  --display: 'Space Grotesk', Inter, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.content { flex: 999 1 560px; min-width: 0; padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 24px; }

/* ---------- Sidebar ---------- */
.sidebar { flex: 1 1 232px; max-width: 100%; background: var(--dark); color: #CFE3E0; padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; }
.brand-text b { font-family: var(--display); font-size: 17px; color: #fff; letter-spacing: .04em; }
.brand-text small { font-size: 12px; color: #8FB5B0; letter-spacing: .2em; }
.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-group > div { display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: 11px; letter-spacing: .12em; color: #7FA6A1; padding: 0 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; font-size: 14px; transition: background .15s; }
.nav-item:hover { background: var(--dark-2); }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.sub-item { padding: 9px 12px 9px 42px; font-size: 14px; border-radius: 8px; background: none; border: 0; text-align: left; cursor: pointer; }
.sub-item:hover, .sub-item.active { color: #fff; }
.agent-status { margin-top: auto; background: var(--dark-2); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.agent-status div { display: flex; align-items: center; gap: 8px; color: #fff; font-size: 13px; }
.agent-status p { margin: 0; font-size: 12px; line-height: 1.5; color: #A9C9C4; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #4ADE9E; box-shadow: 0 0 0 4px rgba(74,222,158,.15); }
.link-btn { background: none; border: 0; padding: 0; color: #7EE0CF; font-size: 12px; text-align: left; cursor: pointer; text-decoration: underline; }

/* ---------- Topbar / headers ---------- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.search { flex: 1 1 280px; max-width: 420px; display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid #E1E8E6; border-radius: 12px; padding: 0 14px; height: 44px; }
.search input { border: 0; outline: 0; flex: 1; font-size: 14px; background: transparent; }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(18,150,138,.15); }
.user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #D6EEEB; color: var(--primary); font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: center; flex: none; }
.avatar.sm { width: 34px; height: 34px; font-size: 12px; background: var(--mint); color: var(--primary-dark); }
.user-meta { display: flex; flex-direction: column; }
.user-meta b { font-size: 14px; font-weight: 600; }
.user-meta span { font-size: 12px; color: var(--muted); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head h1 { font-size: 30px; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn { height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); font-size: 14px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.sm { height: 36px; padding: 0 14px; border-radius: 10px; font-size: 13px; }
.btn.block { flex: 1; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid #E1E8E6; background: var(--surface); display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.badge-dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: #E5484D; border: 2px solid #fff; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi strong { font-family: var(--display); font-size: 28px; font-weight: 600; }
.kpi small { font-size: 12px; font-weight: 500; color: var(--primary); }
.kpi.dark { background: var(--dark); border-color: var(--dark); color: #fff; }
.kpi small.muted { color: var(--muted); } .kpi small.text-red { color: var(--red); }
.kpi.dark span { color: #A9C9C4; } .kpi.dark small { color: #7EE0CF; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card.dark { background: var(--dark); border-color: var(--dark); color: #fff; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-head h2 { font-size: 18px; }
.card h2.sm { font-size: 17px; }
.card-link { font-size: 13px; color: var(--primary); font-weight: 600; background: none; border: 0; cursor: pointer; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .08em; }
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.split > .main { flex: 999 1 600px; min-width: 0; }
.split > .side { flex: 1 1 300px; display: flex; flex-direction: column; gap: 20px; }
.muted { color: var(--muted); }
.text-red { color: var(--red); } .text-green { color: var(--primary); } .text-orange { color: var(--orange); }

/* ---------- Tags / bars ---------- */
.tag { font-size: 11px; font-weight: 600; border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.pill { font-size: 12px; font-weight: 600; border-radius: 20px; padding: 3px 10px; white-space: nowrap; }
.t-hot, .p-late { background: var(--red-bg); color: var(--red); }
.t-warm, .p-today { background: var(--orange-bg); color: var(--orange); }
.t-cold { background: var(--blue-bg); color: var(--blue); }
.p-ok { background: var(--mint); color: var(--primary-dark); }
.bar { height: 6px; border-radius: 6px; background: var(--muted-bg); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 6px; background: var(--brand); transition: width .3s; }

/* ---------- Kanban ---------- */
.board-wrap { overflow-x: auto; padding-bottom: 4px; }
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 14px; }
.col { background: var(--muted-bg); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 220px; transition: background .15s, box-shadow .15s; }
.col.drag-over { background: #DDEDEA; box-shadow: inset 0 0 0 2px var(--brand); }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 2px; font-size: 13px; font-weight: 600; }
.col-head span { font-size: 12px; font-weight: 500; color: var(--muted); background: #fff; border-radius: 20px; padding: 2px 9px; }
.col-sum { font-size: 12px; color: var(--muted); padding: 0 4px; }
.lead { background: var(--surface); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 1px 2px rgba(12,42,39,.06); cursor: grab; border: 1px solid transparent; text-align: left; width: 100%; }
.lead:hover { border-color: #CDE5E1; }
.lead.dragging { opacity: .45; }
.lead-top { display: flex; justify-content: space-between; gap: 8px; }
.lead-top b { font-size: 14px; }
.lead p { margin: 0; font-size: 13px; color: #3D524E; }
.lead-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.lead-foot b { color: var(--text); }
.empty { font-size: 12px; color: var(--muted); text-align: center; padding: 16px 4px; border: 1px dashed #C9D6D3; border-radius: 12px; }

/* ---------- AI tips ---------- */
.ai-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--mint); display: flex; align-items: center; justify-content: center; flex: none; }
.tip { border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; animation: in .25s ease; }
.tip p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.tip .row { display: flex; gap: 8px; }
@keyframes in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 10px 8px; border-bottom: 1px solid var(--line); }
td { padding: 14px 8px; border-bottom: 1px solid #F0F3F2; vertical-align: middle; }
td small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.num { text-align: right; font-weight: 600; white-space: nowrap; }
.pct-cell { width: 170px; }
.pct-cell small { margin-top: 4px; }

/* ---------- Approval ---------- */
.sum-row { display: flex; justify-content: space-between; font-size: 14px; padding: 10px 12px; background: var(--bg); border-radius: 10px; }
.result { font-size: 13px; font-weight: 600; border-radius: 10px; padding: 12px; line-height: 1.5; }
.result.ok { color: var(--primary-dark); background: var(--mint); }
.result.no { color: var(--orange); background: var(--orange-bg); }

/* ---------- Transactions ---------- */
.tx { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #F0F3F2; font-size: 13px; }
.tx:last-child { border-bottom: 0; }
.tx small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- Koordinator ---------- */
.stages { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stage { border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.stage.alert { background: #FDF3F2; }
.stage span { font-size: 12px; color: var(--muted); }
.stage b { font-size: 15px; }
.stage strong { font-family: var(--display); font-size: 26px; font-weight: 600; }
.stage small { font-size: 12px; font-weight: 500; }
.task { display: flex; align-items: center; gap: 14px; padding: 12px 4px; border-bottom: 1px solid #F0F3F2; }
.task:last-child { border-bottom: 0; }
.check { width: 24px; height: 24px; flex: none; border-radius: 7px; border: 1.5px solid #B8C6C3; background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.check.on { background: var(--brand); border-color: var(--brand); }
.task-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.task-body b { font-size: 14px; font-weight: 500; }
.task-body small { font-size: 12px; color: var(--muted); }
.task.done .task-body b { color: #8A9C98; text-decoration: line-through; }
.task-who { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.member { display: flex; align-items: center; gap: 12px; }
.member-body { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.member-body div { display: flex; justify-content: space-between; font-size: 13px; }
.card.dark p { margin: 0; font-size: 13px; line-height: 1.6; color: #CFE3E0; }
.btn.ghost-dark { background: transparent; border-color: #2E5A55; color: #fff; }
.btn.brand { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ---------- Modal / toast ---------- */
.modal { border: 0; border-radius: 20px; padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: 0 24px 64px rgba(12,42,39,.25); }
.modal::backdrop { background: rgba(12,42,39,.45); backdrop-filter: blur(2px); }
.modal form { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.field input, .field select, .field textarea { height: 44px; border: 1px solid var(--line-2); border-radius: 10px; padding: 0 12px; font-size: 14px; font-weight: 400; background: #fff; }
.field textarea { height: 88px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(18,150,138,.15); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .actions { justify-content: flex-end; margin-top: 6px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--dark); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .content { padding: 20px 16px 40px; }
  .page-head h1 { font-size: 24px; }
  .task { flex-wrap: wrap; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* CRM: voronka to'liq ko'rinsin, agent paneli kerak bo'lsa pastga tushadi */
.crm-split > .main { flex-basis: 1000px; }
.tips { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #DDF1EE 0%, transparent 60%), var(--bg); }
.login-card { width: min(420px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 32px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 24px 64px rgba(12,42,39,.08); }
.login-card .brand { padding: 0; }
.login-card .brand-text b { color: var(--text); }
.login-card .brand-text small { color: var(--muted); }
.login-card h1 { font-size: 24px; margin-top: 8px; }
.login-card p { margin: 0; color: var(--muted); font-size: 14px; }
.login-error { color: var(--red); background: var(--red-bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.demo-users { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo-users button { text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-size: 12px; color: var(--muted); }
.demo-users button b { display: block; color: var(--text); font-size: 13px; }
.demo-users button:hover { border-color: var(--brand); }
.logout { margin-left: 8px; }
.loading { color: var(--muted); font-size: 14px; padding: 40px 0; }
.purchase + .purchase { border-top: 1px solid var(--line); padding-top: 14px; }
select.inline { height: 32px; border: 1px solid var(--line-2); border-radius: 8px; font-size: 12px; padding: 0 6px; background: #fff; }
