*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; display: flex; min-height: 100vh; font-size: 14px; color: #1a1a1a; }

.sidebar { width: 200px; background: #1e293b; color: #e2e8f0; padding: 16px; flex-shrink: 0; }
.sidebar-logo { font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 24px; }
.sidebar ul { list-style: none; }
.sidebar ul li { margin-bottom: 4px; }
.sidebar ul li a { color: #cbd5e1; text-decoration: none; display: block; padding: 6px 8px; border-radius: 4px; }
.sidebar ul li a:hover { background: #334155; color: #fff; }
.triage-badge { background: #ef4444; color: #fff; border-radius: 10px; padding: 1px 6px; font-size: 11px; margin-left: 4px; }
.main-content { flex: 1; padding: 24px; overflow: auto; }
.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-header h1 { font-size: 22px; }

.kanban-board { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; min-height: 70vh; }
.kanban-col { min-width: 220px; max-width: 240px; background: #f1f5f9; border-radius: 8px; padding: 8px; }
.kanban-col.terminal { opacity: 0.65; background: #e2e8f0; }
.col-header { display: flex; justify-content: space-between; padding: 4px 4px 8px; font-weight: 600; font-size: 12px; text-transform: uppercase; color: #475569; }
.col-count { background: #94a3b8; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; }
.card-list { min-height: 40px; }

.deal-card { background: #fff; border-radius: 6px; padding: 10px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); cursor: grab; }
.deal-card:active { cursor: grabbing; }
.card-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.deal-id { font-size: 11px; color: #94a3b8; }
.card-title a { font-weight: 600; color: #1e293b; text-decoration: none; }
.card-title a:hover { color: #3b82f6; }
.card-firma { font-size: 12px; color: #64748b; margin-top: 2px; }
.card-zdroj { font-size: 11px; color: #94a3b8; margin-top: 4px; }
.countdown-warning { color: #dc2626; font-weight: 600; font-size: 12px; margin-top: 4px; }

.bant-badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.bant-badge.red { background: #fee2e2; color: #dc2626; }
.bant-badge.yellow { background: #fef9c3; color: #ca8a04; }
.bant-badge.green { background: #dcfce7; color: #16a34a; }
.bant-badge.none { display: none; }
.badge-review { background: #f97316; color: #fff; border-radius: 10px; padding: 1px 6px; font-size: 11px; font-weight: 700; }
.badge-auto { background: #e2e8f0; color: #475569; border-radius: 4px; padding: 1px 5px; font-size: 11px; }

.filter-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-form input, .filter-form select { padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 4px; }
.btn-primary { background: #3b82f6; color: #fff; padding: 7px 14px; border-radius: 4px; text-decoration: none; font-weight: 600; border: none; cursor: pointer; }
.btn-primary:hover { background: #2563eb; }
.btn-secondary { background: #e2e8f0; color: #475569; padding: 5px 10px; border-radius: 4px; border: none; cursor: pointer; }
.btn-danger { background: #fef2f2; color: #dc2626; padding: 5px 10px; border-radius: 4px; border: 1px solid #fca5a5; cursor: pointer; }
.btn-sm { padding: 2px 8px; font-size: 12px; background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; border-radius: 3px; cursor: pointer; }
.btn-delete { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 16px; }
.btn-approve { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; padding: 4px 10px; border-radius: 4px; cursor: pointer; }

form label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-weight: 500; }
form label input, form label select, form label textarea { padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 14px; }
form label textarea { min-height: 80px; resize: vertical; }
form button[type=submit] { padding: 8px 18px; background: #3b82f6; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-weight: 600; }
form a { color: #64748b; text-decoration: none; margin-left: 8px; }

.data-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.data-table th, .data-table td { padding: 8px 12px; border-bottom: 1px solid #e2e8f0; text-align: left; }
.data-table th { font-weight: 600; color: #475569; font-size: 12px; text-transform: uppercase; }
.data-table tr:hover { background: #f8fafc; }
.data-table a { color: #3b82f6; text-decoration: none; }

.empty-state { color: #94a3b8; font-style: italic; padding: 16px 0; }
.alert-error { background: #fef2f2; color: #dc2626; padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid #fca5a5; }
.alert-success { background: #f0fdf4; color: #16a34a; padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }

.deal-detail { max-width: 900px; }
.deal-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.deal-header h1 { font-size: 22px; }
.deal-id-badge { font-size: 13px; color: #94a3b8; font-weight: 400; }
.stav-badge { background: #e0f2fe; color: #0369a1; padding: 3px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.deal-meta { display: flex; gap: 16px; color: #64748b; font-size: 13px; margin-bottom: 16px; }
.deal-contacts { font-size: 13px; margin-bottom: 14px; }
.contact-list { list-style: none; padding: 0; margin: 4px 0 0 0; display: flex; flex-direction: column; gap: 4px; }
.contact-list li { display: flex; align-items: center; gap: 12px; }
.contact-link { color: #64748b; text-decoration: none; }
.contact-link:hover { color: #0369a1; text-decoration: underline; }

.discovery-section, .timeline-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid #e2e8f0; }
.discovery-section h2, .timeline-section h2 { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.approval-banner { padding: 8px 14px; border-radius: 6px; margin-bottom: 14px; background: #fef9c3; color: #92400e; }
.approval-banner.approved { background: #f0fdf4; color: #16a34a; }
.discovery-field { margin-bottom: 16px; padding: 12px; background: #f8fafc; border-radius: 6px; }
.field-status { font-size: 11px; padding: 1px 7px; border-radius: 10px; margin-left: 8px; }
.field-status.approved { background: #dcfce7; color: #16a34a; }
.field-status.ai_draft { background: #fef9c3; color: #92400e; }
.field-status.pending_review { background: #f1f5f9; color: #64748b; }
.bant-section { margin-top: 20px; padding: 14px; background: #f8fafc; border-radius: 6px; }
.bant-section h3 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.vp-pull-section { margin-top: 20px; padding: 14px; background: #f0f9ff; border-radius: 6px; }

.timeline { display: flex; flex-direction: column; gap: 8px; }
.activity-row { display: flex; align-items: flex-start; gap: 8px; padding: 10px; background: #f8fafc; border-radius: 6px; }
.activity-row.is-auto { background: #f0f9ff; }
.act-icon { font-size: 16px; min-width: 24px; }
.act-datum { font-size: 12px; color: #94a3b8; white-space: nowrap; }
.act-smer { font-size: 11px; background: #e2e8f0; border-radius: 4px; padding: 1px 6px; }
.act-obsah { flex: 1; font-size: 13px; color: #374151; }
.act-obsah > p { margin: 0 0 0.25rem 0; }
.act-obsah > p:last-child { margin-bottom: 0; }
.act-obsah > ul,
.act-obsah > ol { margin: 0; padding-left: 1.25rem; }
.form-hint { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.form-hint kbd { font-size: 10px; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 3px; padding: 0 3px; font-family: inherit; }
.act-ref { font-size: 11px; color: #3b82f6; }
.activity-form { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.activity-form select, .activity-form input, .activity-form textarea { padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 4px; }

.metrics-section, .state-counts-section, .source-quality-section { margin-bottom: 28px; }
.metrics-section h2, .state-counts-section h2, .source-quality-section h2 { font-size: 16px; margin-bottom: 12px; }
.metric-card { display: inline-block; padding: 16px 24px; background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0; }
.metric-label { font-size: 12px; color: #64748b; text-transform: uppercase; margin-bottom: 4px; }
.metric-value { font-size: 36px; font-weight: 700; color: #1e293b; }
.metric-value.empty { color: #94a3b8; }
.metric-sub { font-size: 12px; color: #94a3b8; margin-top: 4px; }
.metric-empty-note { font-size: 12px; color: #94a3b8; margin-top: 8px; }
.state-counts { display: flex; flex-wrap: wrap; gap: 8px; }
.state-count-item { padding: 6px 14px; background: #e0f2fe; border-radius: 20px; font-size: 13px; }
.state-count-item.terminal { background: #f1f5f9; }
.state-name { color: #0369a1; }
.state-n { font-weight: 700; color: #0369a1; margin-left: 6px; }
.state-n.zero { color: #94a3b8; }
.source-table { width: 100%; border-collapse: collapse; }
.source-table th, .source-table td { padding: 8px 12px; border-bottom: 1px solid #e2e8f0; text-align: left; font-size: 13px; }
.source-table th { font-weight: 600; color: #475569; font-size: 12px; }
.period-filter { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; }
.period-filter input { padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 4px; }

.triage-item { padding: 12px; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; margin-bottom: 10px; }
.triage-meta { font-size: 12px; color: #94a3b8; margin-bottom: 4px; }
.triage-content { font-size: 13px; color: #374151; margin-bottom: 8px; }
.triage-assign { display: flex; gap: 8px; align-items: center; }
.triage-assign select { padding: 5px 8px; border: 1px solid #cbd5e1; border-radius: 4px; }
.tracker-disconnected { color: #94a3b8; font-style: italic; }
.transition-warning, .won-prompt { border: 2px solid #f97316; }

/* ── Inline-create dialogs ── */
dialog { border: none; border-radius: 8px; padding: 0; box-shadow: 0 8px 32px rgba(0,0,0,.18); max-width: 420px; width: 100%; }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 10px; border-bottom: 1px solid #e2e8f0; font-weight: 600; }
.dialog-body { padding: 16px 18px 18px; }
.btn-inline-add { background: none; border: none; color: #3b82f6; font-size: 12px; cursor: pointer; padding: 0 0 0 6px; font-weight: 500; }
.btn-inline-add:hover { text-decoration: underline; }
.select-row { display: flex; align-items: center; gap: 4px; }

/* ── Activity status / planned timeline ── */
.next-activity-banner { padding: 10px 14px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 6px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.next-activity-banner.overdue { background: #fef2f2; border-color: #fca5a5; }
.timeline-group-header { font-size: 11px; font-weight: 600; text-transform: uppercase; color: #64748b; margin-bottom: 6px; letter-spacing: 0.05em; }
.timeline-divider { text-align: center; color: #94a3b8; font-size: 12px; margin: 12px 0; border-top: 1px solid #e2e8f0; padding-top: 8px; }
.activity-row.overdue { background: #fef2f2; border-left: 3px solid #dc2626; }
.badge-overdue { background: #fee2e2; color: #dc2626; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700; }
.badge-planned { background: #eff6ff; color: #2563eb; border-radius: 10px; padding: 1px 7px; font-size: 11px; }
.btn-mark-done { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; padding: 3px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.btn-mark-done:hover { background: #dcfce7; }
.select-row select { flex: 1; }

/* ── Agenda page ── */
.agenda-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.agenda-table th { text-align: left; padding: 8px 10px; border-bottom: 2px solid #e2e8f0; color: #64748b; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.agenda-table td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.agenda-table tbody tr:hover td { background: #f8fafc; }
.agenda-table tr.overdue td { background: #fef2f2; }
.agenda-table tr.overdue:hover td { background: #fee2e2; }
.agenda-datum { white-space: nowrap; }
.agenda-obsah { color: #64748b; max-width: 260px; }
.agenda-badge { background: #3b82f6; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700; margin-left: 4px; }

/* ── Activity form status hint ── */
.status-hint { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; margin-left: 4px; }
.hint-done { background: #f0fdf4; color: #16a34a; }
.hint-planned { background: #eff6ff; color: #2563eb; }

/* ── Quick-log buttons ── */
.quicklog-buttons { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; margin-bottom: 4px; }
.quicklog-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; }
.btn-quicklog { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; border-radius: 14px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.btn-quicklog:hover { background: #e2e8f0; color: #1e293b; }
.activity-form select[hidden] { display: none; }
.btn-quicklog--active { background: #334155; color: #f8fafc; border-color: #334155; font-weight: 600; }

/* ── Relative time in planned timeline ── */
.act-relative { font-size: 11px; color: #94a3b8; margin-left: 4px; }
.act-relative.overdue-hint { color: #dc2626; }

/* ── Email card in timeline ── */
.email-card { background: #f0f7ff; border-left: 3px solid #3b82f6; border-radius: 4px; padding: 10px 12px; margin: 4px 0; width: 100%; box-sizing: border-box; }
.email-header { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; margin-bottom: 6px; font-size: 13px; }
.email-from { font-weight: 600; color: #1e3a5f; }
.email-subject { color: #374151; flex: 1; }
.email-body, .email-body-preview { white-space: pre-wrap; word-break: break-word; overflow-wrap: break-word; font-size: 12px; color: #374151; background: transparent; border: none; padding: 0; margin: 4px 0 0; font-family: inherit; }
.email-toggle { font-size: 11px; color: #3b82f6; text-decoration: none; display: inline-block; margin-top: 4px; }
.email-toggle:hover { text-decoration: underline; }

/* ── Global inbox (/emails) ── */
.emails-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.emails-table th { text-align: left; padding: 6px 10px; border-bottom: 2px solid #e2e8f0; color: #64748b; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.emails-table td { padding: 7px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.emails-table tr:hover td { background: #f8fafc; }
.badge-triage { background: #f97316; color: #fff; padding: 2px 7px; border-radius: 10px; font-size: 11px; }
.badge-ignored { background: #94a3b8; color: #fff; padding: 2px 7px; border-radius: 10px; font-size: 11px; }

/* ── Pagination ── */
.pagination { display: flex; gap: 12px; align-items: center; margin-top: 16px; font-size: 13px; color: #64748b; }
.pagination a { color: #3b82f6; text-decoration: none; }
.pagination a:hover { text-decoration: underline; }

/* ── Inline activity edit ── */
.btn-edit { background: none; border: none; cursor: pointer; font-size: 14px; color: #94a3b8; padding: 0 4px; line-height: 1; }
.btn-edit:hover { color: #475569; }
.activity-edit-form-row { flex-wrap: wrap; }
.edit-form-buttons { display: flex; gap: 8px; margin-top: 4px; }

/* Profil kontaktu */
.profil-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid #e2e8f0; }
.profil-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.profil-dl { display: grid; grid-template-columns: 150px 1fr; gap: 5px 12px; font-size: 13px; }
.profil-dl dt { color: #64748b; font-weight: 500; }
.profil-dl dd { margin: 0; }
.birthday-inputs { display: flex; gap: 12px; }
.profil-chip { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px;
               background: #e0f2fe; color: #0369a1; margin-left: 4px; vertical-align: middle; }
.profil-chip--birthday { background: #fef9c3; color: #92400e; }
.form-error { color: #dc2626; font-size: 12px; flex-basis: 100%; }

/* ── Login page (standalone, bez sidebaru) ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #0f172a; padding: 16px; }
.login-card { background: #fff; border-radius: 12px; padding: 32px 28px; max-width: 360px; width: 100%; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.login-logo { font-size: 22px; font-weight: 700; color: #1e293b; margin-bottom: 8px; }
.login-hint { color: #64748b; font-size: 13px; margin-bottom: 20px; }
.btn-github { display: inline-block; width: 100%; padding: 12px 16px; min-height: 44px; background: #1e293b; color: #fff; text-decoration: none; border-radius: 6px; font-weight: 600; }
.btn-github:hover { background: #334155; }

/* ── Mobile nav toggle / off-canvas (desktop: hidden) ── */
.nav-toggle { display: none; }
.nav-backdrop { display: none; }
/* "Přesunout do stavu" dropdown — skrytý na desktopu (DnD místo něj) */
.card-move { display: none; }

@media (max-width: 768px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  body { display: block; }

  .nav-toggle {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 8px; left: 8px; z-index: 1002;
    width: 44px; height: 44px; min-width: 44px; min-height: 44px;
    background: #1e293b; color: #fff; border: none; border-radius: 6px;
    font-size: 22px; cursor: pointer;
  }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 1001;
    width: 240px; max-width: 80vw; height: 100vh; overflow-y: auto;
    transform: translateX(-100%); transition: transform 0.22s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); }

  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,.45);
  }

  .sidebar ul li a { padding: 11px 10px; min-height: 44px; }

  .main-content { padding: 16px 12px; padding-top: 60px; overflow-x: hidden; }
  .main-content img, .main-content table, .main-content pre { max-width: 100%; }

  .page-header { flex-wrap: wrap; }

  /* Kanban: horizontální scroll-snap, další sloupec vykukuje */
  .kanban-board {
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    min-height: auto;
  }
  .kanban-col {
    flex: 0 0 85vw; min-width: 0; max-width: 85vw;
    scroll-snap-align: start;
  }

  /* "Přesunout do stavu" dropdown viditelný na mobilu */
  .card-move { display: block; margin-top: 8px; }
  .card-move select { width: 100%; min-height: 44px; padding: 8px 10px;
    border: 1px solid #cbd5e1; border-radius: 4px; font-size: 14px; }
  .deal-card { cursor: default; }

  /* Single-column formuláře a detail */
  .deal-detail { max-width: 100%; }
  .deal-header, .deal-meta { flex-wrap: wrap; }
  .filter-form { flex-direction: column; align-items: stretch; }
  .filter-form input, .filter-form select, .filter-form button,
  .filter-form .btn-primary { width: 100%; min-height: 44px; }

  form label input, form label select, form label textarea { min-height: 44px; }
  form button[type=submit] { min-height: 44px; width: 100%; }

  .data-table { display: block; overflow-x: auto; }
}
