:root {
  --bg: #f3f5fb;
  --surface: #ffffff;
  --surface-soft: #f9fbff;
  --text: #101828;
  --muted: #667085;
  --line: #e5e7eb;
  --primary: #1d4ed8;
  --primary-strong: #1e40af;
  --danger: #dc2626;
  --danger-strong: #b91c1c;
  --success: #16a34a;
  --sidebar: #0f172a;
  --sidebar-text: #e2e8f0;
}

* {
  box-sizing: border-box;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: var(--sidebar-text);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid #1f2937;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #94a3b8;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #60a5fa;
  box-shadow: 0 0 14px rgba(96, 165, 250, 0.8);
}

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

.nav-btn {
  text-align: left;
  border: 1px solid #1f2937;
  border-radius: 10px;
  background: transparent;
  color: #cbd5e1;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-btn:hover {
  background: #1f2937;
  color: #ffffff;
}

.nav-btn.active {
  background: #1e3a8a;
  border-color: #1d4ed8;
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
}

.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #1f2937;
  border: 1px solid #334155;
}

.workspace {
  padding: 18px 20px 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}

.topbar h2 {
  margin: 0;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

.panel.subtle {
  background: var(--surface-soft);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-head h3 {
  margin: 0;
}

.companies-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.segmented-control {
  display: inline-flex;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 10px;
  overflow: hidden;
}

.seg-btn {
  background: transparent;
  border: 0;
  color: #334155;
  padding: 7px 12px;
  font-size: 13px;
}

.seg-btn:hover {
  background: #e2e8f0;
  border-color: transparent;
}

.seg-btn.active {
  background: #1d4ed8;
  color: #fff;
}

.check-inline {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.check-inline input {
  width: 16px;
  height: 16px;
}

.progress-wrap {
  margin-top: 8px;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
  border: 1px solid #d1d5db;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #1d4ed8 100%);
  transition: width 0.25s ease;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.kpi-card h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.kpi-card p {
  margin: 8px 0 0;
  font-size: 26px;
  font-weight: 700;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
}

.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  background: #eff6ff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}

.timeline,
.stack-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.timeline li,
.stack-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  font-size: 13px;
  line-height: 1.4;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.form-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.help-text {
  font-size: 12px;
  color: var(--muted);
}

.companies-summary-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chip-button {
  cursor: pointer;
}

.chip-button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

input,
textarea,
select,
button {
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

button {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

button:hover {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

button.danger:hover {
  background: var(--danger-strong);
  border-color: var(--danger-strong);
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-actions.wrap {
  flex-wrap: wrap;
}

#kanban-scroll-tools button {
  min-width: 44px;
}

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

.data-table th,
.data-table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  font-size: 13px;
  vertical-align: top;
}

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

.row-selected {
  background: #eff6ff !important;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
}

.draft-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.channel-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid #bae6fd;
  background: #e0f2fe;
  color: #0369a1;
}

.channel-pill.messenger {
  border-color: #ddd6fe;
  background: #ede9fe;
  color: #6d28d9;
}

.meta-mini {
  font-size: 12px;
  color: var(--muted);
}

.jobs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.kanban-board {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: max-content;
  padding-bottom: 8px;
}

.qr-box {
  margin-top: 12px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

#companies-kanban-view {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
}

.kanban-column {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  min-height: 220px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.kanban-column-header {
  border-bottom: 1px solid #e2e8f0;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.kanban-column-header h4 {
  margin: 0;
  font-size: 13px;
}

.kanban-count {
  font-size: 12px;
  color: var(--muted);
}

.kanban-lane {
  padding: 10px;
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 170px;
}

.kanban-lane.drag-over {
  background: #dbeafe;
  border-radius: 0 0 12px 12px;
}

.kanban-empty {
  color: var(--muted);
  font-size: 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}

.kanban-card {
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #fff;
  padding: 9px;
  cursor: grab;
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card.dragging {
  opacity: 0.65;
}

.kanban-card h5 {
  margin: 6px 0;
  font-size: 13px;
  line-height: 1.35;
}

.kanban-meta {
  font-size: 12px;
  color: var(--muted);
  display: grid;
  gap: 2px;
}

.kanban-card .inline-actions {
  margin-top: 8px;
}

.job-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  font-size: 13px;
}

.company-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.company-header h2 {
  margin: 0;
}

.status-tools {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.company-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.info-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px;
  margin: 0;
}

.info-list dt {
  color: var(--muted);
  font-size: 12px;
}

.info-list dd {
  margin: 0;
  font-size: 13px;
}

.text-block {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 13px;
}

.danger-zone {
  border-color: #fecaca;
  background: #fff7f7;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1000;
  background: #111827;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 220px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.toast.error {
  background: #7f1d1d;
}

.toast.success {
  background: #14532d;
}

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .panel-grid,
  .company-grid {
    grid-template-columns: 1fr;
  }

  .jobs-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-tools {
    grid-template-columns: 1fr 1fr;
  }
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 50;
  }

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

  .kpi-grid,
  .jobs-grid {
    grid-template-columns: 1fr;
  }

.status-tools {
  grid-template-columns: 1fr;
}
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  width: min(420px, 90vw);
  background: var(--surface);
  padding: 32px;
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.brand.compact h1 {
  font-size: 18px;
}

.login-form {
  display: grid;
  gap: 16px;
  margin: 24px 0 16px;
}

.login-form input {
  margin-top: 6px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.login-form button {
  width: 100%;
}

.error-text {
  color: var(--danger);
  font-size: 14px;
  margin: 0;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 12px;
  background: #eef2ff;
  color: #1e1b4b;
  text-decoration: none;
  font-weight: 600;
  border: 1px solid #c7d2fe;
}

.link-button:hover {
  background: #e0e7ff;
}

.tg-leads {
  display: grid;
  gap: 12px;
}

.tg-lead-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--surface-soft);
  display: grid;
  gap: 8px;
}

.tg-lead-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.tg-lead-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tg-lead-actions button {
  padding: 8px 12px;
  font-size: 13px;
}
