:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #17202c;
  --ink-2: #5b6676;
  --ink-3: #8b95a3;
  --line: #e3e7ed;
  --line-2: #eef1f5;
  --accent: #1e6fd9;
  --accent-soft: #e8f0fc;
  --good: #13915f;
  --good-soft: #e4f5ec;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --orange: #d9661e;
  --orange-soft: #fdeee3;
  --bad: #c9372c;
  --bad-soft: #fbe9e7;
  --muted-soft: #eef0f3;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
}

.muted {
  color: var(--ink-2);
}

.small {
  font-size: 12px;
}

.hidden {
  display: none !important;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 52px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand .logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
}

.nav {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
}

.nav a {
  padding: 7px 12px;
  border-radius: 6px;
  color: var(--ink-2);
  white-space: nowrap;
  font-weight: 500;
}

.nav a:hover {
  background: var(--line-2);
  color: var(--ink);
}

.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav .badge {
  margin-left: 6px;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
}

.live.on {
  background: var(--good);
  box-shadow: 0 0 0 3px var(--good-soft);
}

main {
  padding: 16px 20px 40px;
  max-width: 1600px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  margin: 4px 0 14px;
}

h2 {
  font-size: 15px;
  margin: 0 0 10px;
}

/* ---------- panels, cards ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-pad {
  padding: 16px;
}

.grid {
  display: grid;
  gap: 12px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr)) repeat(2, minmax(250px, 1.6fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s;
}

.stat:hover {
  border-color: var(--accent);
}

.stat .label {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
}

.stat .value {
  font-size: 24px;
  font-weight: 650;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.stat .value small {
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 500;
}

.stat.good .value {
  color: var(--good);
}

.stat.warn .value {
  color: var(--warn);
}

.opcard {
  padding: 12px 14px;
}

.opcard .head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.opcard .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.opcard .pct {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.bar {
  height: 6px;
  background: var(--line-2);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
  display: flex;
}

.bar>span {
  display: block;
  height: 100%;
}

.opcard .nums {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  font-size: 12px;
  color: var(--ink-2);
}

.opcard .nums b {
  display: block;
  color: var(--ink);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1300px) {
  .stats {
    grid-template-columns: repeat(5, 1fr);
  }

  .stats .opcard {
    grid-column: span 5;
  }
}

@media (max-width: 800px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats .opcard {
    grid-column: span 2;
  }
}

/* ---------- tabs, filters ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  overflow-x: auto;
}

.tab {
  padding: 11px 14px 10px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 550;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.badge {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--line-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.tab.active .badge {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.alert {
  background: var(--orange-soft);
  color: var(--orange);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line-2);
  align-items: center;
}

.filters .search {
  flex: 1 1 260px;
  min-width: 200px;
}

input[type=text],
input[type=search],
input[type=password],
input[type=date],
input[type=datetime-local],
select,
textarea {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  outline: none;
}

textarea {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
  min-height: 70px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select {
  padding-right: 26px;
  max-width: 190px;
}

label.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-weight: 550;
  white-space: nowrap;
}

.btn:hover {
  background: var(--line-2);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  filter: brightness(.95);
}

.btn.danger {
  color: var(--bad);
  border-color: #f0c4bf;
}

.btn.danger:hover {
  background: var(--bad-soft);
}

.btn.sm {
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.ghost:hover {
  background: var(--line-2);
}

.icon-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  color: var(--ink-3);
  line-height: 1;
}

.icon-btn:hover {
  background: var(--line-2);
  color: var(--accent);
}

/* ---------- table ---------- */
.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
}

table.data th {
  position: sticky;
  top: 0;
  background: #fafbfc;
  text-align: left;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.data td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}

table.data tbody tr {
  cursor: pointer;
}

table.data tbody tr:hover {
  background: #f8fafd;
}

table.data tbody tr.selected {
  background: var(--accent-soft);
}

table.data td.num {
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

td .name {
  font-weight: 550;
}

td .comment {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
}

.phone-cell,
td.nowrap {
  white-space: nowrap;
}

.phone-cell .more {
  color: var(--ink-3);
  font-size: 12px;
}

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--ink-2);
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  color: var(--ink-2);
  flex-wrap: wrap;
}

.op-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.st {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.st-PENDING {
  background: var(--muted-soft);
  color: var(--ink-2);
}

.st-ANSWERED {
  background: var(--good-soft);
  color: var(--good);
}

.st-NO_ANSWER {
  background: var(--warn-soft);
  color: var(--warn);
}

.st-WRONG_NUMBER {
  background: var(--bad-soft);
  color: var(--bad);
}

.st-CALLBACK {
  background: var(--orange-soft);
  color: var(--orange);
}

.eye {
  color: var(--orange);
  font-size: 12px;
  margin-left: 4px;
}

/* ---------- drawer (talaba kartochkasi) ---------- */
.drawer-back {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .25);
  z-index: 30;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100vw);
  background: var(--panel);
  z-index: 31;
  box-shadow: -8px 0 24px rgba(15, 23, 42, .15);
  display: flex;
  flex-direction: column;
}

.drawer-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-head .title {
  font-size: 17px;
  font-weight: 650;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 18px;
}

.drawer-foot {
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  align-items: center;
}

.banner {
  padding: 9px 12px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 13px;
}

