*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 10px;
}

body {
  font-family: 'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--primary); }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 1.25rem 0;
  flex-shrink: 0;
}

.sidebar h1 {
  font-size: 1rem;
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.user-bar {
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.nav-item {
  display: block;
  padding: 0.65rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
}

.nav-item:hover, .nav-item.active {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active { border-right: 3px solid var(--primary); }

.main { flex: 1; padding: 1.75rem; overflow: auto; }

.page { display: none; }
.page.active { display: block; }

h2 { margin-bottom: 1.25rem; font-size: 1.3rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.stat .value { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.stat .label { font-size: 0.85rem; color: var(--text-muted); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.7rem; text-align: right; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 500; font-size: 0.85rem; }

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.35rem; color: var(--text-muted); font-size: 0.9rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.78rem;
}
.badge-hf { background: #1e3a5f; color: #93c5fd; }
.badge-wc { background: #422006; color: #fcd34d; }
.badge-manual { background: var(--surface-hover); color: var(--text-muted); }
.badge-merged { background: #1a3a2a; color: #86efac; }
.badge-lead { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.badge-customer { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.inv-count {
  display: inline-flex;
  min-width: 1.75rem;
  justify-content: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  font-weight: 700;
  font-size: 0.85rem;
}
.list-toolbar .toolbar-row,
.contacts-toolbar .toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.list-toolbar .toolbar-row:last-of-type,
.contacts-toolbar .toolbar-row:last-of-type { margin-bottom: 0.5rem; }
.list-toolbar .input,
.contacts-toolbar .input {
  flex: 1;
  min-width: 12rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.select-compact {
  flex: 0 1 12rem;
  min-width: 10rem;
  cursor: pointer;
}
.list-toolbar .filter-tabs { margin-bottom: 0.5rem; }
.text-muted { color: var(--text-muted); font-size: 0.875rem; }

.contact-card-modal {
  max-height: 92vh;
  overflow: auto;
}
.contact-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.contact-card-kind {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
}
.contact-card-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.contact-stat {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.55rem;
  text-align: center;
}
.contact-stat-val {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
}
.contact-stat-lbl {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.contact-card-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 1rem;
}
.contact-card-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}
.contact-card-section h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.contact-card-table {
  margin: 0;
  padding: 0;
  overflow: auto;
  max-height: 240px;
}
#contact-notes {
  width: 100%;
  resize: vertical;
  min-height: 4.5rem;
}

@media (max-width: 720px) {
  .contact-card-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contact-card-meta { grid-template-columns: 1fr; }
  .contact-card-head { flex-direction: column; }
}

.inv-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem 0.2rem 0.3rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-hover);
  color: var(--text-muted);
}
.inv-status-ico {
  display: inline-flex;
  width: 1.35rem;
  height: 1.35rem;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex: 0 0 auto;
}
.inv-status-ico svg { display: block; }
.inv-status--draft {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}
.inv-status--draft .inv-status-ico { background: #64748b; color: #fff; }
.inv-status--confirmed {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}
.inv-status--confirmed .inv-status-ico { background: #3b82f6; color: #fff; }
.inv-status--partial {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}
.inv-status--partial .inv-status-ico { background: #f59e0b; color: #1c1917; }
.inv-status--paid {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}
.inv-status--paid .inv-status-ico { background: #10b981; color: #042f2e; }
.inv-status--canceled {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
.inv-status--canceled .inv-status-ico { background: #ef4444; color: #fff; }
.inv-status--unknown {
  background: var(--surface-hover);
  color: var(--text-muted);
}
.inv-status--unknown .inv-status-ico { background: #475569; color: #fff; }

.filter-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-tab {
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}
.filter-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.conn-status { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.conn-pill {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
}
.conn-pill.ok { border-color: #166534; color: #86efac; }
.conn-pill.fail { border-color: #991b1b; color: #fca5a5; }

.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  min-height: 220px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.kanban-col--todo { border-top-color: #f59e0b; }
.kanban-col--doing { border-top-color: #3b82f6; }
.kanban-col--done { border-top-color: #22c55e; }
.kanban-col.drag-over {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}
.kanban-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}
.kanban-col-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.92rem;
}
.kanban-col-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--text-muted);
}
.kanban-col--todo .kanban-col-dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2); }
.kanban-col--doing .kanban-col-dot { background: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
.kanban-col--done .kanban-col-dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2); }
.kanban-col-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  height: 1.55rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--surface-hover);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
}
.kanban-list { min-height: 140px; display: flex; flex-direction: column; }
.kanban-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
  padding: 1.75rem 0.5rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  pointer-events: none;
}
.kanban-empty-ico { display: block; font-size: 1.4rem; margin-bottom: 0.35rem; opacity: 0.6; }
.kanban-card {
  position: relative;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-inline-end: 3px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.8rem 0.75rem 0.9rem;
  margin-bottom: 0.55rem;
  font-size: 0.9rem;
  cursor: grab;
  touch-action: none;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: opacity .15s, transform .15s, box-shadow .15s, border-color .15s;
}
.kanban-card:hover {
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  transform: translateY(-1px);
  border-color: var(--primary);
}
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging {
  opacity: 0.45;
  transform: scale(0.98);
}
.kanban-card-title { font-weight: 600; line-height: 1.4; }
.kanban-card-handle {
  position: absolute;
  top: 0.55rem;
  left: 0.45rem;
  width: 0.28rem;
  height: 1.1rem;
  border-radius: 99px;
  background: repeating-linear-gradient(
    to bottom,
    var(--text-muted) 0 2px,
    transparent 2px 4px
  );
  opacity: 0.55;
}
.kanban-card-cat {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 0.4rem;
  background: var(--surface);
  color: var(--text-muted);
}
.kanban-card-cat--sales { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.kanban-card-cat--followup { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.kanban-card-cat--support { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.kanban-card-cat--admin { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.kanban-ghost {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  opacity: 0.92;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  margin: 0;
}

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem;
}
#modal-invoice.modal-overlay { z-index: 160; }
#modal-sms.modal-overlay { z-index: 170; }
#modal-contact.modal-overlay { z-index: 140; }

.management-tab.active { display: block !important; }
.management-stats .stat .label { white-space: nowrap; }

.contact-card-table .inv-desc {
  display: inline-block;
  max-width: 16rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  white-space: normal;
}
.inv-row-click { cursor: pointer; }
.inv-row-click:hover td { background: var(--surface-hover); }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

.empty-state { text-align: center; padding: 2rem; color: var(--text-muted); }

.fab-add {
  position: fixed;
  left: 1.5rem;
  bottom: 1.75rem;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  font-size: 1.9rem;
  font-weight: 400;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(59, 130, 246, 0.45), 0 4px 10px rgba(0, 0, 0, 0.3);
  z-index: 130;
  transition: transform .15s ease, box-shadow .15s ease;
}
.fab-add span { transform: translateY(-1px); }
.fab-add:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 14px 32px rgba(59, 130, 246, 0.55), 0 6px 14px rgba(0, 0, 0, 0.35);
}
.fab-add:active { transform: scale(0.95); }

.toast {
  position: fixed; bottom: 1rem; left: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 200;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  margin: 0.5rem;
}
.login-box .btn { min-height: 48px; width: 100%; justify-content: center; }
.login-box input { min-height: 48px; font-size: 16px; }
.login-box h1 { text-align: center; margin-bottom: 0.25rem; }
.login-box p { text-align: center; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

.inv-row-click { cursor: pointer; }
.inv-row-click:hover td { background: var(--surface-hover); }
.detail-meta { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1rem; line-height: 1.8; }

.page-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.page-toolbar h2 { margin: 0; display: flex; align-items: center; gap: 0.5rem; }

.page-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.7rem;
  height: 1.7rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table { min-width: 520px; }

.mobile-header,
.bottom-nav,
.sidebar-backdrop { display: none; }

.icon-btn {
  border: none;
  background: var(--surface-hover);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  font-size: 1.2rem;
  cursor: pointer;
  font-family: inherit;
}

/* ——— موبایل ——— */
@media (max-width: 768px) {
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 90;
  }

  .mobile-title {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 110;
  }
  body.sidebar-open .sidebar-backdrop { display: block; }

  .app { flex-direction: column; }

  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: min(280px, 88vw);
    height: 100%;
    z-index: 120;
    border-left: none;
    border-bottom: none;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 1rem);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }

  .sidebar .user-bar .btn-logout-desktop { display: none; }

  .main {
    padding: 1rem 0.85rem;
    width: 100%;
  }

  h2 { font-size: 1.15rem; }

  .form-row, .kanban { grid-template-columns: 1fr; }

  .stats { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .stat { padding: 0.75rem 0.5rem; }
  .stat .value { font-size: 1.15rem; }
  .stat .label { font-size: 0.75rem; }

  .btn {
    min-height: 44px;
    padding: 0.55rem 1rem;
  }

  .nav-item {
    padding: 0.85rem 1.25rem;
    font-size: 0.95rem;
  }

  .filter-tab {
    min-height: 40px;
    padding: 0.45rem 0.9rem;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    padding: 1.25rem;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }
  .modal-actions .btn { width: 100%; justify-content: center; }

  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 95;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.45rem 0.25rem;
    min-height: 56px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    cursor: pointer;
    font-size: 0.68rem;
  }
  .bottom-nav-item span { font-size: 1.1rem; line-height: 1; }
  .bottom-nav-item.active { color: var(--primary); }

  .toast {
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    text-align: center;
  }

  .fab-add {
    left: 1rem;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 0.85rem);
    width: 3.5rem;
    height: 3.5rem;
  }

  .data-table { min-width: 600px; }
  th, td { padding: 0.65rem 0.5rem; font-size: 0.85rem; }

  .kanban-card {
    padding: 0.75rem;
    min-height: 44px;
  }

  .kanban-col { padding: 0.75rem; }
  .kanban-col-head { margin-bottom: 0.65rem; padding-bottom: 0.5rem; }
}

@media (min-width: 769px) {
  .mobile-header,
  .bottom-nav,
  .sidebar-backdrop { display: none !important; }
}

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

/* VoIP call popup */
.call-popup {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  width: min(420px, calc(100vw - 1.5rem));
}
.call-popup-inner {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  background: #0f172a;
  border: 1px solid #1d4ed8;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  color: #fff;
}
.call-popup.known .call-popup-inner { border-color: #16a34a; }
.call-popup.hangup .call-popup-inner { border-color: #64748b; opacity: 0.95; }
.call-popup-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.6);
  animation: callPulse 1.4s infinite;
  flex-shrink: 0;
}
.call-popup.hangup .call-popup-pulse { background: #94a3b8; animation: none; }
@keyframes callPulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.55); }
  70% { box-shadow: 0 0 0 12px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.call-popup-label { font-size: 0.75rem; color: #93c5fd; margin-bottom: 0.15rem; }
.call-popup-name { font-weight: 700; font-size: 1.05rem; }
.call-popup-phone { font-size: 0.85rem; color: #cbd5e1; margin-top: 0.15rem; }
.call-popup-inner > div { flex: 1; min-width: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.contact-row { cursor: pointer; }
.contact-row:hover { background: var(--surface-hover); }
.calls-filters-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.15rem;
}
.calls-filters-row .call-dir-filters,
.calls-filters-row .filter-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  margin-bottom: 0;
  flex: 0 0 auto;
}
.calls-filters-row .call-dir-chip,
.calls-filters-row .filter-tab {
  flex: 0 0 auto;
  white-space: nowrap;
}

.call-dir-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.call-dir-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.call-dir-chip:hover { background: var(--surface-hover); }
.call-dir-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}
.call-dir-chip--in:not(.active) { color: #34d399; border-color: rgba(52, 211, 153, 0.35); background: rgba(16, 185, 129, 0.12); }
.call-dir-chip--out:not(.active) { color: #60a5fa; border-color: rgba(96, 165, 250, 0.35); background: rgba(59, 130, 246, 0.12); }
.call-dir-chip.active.call-dir-chip--in { background: #059669; border-color: #059669; box-shadow: 0 4px 12px rgba(5, 150, 105, 0.28); }
.call-dir-chip.active.call-dir-chip--out { background: #2563eb; border-color: #2563eb; }
.call-dir-ico {
  display: inline-flex;
  width: 1.35rem;
  height: 1.35rem;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.call-dir-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem 0.2rem 0.35rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-hover);
  color: var(--text-muted);
}
.call-dir-badge svg { flex: 0 0 auto; }
.call-dir-badge--in { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.call-dir-badge--out { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.call-dir-badge--missed { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.call-dir-badge--out-miss { background: rgba(249, 115, 22, 0.15); color: #fb923c; }

.call-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem 0.2rem 0.3rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-hover);
  color: var(--text-muted);
}
.call-status-ico {
  display: inline-flex;
  width: 1.15rem;
  height: 1.15rem;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
}
.call-status-badge--ok {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}
.call-status-badge--ok .call-status-ico {
  background: #10b981;
  color: #042f2e;
}
.call-status-badge--no {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}
.call-status-badge--no .call-status-ico {
  background: #ef4444;
  color: #fff;
}

.call-player {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 16rem;
  max-width: 22rem;
  padding: 0.2rem 0.35rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.call-player audio { display: none; }
.call-player-btn {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  color: var(--text);
}
.call-player-btn:hover { background: rgba(255, 255, 255, 0.08); }
.call-player-seek {
  flex: 1 1 auto;
  min-width: 4.5rem;
  height: 0.35rem;
  accent-color: var(--primary);
  cursor: pointer;
  direction: ltr;
  writing-mode: horizontal-tb;
  unicode-bidi: isolate;
}
.call-player-time {
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 3.6rem;
}
.call-player-speed {
  flex: 0 0 auto;
  width: auto;
  min-width: 3.6rem;
  max-width: 4.4rem;
  height: 1.65rem;
  padding: 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  cursor: pointer;
  color-scheme: dark;
}
.call-player-speed option {
  background: var(--surface);
  color: var(--text);
}

.kanban-card-meta,
.kanban-card-due {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.kanban-card-due { color: #93c5fd; }
.kanban-card-due--overdue { color: #f87171; font-weight: 600; }

.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.cal-toolbar strong {
  flex: 1;
  text-align: center;
  font-size: 1.05rem;
}
.cal-grid-wrap { padding: 0.75rem; }
.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
}
.cal-weekdays {
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  font-weight: 600;
}
.cal-cell {
  min-height: 5.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.cal-cell--empty {
  background: transparent;
  border-color: transparent;
}
.cal-cell--today {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}
.cal-day-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}
.cal-tasks {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-height: 0;
}
.cal-task {
  display: block;
  width: 100%;
  text-align: right;
  border: none;
  border-radius: 4px;
  padding: 0.15rem 0.3rem;
  font-size: 0.7rem;
  cursor: pointer;
  color: #e2e8f0;
  background: rgba(59, 130, 246, 0.25);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-task:hover { filter: brightness(1.1); }
.cal-task--todo { background: rgba(245, 158, 11, 0.28); color: #fcd34d; }
.cal-task--doing { background: rgba(59, 130, 246, 0.28); color: #93c5fd; }
.cal-task--done { background: rgba(16, 185, 129, 0.28); color: #6ee7b7; }
.cal-more {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.task-transfer-history {
  margin-top: 0.6rem;
  max-height: 8rem;
  overflow: auto;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.task-transfer-item {
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
}

@media (max-width: 720px) {
  .cal-cell { min-height: 4.2rem; padding: 0.25rem; }
  .cal-task { font-size: 0.62rem; }
}