.banner.warn {
  background: #fff6dd;
  border: 1px solid #f3dc9b;
  color: #7a5a06;
}

.banner.info {
  background: var(--accent-soft);
  border: 1px solid #c9dcf7;
  color: #1b4f99;
}

.banner.bad {
  background: var(--bad-soft);
  border: 1px solid #f0c4bf;
  color: #8f241b;
}

.phones {
  display: grid;
  gap: 6px;
  margin: 6px 0 14px;
}

.phone-big {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.phone-big a {
  font-size: 19px;
  font-weight: 650;
  font-family: var(--mono);
  color: var(--ink);
  letter-spacing: .3px;
}

.phone-big .btn {
  margin-left: auto;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 12px;
  margin-bottom: 14px;
}

.kv dt {
  color: var(--ink-2);
}

.kv dd {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  word-break: break-word;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink-3);
  margin: 16px 0 8px;
}

.status-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.status-buttons button {
  height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  text-align: left;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-buttons button kbd {
  margin-left: auto;
  font: 11px var(--mono);
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
}

.status-buttons button.on.ANSWERED {
  background: var(--good-soft);
  border-color: var(--good);
  color: var(--good);
}

.status-buttons button.on.NO_ANSWER {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: var(--warn);
}

.status-buttons button.on.WRONG_NUMBER {
  background: var(--bad-soft);
  border-color: var(--bad);
  color: var(--bad);
}

.status-buttons button.on.CALLBACK {
  background: var(--orange-soft);
  border-color: var(--orange);
  color: var(--orange);
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  padding: 8px 0 8px 14px;
  border-left: 2px solid var(--line);
  position: relative;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 13px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}

.timeline .when {
  font-size: 12px;
  color: var(--ink-3);
}

.field {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

.field>span {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

/* ---------- modal ---------- */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal {
  background: var(--panel);
  border-radius: 10px;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 40px rgba(15, 23, 42, .25);
}

.modal.wide {
  width: min(980px, 100%);
}

.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 650;
  font-size: 16px;
}

.modal-body {
  padding: 16px 18px;
}

.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- toasts ---------- */
#toasts {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 50;
  display: grid;
  gap: 8px;
}

.toast {
  background: #1f2937;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .2);
  max-width: 380px;
  font-size: 13px;
  animation: tin .15s ease-out;
}

.toast.good {
  background: #0f6e48;
}

.toast.bad {
  background: #a02a21;
}

@keyframes tin {
  from {
    transform: translateY(6px);
    opacity: 0;
  }
}

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login {
  width: min(360px, 100%);
  padding: 28px;
}

.login h1 {
  margin-top: 0;
}

.login .field input {
  width: 100%;
  height: 38px;
}

.login .btn {
  width: 100%;
  height: 40px;
  margin-top: 16px;
}

.error-text {
  color: var(--bad);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ---------- import ---------- */
.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 900px) {
  .two {
    grid-template-columns: 1fr;
  }
}

.drop {
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  color: var(--ink-2);
}

.drop input {
  margin-top: 8px;
}

.mapping {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 13px;
}

.mapping td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line-2);
}

.mapping select {
  max-width: 100%;
  width: 100%;
  height: 30px;
}

.sample {
  font-size: 12px;
  overflow-x: auto;
  margin-top: 10px;
}

.sample table {
  border-collapse: collapse;
}

.sample td,
.sample th {
  border: 1px solid var(--line-2);
  padding: 3px 6px;
  white-space: nowrap;
}

.report-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.modes {
  display: grid;
  gap: 8px;
}

.mode {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.mode:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mode b {
  display: block;
}

.cand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  margin-top: 6px;
}

.cand .info {
  flex: 1;
  min-width: 0;
  font-size: 13px;
}

.ok-mark {
  color: var(--good);
  font-weight: 700;
}

.bad-mark {
  color: var(--bad);
  font-weight: 700;
}
/* ---------- qo'ng'iroqlar hisoboti ---------- */
.calls-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1100px) { .calls-grid { grid-template-columns: 1fr; } }
.minibar { flex: 1; min-width: 40px; height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; display: block; }
.minibar > span { display: block; height: 100%; background: var(--accent); }
.stat.bad .value { color: var(--bad); }
.stat.orange .value { color: var(--orange); }
.stat.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
@media (max-width: 900px) { #dCards { grid-template-columns: repeat(2, 1fr) !important; } }

#dDaily th, #dDaily td { padding: 7px 6px; font-size: 13px; }
#dDaily .minibar { min-width: 24px; }
.calls-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .calls-grid { grid-template-columns: 1fr; } }

/* Ikki bosqichli tasdiqlash */
.tfa-steps { padding-left: 18px; margin: 0 0 12px; font-size: 13px; line-height: 1.5; }
.tfa-steps li { margin-bottom: 4px; }
.tfa-qr { display: flex; justify-content: center; margin: 6px 0 12px; }
.tfa-qr img { background: #fff; padding: 8px; border-radius: 8px; border: 1px solid #e3e7ee; }
.tfa-secret { font-size: 14px; letter-spacing: 1px; margin: 8px 0; padding: 8px; background: #f4f6f9; border-radius: 6px; word-break: break-all; color: #1c2430; }
.tfa-code { font-size: 24px !important; letter-spacing: 8px; text-align: center; font-family: ui-monospace, Consolas, monospace; }
