/* CRM-specific styles — extends admin.css */

/* ── No-sidebar layout (CRM runs full-width) ─────── */
.admin-shell--no-sidebar { display: block; }
.admin-shell--no-sidebar .admin-sidebar { display: none; }
.admin-shell--no-sidebar .admin-main { padding: 24px 32px; }

/* ── Back link ───────────────────────────────────── */
.crm-back-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.1s;
  white-space: nowrap;
}
.crm-back-link:hover { color: var(--primary); }

/* ── Bento dashboard grid ────────────────────────── */
.bento-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
.bento-grid .bento-full { grid-column: 1 / -1; }
.bento-grid .bento-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  overflow: hidden;
}
.bento-card .bento-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bento-card .bento-title .bt-count {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: #EFF6FF;
  color: #2563EB;
}

/* ── Header ──────────────────────────────────────── */

.crm-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.crm-header h1 { margin: 0; margin-right: auto; }

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 360px;
  min-width: 220px;
}

#global-search {
  padding: 10px 56px 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  width: 100%;
  background: #F1F5F9;
  font-family: inherit;
}
#global-search:focus {
  outline: none;
  border-color: var(--primary);
}

.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Monaco, Menlo, monospace;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: all 0.1s;
}
.search-kbd:hover {
  border-color: var(--text);
  color: var(--text);
}

/* Mobile-only icon search button — shown only ≤768px (see media query) */
.crm-mobile-search-btn {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.crm-mobile-search-btn:hover { background: var(--bg); color: var(--text); }
.crm-mobile-search-btn:active { background: var(--border); }

/* ── Tabs (pill / segment control) ────────────────── */

.crm-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  background: #F1F5F9;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.crm-tab {
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: inherit;
  transition: all 0.15s;
}
.crm-tab:hover { color: var(--text); background: rgba(255,255,255,0.5); }
.crm-tab.active {
  color: var(--primary);
  background: white;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── Section header (with right-aligned totals) ─── */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.section-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.section-totals {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.section-totals .st-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.section-totals .st-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.section-totals .st-value {
  font-weight: 600;
  color: var(--text);
}

/* ── Revenue chart (SVG) ─────────────────────────── */

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  overflow-x: auto;
}
.chart-card svg {
  display: block;
  width: 100%;
  min-width: 480px;
  height: 280px;
}
.chart-bar-realized { fill: #10b981; }
.chart-bar-expected { fill: #3b82f6; opacity: 0.75; }
.chart-bar-realized:hover, .chart-bar-expected:hover { opacity: 1; filter: brightness(1.08); }
.chart-axis text {
  font-size: 11px;
  fill: var(--text-muted);
  font-family: inherit;
}
.chart-grid line {
  stroke: var(--border);
  stroke-dasharray: 2 3;
}
.chart-bar-label {
  font-size: 10px;
  fill: var(--text);
  font-weight: 600;
  text-anchor: middle;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.chart-bar-label.muted { fill: var(--text-muted); font-weight: 500; }
.chart-empty {
  padding: 60px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}
.chart-month-label {
  font-size: 11px;
  fill: var(--text);
  font-weight: 500;
  text-anchor: middle;
  font-family: inherit;
}
.chart-month-label.future { fill: var(--text-muted); font-style: italic; }

/* Chart tooltip */
.chart-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  background: var(--bg, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  min-width: 180px;
  opacity: 0;
  transition: opacity 0.12s;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .tt-title {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text);
}
.chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.chart-tooltip .tt-row + .tt-row { margin-top: 3px; }
.chart-tooltip .tt-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.chart-tooltip .tt-label {
  color: var(--text-muted);
  flex: 1;
}
.chart-tooltip .tt-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.chart-tooltip .tt-divider {
  border-top: 1px solid var(--border);
  margin: 6px 0;
}
.chart-tooltip .tt-deals {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Leads tab ───────────────────────────────────── */

.leads-info {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.leads-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

/* ── Lead validity + status badges ───────────────── */

.lead-row {
  display: grid;
  grid-template-columns: 1fr 180px 110px 110px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.1s;
}
.lead-row:hover { background: var(--bg); }
.lead-row:last-child { border-bottom: none; }
.lead-row .lr-title { font-weight: 600; }
.lead-row .lr-partner { color: var(--text-muted); font-size: 13px; }
.lead-row .lr-status, .lead-row .lr-validity { display: flex; justify-content: center; }

.validity-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.validity-badge.fresh    { background: #d1fae5; color: #059669; }
.validity-badge.warning  { background: #fef3c7; color: #92400e; }
.validity-badge.expiring { background: #fed7aa; color: #c2410c; }
.validity-badge.expired  { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }

.lead-status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.lead-status-connected   { background: #e5e7eb; color: #4b5563; }
.lead-status-no_response { background: #fef3c7; color: #92400e; }
.lead-status-in_progress { background: #fed7aa; color: #c2410c; }
.lead-status-to_invoice  { background: #d1fae5; color: #059669; }
.lead-status-completed   { background: #fce7f3; color: #be185d; }
.lead-status-abandoned   { background: #fee2e2; color: #dc2626; }

@media (max-width: 768px) {
  .lead-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .lead-row .lr-status, .lead-row .lr-validity { justify-content: flex-start; }
}

/* ── Today dashboard ─────────────────────────────── */

.today-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.today-section.full-width { grid-column: 1 / -1; }

.today-section h2 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text-subtle, var(--text-muted));
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-left: 12px;
  border-left: 3px solid var(--primary);
}

.today-list {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.today-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 12px;
}
.today-item:last-child { border-bottom: none; }
.today-item:hover { background: var(--bg); }

.today-item .item-name { font-weight: 600; flex: 1; }
.today-item .item-meta { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.today-item .item-amount {
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.today-item .item-date {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.today-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Pipeline cards ──────────────────────────────── */

.pipeline-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.pipeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  border-top: 3px solid var(--stage-color, var(--border));
}
.pipeline-card .pc-count {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pipeline-card .pc-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 2px;
}
.pipeline-card .pc-revenue {
  font-size: 15px;
  font-weight: 700;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

/* ── Pipeline filter banner ──────────────────────── */
.pipeline-filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: #1E40AF;
  margin-bottom: 12px;
}
.pipeline-filter-banner button {
  background: none;
  border: 1px solid #BFDBFE;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #1E40AF;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.1s;
}
.pipeline-filter-banner button:hover {
  background: #DBEAFE;
  border-color: #93C5FD;
}

/* ── Pipeline view toggle ────────────────────────── */

.pipeline-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}
.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  background: white;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.1s;
}
.view-toggle-btn:not(:last-child) { border-right: 1px solid var(--border); }
.view-toggle-btn:hover { background: var(--bg); color: var(--text); }
.view-toggle-btn.active { background: var(--text); color: white; }
.view-toggle-btn svg { flex-shrink: 0; }

/* ── Column settings popover (kanban only) ───────── */

.column-settings {
  position: relative;
}
.column-settings-btn svg {
  opacity: 0.8;
}
.column-settings-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.14);
  padding: 12px;
  min-width: 320px;
  z-index: 25;
  animation: pop-in 0.12s ease-out;
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.column-settings-popover .csp-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 4px 8px;
}
.csp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
}
.csp-row .stage-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.csp-row .stage-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
}
.csp-state-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.csp-state-toggle button {
  padding: 5px 10px;
  border: none;
  background: white;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
}
.csp-state-toggle button:not(:last-child) {
  border-right: 1px solid var(--border);
}
.csp-state-toggle button:hover {
  background: var(--bg);
  color: var(--text);
}
.csp-state-toggle button.active {
  background: var(--text);
  color: white;
}
.csp-footer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}
.csp-reset {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 8px;
}
.csp-reset:hover { color: var(--text); text-decoration: underline; }

/* ── Collapsed kanban column (48px vertical bar) ── */

.kanban-col.collapsed {
  flex: 0 0 48px;
  min-width: 48px;
  max-width: 48px;
  max-height: calc(100vh - 240px);
  cursor: pointer;
  transition: flex-basis 0.15s;
}
.kanban-col.collapsed:hover {
  background: #e8eef5;
}
.kanban-col.collapsed .kanban-col-header,
.kanban-col.collapsed .kanban-col-revenue,
.kanban-col.collapsed .kanban-cards {
  display: none;
}
.kanban-col.collapsed .kanban-col-collapsed-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 12px;
  height: 100%;
  position: relative;
}
.kanban-col:not(.collapsed) .kanban-col-collapsed-body { display: none; }
.kanban-col-collapsed-body .stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.kanban-col-collapsed-body .stage-name-v {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  color: var(--text);
  margin-top: 8px;
}
.kanban-col-collapsed-body .stage-count-v {
  background: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Collapse button in expanded column header */
.kanban-col-header .col-collapse-btn {
  background: none;
  border: none;
  padding: 2px 6px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 3px;
  flex-shrink: 0;
}
.kanban-col-header .col-collapse-btn:hover {
  background: white;
  color: var(--text);
}

/* ── Pipeline kanban (drag & drop, web-only) ─────── */

.pipeline-kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  min-height: 60vh;
}
.kanban-col {
  flex: 0 0 280px;
  background: var(--bg);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  max-height: min(calc(100vh - 240px), 660px);
}
.kanban-col-header {
  padding: 12px 14px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  border-radius: 10px 10px 0 0;
  z-index: 1;
}
.kanban-col-header .stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.kanban-col-header .stage-name {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.kanban-col-header .stage-count {
  font-size: 12px;
  color: var(--text-muted);
  background: white;
  padding: 2px 8px;
  border-radius: 10px;
}
.kanban-col-revenue {
  padding: 0 14px 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}
.kanban-cards.drag-over {
  background: rgba(255, 122, 89, 0.08);
  outline: 2px dashed var(--primary);
  outline-offset: -4px;
  border-radius: 8px;
}
.kanban-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: grab;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: all 0.1s;
}
.kanban-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.kanban-card.dragging {
  opacity: 0.4;
  cursor: grabbing;
}
.kanban-card .kc-name {
  font-weight: 600;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kanban-card .kc-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.kanban-card .kc-amount {
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.kanban-empty {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 24px 8px;
  font-style: italic;
}

/* Hide kanban on mobile (drag&drop is awkward on touch screens — keep list view) */
@media (max-width: 900px) {
  .view-toggle-btn[data-view="kanban"] { display: none; }
  .view-toggle-btn[data-comm-view="kanban"] { display: none; }
  .pipeline-kanban { display: none !important; }
}

/* ── Pipeline calendar (month grid) ──────────────── */

.pipeline-calendar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.cal-header .cal-title {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
  text-transform: capitalize;
  font-variant-numeric: tabular-nums;
}
.cal-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}
.cal-nav-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  transition: all 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
}
.cal-nav-btn:hover {
  background: var(--bg);
  border-color: var(--text);
}
.cal-nav-today {
  padding: 6px 12px;
  margin-right: 4px;
}
.cal-totals {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}
.cal-totals strong { color: var(--text); font-weight: 600; }

.cal-weekdays {
  display: grid;
  grid-template-columns: 36px repeat(7, 1fr);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.cal-weekdays .cal-weekday.cal-wknum-head {
  font-size: 9px;
  text-align: center;
  padding: 8px 4px;
  color: #94a3b8;
}
.cal-weekday {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
}
.cal-weekday.weekend { color: #94a3b8; }

.cal-grid {
  display: grid;
  grid-template-columns: 36px repeat(7, 1fr);
  grid-auto-rows: minmax(112px, 1fr);
}
.cal-wknum {
  background: var(--bg);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}
.cal-day {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 112px;
  background: white;
  overflow: hidden;
}
/* Last column = Ne (Sunday) — 8n because first column is the week-number cell */
.cal-day:nth-child(8n) { border-right: none; }

.cal-day.other-month {
  background: #fafbfc;
  color: var(--text-muted);
}
.cal-day.other-month .cal-day-num { color: #cbd5e1; }

.cal-day.today .cal-day-num {
  background: var(--primary);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.cal-day.weekend { background: #fafbfc; }

.cal-day-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}

.cal-event {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: filter 0.1s;
  line-height: 1.3;
}
.cal-event:hover { filter: brightness(1.1); }
.cal-event-amount {
  float: right;
  opacity: 0.85;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}

.cal-more {
  font-size: 10px;
  color: var(--text-muted);
  padding: 2px 4px;
  cursor: pointer;
  font-weight: 500;
}
.cal-more:hover { color: var(--text); text-decoration: underline; }

/* Day popover — opens when user clicks "+N další" or the day number */
.cal-day-popover {
  position: fixed;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
  padding: 12px;
  min-width: 280px;
  max-width: 360px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 50;
}
.cal-day-popover h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cal-day-popover .cal-event {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  padding: 6px 10px;
}

@media (max-width: 900px) {
  .view-toggle-btn[data-view="calendar"] { display: none; }
  .pipeline-calendar { display: none !important; }
}

/* ── Pipeline board (vertical list grouped by stage) ── */

.pipeline-board { display: flex; flex-direction: column; gap: 24px; }

.pipeline-stage {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border-left: 4px solid var(--stage-color, var(--border));
}

.pipeline-stage-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.pipeline-stage-header .stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.pipeline-stage-header .stage-name {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
}
.pipeline-stage-header .stage-count {
  font-size: 13px;
  color: var(--text-muted);
}
.pipeline-stage-header .stage-revenue {
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.pipeline-deal {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 2fr 1.5fr 100px 100px 100px 100px;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 14px;
}
.pipeline-deal:last-child { border-bottom: none; }
.pipeline-deal:hover { background: var(--bg); }
.pipeline-deal-header {
  cursor: default;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 16px;
  background: var(--bg);
}
.pipeline-deal-header:hover { background: var(--bg); }
.pipeline-deal .pd-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipeline-deal .pd-company {
  color: var(--text-muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pipeline-deal .pd-date {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}
.pipeline-deal .pd-revenue,
.pipeline-deal .pd-costs,
.pipeline-deal .pd-profit {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
  font-size: 14px;
}
.pipeline-deal .pd-revenue { font-weight: 700; }
.pipeline-deal .pd-costs { color: var(--text-muted); }
.pipeline-deal .pd-profit { font-weight: 600; color: var(--success, #22c55e); }
.pipeline-deal .pd-profit.negative { color: var(--danger, #ef4444); }

@media (max-width: 900px) {
  .pipeline-deal {
    grid-template-columns: 2fr 1fr 90px 90px;
  }
  .pipeline-deal .pd-costs,
  .pipeline-deal .pd-profit { display: none; }
  .pipeline-deal-header .pd-costs,
  .pipeline-deal-header .pd-profit { display: none; }
}

/* ── Companies table ─────────────────────────────── */

.ct-count {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.company-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.company-table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.company-table th.ct-sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.12s;
}
.company-table th.ct-sortable:hover,
.company-table th.ct-sorted {
  color: var(--text);
}
.company-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.company-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}
.company-table tbody tr:hover {
  background: var(--bg-hover, rgba(0,0,0,0.03));
}
.company-table .ct-name {
  font-weight: 600;
  white-space: nowrap;
}
.company-table .ct-ico {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 13px;
}
.company-table .ct-web {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.company-table td a {
  color: var(--primary);
  text-decoration: none;
}
.company-table td a:hover {
  text-decoration: underline;
}

/* ── Detail overlay ──────────────────────────────── */

.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45,62,80,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);   }
}

.detail-panel {
  width: 640px;
  max-width: calc(100vw - 48px);
  max-height: 92vh;
  background: white;
  overflow-y: auto;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.22), 0 0 0 1px rgba(0,0,0,0.04);
  border-radius: 16px;
  position: relative;
  animation: modal-in 0.2s ease-out;
}

.detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}
.detail-close:hover { color: var(--text); }

.detail-header { margin-bottom: 24px; }
.detail-header h2 { margin: 0 0 4px; font-size: 22px; }
.detail-header .dh-meta { color: var(--text-muted); font-size: 14px; }

.detail-section {
  margin-bottom: 24px;
}
.detail-section h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.detail-field { font-size: 14px; }
.detail-field .df-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.detail-field .df-value { font-weight: 500; }

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Stage colors */
.stage-inquiry    { background: #f1f5f9; color: #64748b; }
.stage-invited    { background: #dbeafe; color: #2563eb; }
.stage-scheduled  { background: #e0e7ff; color: #4f46e5; }
.stage-proposal   { background: #ede9fe; color: #7c3aed; }
.stage-won        { background: #d1fae5; color: #059669; }
.stage-lost       { background: #fee2e2; color: #dc2626; }
.stage-invoiced   { background: #ccfbf1; color: #0d9488; }

/* ── Deal items table ────────────────────────────── */
.items-table {
  width: 100%;
  font-size: 14px;
  border-collapse: collapse;
}
.items-table th {
  font-size: 12px;
  color: var(--text-muted);
  text-align: left;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.items-table td {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.items-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Timeline ────────────────────────────────────── */
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  font-size: 14px;
}
.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  margin-top: 6px;
  flex-shrink: 0;
}
.timeline-item .tl-text { flex: 1; }
.timeline-item .tl-date { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* ── Stage-aware checklist (collapsible, traffic light) ──── */

.checklist-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  overflow: hidden;
}
.checklist-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.checklist-summary:hover { background: var(--bg); }

.checklist-light {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}
.checklist-light.green  { background: #10b981; box-shadow: 0 0 0 3px #d1fae5; }
.checklist-light.red    { background: #ef4444; box-shadow: 0 0 0 3px #fee2e2; }
.checklist-light.gray   { background: #9ca3af; box-shadow: 0 0 0 3px #e5e7eb; }

.checklist-text { flex: 1; font-size: 14px; font-weight: 500; }
.checklist-toggle {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.checklist-card.expanded .checklist-toggle { transform: rotate(180deg); }

.checklist-details {
  display: none;
  padding: 4px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.checklist-card.expanded .checklist-details { display: block; }

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item.optional { opacity: 0.6; }

.checklist-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.checklist-icon.ok       { background: #d1fae5; color: #059669; }
.checklist-icon.miss     { background: #fee2e2; color: #dc2626; }
.checklist-icon.miss-opt { background: #f3f4f6; color: #9ca3af; }

.checklist-label { flex: 1; }
.checklist-required-badge {
  font-size: 9px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 4px;
}
.checklist-value {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Status picker (visual pipeline) ─────────────── */

.stage-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0 16px;
}
.stage-pick {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.1s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stage-pick .stage-pick-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.stage-pick:hover {
  border-color: var(--text);
  transform: translateY(-1px);
}
.stage-pick.selected {
  border-width: 2px;
  font-weight: 600;
  padding: 7px 11px; /* compensate border */
}

/* ── Form modal (create / edit) ──────────────────── */

.form-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45,62,80,0.5);
  z-index: 160;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.form-modal {
  background: white;
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.form-modal-header {
  padding: 20px 24px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.form-modal-header h3 { margin: 0; font-size: 18px; }
.form-modal-header .detail-close { position: static; }

#form-modal-body {
  padding: 16px 24px;
  overflow-y: auto;
  flex: 1;
}

.form-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-modal .form-row {
  margin-bottom: 12px;
}
.form-modal .form-field {
  margin-bottom: 12px;
}
.form-modal .form-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-modal .form-field input,
.form-modal .form-field textarea,
.form-modal .form-field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
}
.form-modal .form-field input:focus,
.form-modal .form-field textarea:focus,
.form-modal .form-field select:focus {
  outline: none;
  border-color: var(--primary);
}
.form-modal .form-field-row {
  display: flex;
  gap: 8px;
}
.form-modal .form-field-row input { flex: 1; }
.form-modal .form-field .field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-modal .field-error {
  color: var(--error);
  font-size: 12px;
  margin-top: 4px;
}

/* ARES button inside IČO field */
.btn-inline {
  padding: 9px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.btn-inline:hover { background: var(--border); }

/* Items table for deal create */
.items-builder {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.items-builder-row {
  display: grid;
  grid-template-columns: 1fr 70px 110px 32px;
  gap: 6px;
  padding: 6px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.items-builder-row:last-child { border-bottom: none; }
.items-builder-row input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}
.items-builder-row .item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
}
.items-builder-row .item-remove:hover { color: var(--error); }
.items-builder-add {
  width: 100%;
  padding: 8px;
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.items-builder-add:hover { background: var(--border); color: var(--text); }

/* Company picker (autocomplete) */
.company-picker {
  position: relative;
}
.company-picker-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.company-picker-result {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.company-picker-result:last-child { border-bottom: none; }
.company-picker-result:hover { background: var(--bg); }

/* Empty state — actionable, not just italic text */
.today-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  font-style: normal;
}

/* ── Inline editable fields (click to edit) ─────── */

.editable-field {
  cursor: text;
  border-bottom: 1px dashed transparent;
  transition: background 0.1s, border-color 0.1s;
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 3px;
  display: inline-block;
  min-width: 12px;
  min-height: 1em;
}
.editable-field:hover {
  background: #fff7f2;
  border-bottom-color: var(--primary);
}
.editable-field.editing {
  background: white;
  border-bottom-color: transparent;
  padding: 0;
  margin: 0;
  width: 100%;
}
.editable-field .placeholder {
  color: var(--text-muted);
  font-style: italic;
}
.editable-field .saving {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9em;
}
.editable-input {
  font: inherit;
  color: inherit;
  padding: 4px 8px;
  border: 2px solid var(--primary);
  border-radius: 4px;
  background: white;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}
.editable-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255,122,89,0.15);
}
textarea.editable-input {
  resize: vertical;
  min-height: 60px;
}

/* Flash-success animation after inline save */
.editable-field.saved {
  animation: flash-saved 0.7s ease-out;
}
@keyframes flash-saved {
  0%   { background: #d1fae5; box-shadow: 0 0 0 2px #10b981; }
  100% { background: transparent; box-shadow: 0 0 0 0 transparent; }
}

/* Editable h2 in detail header gets bigger input */
.detail-header h2 .editable-field,
.detail-header h2.editable-field {
  display: inline-block;
  min-width: 200px;
}
.detail-header h2 .editable-input {
  font-size: 22px;
  font-weight: 600;
}

/* Editable finance values keep tabular-nums */
.df-value .editable-field {
  font-variant-numeric: tabular-nums;
}

/* ── Inline edit ─────────────────────────────────── */
.detail-edit-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  margin-left: 8px;
  font-family: inherit;
}
.detail-edit-btn:hover { color: var(--text); border-color: var(--text); }

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}
.inline-form input,
.inline-form select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  flex: 1;
}

/* ── Command palette ─────────────────────────────── */

.palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45,62,80,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}

.palette {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  overflow: hidden;
}

.palette input {
  width: 100%;
  padding: 18px 24px;
  border: none;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  border-bottom: 1px solid var(--border);
}

.palette-results {
  max-height: 400px;
  overflow-y: auto;
}

.palette-results.inline {
  max-height: 200px;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-top: 4px;
}

.palette-item {
  padding: 12px 24px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.palette-item:last-child { border-bottom: none; }
.palette-item:hover, .palette-item.selected { background: var(--bg); }

.palette-item .pi-icon {
  width: 24px;
  text-align: center;
  font-size: 14px;
}
.palette-item .pi-title { flex: 1; font-weight: 500; font-size: 14px; }
.palette-item .pi-sub { font-size: 12px; color: var(--text-muted); }

/* ── Quick capture FAB + sheet ───────────────────── */

.fab {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255,122,89,0.4);
  z-index: 90;
  transition: all 0.15s;
}
.fab:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.capture-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45,62,80,0.5);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.capture-sheet {
  background: white;
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}

.capture-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.capture-header h3 { margin: 0; font-size: 18px; }

.capture-selected {
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 4px;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 500;
}

/* ── Mobile bottom nav ───────────────────────────── */

.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  z-index: 80;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}
.mob-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 8px 6px;
  font-size: 10px;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.mob-tab .mob-icon { width: 20px; height: 20px; flex-shrink: 0; }
.mob-tab.active { color: var(--primary); font-weight: 600; }

/* ── Reconciliation rows ─────────────────────────── */
.recon-delta-positive { color: #059669; font-weight: 600; }
.recon-delta-negative { color: #dc2626; font-weight: 600; }

/* ── Action strip (reconcile alerts on Dnes dashboard) ── */
.action-strip {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}
.action-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  flex: 1;
  cursor: pointer;
  transition: filter 0.1s;
}
.action-alert:hover { filter: brightness(0.97); }
.action-alert.alert-red {
  background: #FEF2F2;
  border-left: 4px solid #DC2626;
}
.action-alert.alert-yellow {
  background: #FFFBEB;
  border-left: 4px solid #F59E0B;
}
.action-alert.alert-green {
  background: #ECFDF5;
  border-left: 4px solid #059669;
}
.action-alert .alert-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.action-alert .alert-text {
  flex: 1;
}
.action-alert .alert-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.action-alert .alert-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.action-alert .alert-chevron {
  color: var(--text-subtle, #94A3B8);
  font-size: 16px;
}

/* ── Invoice button (deal detail) ────────────────── */
.btn-invoice {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 32px;
  background: linear-gradient(135deg, #059669, #10B981);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.3);
}
.btn-invoice:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-invoice:active { transform: translateY(0); }
.btn-invoice:disabled { opacity: 0.6; cursor: wait; filter: none; transform: none; }

/* ── Toast notification ─────────────────────────── */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 300;
  opacity: 0;
  transition: all 0.2s ease;
  pointer-events: none;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── FAB mini-menu ─────────────────────────────── */
.fab-menu {
  position: fixed;
  bottom: 96px;
  right: 32px;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  z-index: 91;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.15s ease;
}
.fab-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.fab-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text);
  transition: all 0.1s;
  white-space: nowrap;
}
.fab-menu-item:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.fab-menu-item .fmi-icon { font-size: 16px; }

/* ── Mobile bottom sheet ───────────────────────── */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 170;
  display: flex;
  align-items: flex-end;
}
.bottom-sheet {
  width: 100%;
  background: white;
  border-radius: 20px 20px 0 0;
  padding: 8px 0 max(16px, env(safe-area-inset-bottom));
  max-height: 80vh;
  overflow-y: auto;
}
.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: #CBD5E1;
  border-radius: 2px;
  margin: 0 auto 12px;
}
.bottom-sheet h3 {
  padding: 0 20px 12px;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.bottom-sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
  transition: background 0.1s;
  border: none;
  background: none;
  width: 100%;
  color: var(--text);
  min-height: 48px;
}
.bottom-sheet-item:hover { background: var(--bg); }
.bottom-sheet-item .bsi-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Detail panel drag handle (mobile) ──────────── */
.detail-drag-handle {
  display: none;
  width: 36px;
  height: 4px;
  background: #CBD5E1;
  border-radius: 2px;
  margin: 0 auto 16px;
}

/* ── PWA standalone mode (installed on home screen) ── */
/* Hide the admin sidebar + adjust padding when running as
   an installed PWA — the user only sees CRM with bottom nav. */
@media (display-mode: standalone) {
  .admin-sidebar { display: none !important; }
  .admin-shell { display: block; }
  .admin-main {
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: 80px;
  }
  /* iOS notch: extra top padding */
  .crm-header { padding-top: env(safe-area-inset-top); }
  .mobile-bottom-nav {
    display: flex !important;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
}

/* ════════════════════════════════════════════════════════════
   MOBILE REDESIGN  (≤768px)
   Goal: clean, minimal, thumb-reachable.
   - Sticky compact top bar (back · title · search icon)
   - Bottom nav (5 tabs) + FAB (4 create actions)
   - List-only views (kanban/calendar hidden)
   - Single-column bento, reordered by relevance
   - Universal text-overflow rules
   - 44px tap targets, safe-area aware
   ════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── Layout shell ─────────────────────────────── */
  body { -webkit-tap-highlight-color: transparent; }
  /* Hide global account menu — CRM has its own back link + FAB. */
  .admin-menu { display: none !important; }

  .admin-main {
    padding: 0 14px calc(96px + env(safe-area-inset-bottom));
    max-width: 100%;
  }

  /* ── Sticky compact top bar ───────────────────── */
  .crm-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    margin: 0 -14px 14px;
    padding: 8px 8px;
    padding-top: max(8px, env(safe-area-inset-top));
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 70;
  }
  .crm-header h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    flex: 1;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .crm-back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    color: var(--text-muted);
    font-size: 0;
    flex-shrink: 0;
  }
  .crm-back-link::before {
    content: "‹";
    font-size: 30px;
    line-height: 1;
    font-weight: 300;
  }
  .crm-header .btn-secondary,
  .crm-header .btn-primary { display: none; }
  .search-wrap { display: none; }
  .crm-mobile-search-btn { display: inline-flex; }

  /* ── Tab system: hide pill row, show bottom nav ── */
  .crm-tabs { display: none; }
  .mobile-bottom-nav { display: flex; }

  /* ── Action strip ─────────────────────────────── */
  .action-strip {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
  }
  .action-strip:empty { display: none; }
  .action-alert { padding: 12px 14px; border-radius: 10px; }
  .action-alert .alert-title { font-size: 13px; line-height: 1.35; }
  .action-alert .alert-sub {
    font-size: 12px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* ── Bento: single column, reordered ──────────── */
  .bento-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .bento-grid .bento-card { padding: 14px; border-radius: 10px; }
  .bento-card .bento-title { font-size: 13.5px; margin-bottom: 10px; }
  /* Mobile bento order via :has() — robust against DOM reorder.
     Priority: stale → pipeline summary → chart → commissions. */
  .bento-grid .bento-card:has(#stale-list)     { order: 1; }
  .bento-grid .bento-card:has(#pipeline-cards) { order: 2; }
  .bento-grid .bento-card:has(#revenue-chart)  { order: 3; }
  .bento-grid #commissions-today-card          { order: 4; }
  .chart-card svg { min-width: 0; height: 220px; }

  /* ── Pipeline / Leads / Commissions: list only ── */
  .pipeline-toolbar { display: none !important; }
  #pipeline-board     { display: block !important; }
  #pipeline-kanban,
  #pipeline-calendar  { display: none !important; }
  #leads-list         { display: block !important; }
  #leads-kanban       { display: none !important; }
  #commissions-list   { display: flex !important; flex-direction: column; gap: 8px; }
  #commissions-kanban { display: none !important; }
  .leads-info { font-size: 12.5px; padding: 10px 12px; line-height: 1.4; }

  /* ── Pipeline: vertical sectioned "kanban" by stage ── */
  #pipeline-board { display: flex !important; flex-direction: column; gap: 14px; }
  .pipeline-stage {
    border-radius: 12px;
    border-left-width: 4px;
    /* Bottom-margin handled via parent gap; reset desktop bottom-margin if any */
    margin-bottom: 0;
  }
  .pipeline-stage-header {
    padding: 14px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    gap: 10px;
  }
  .pipeline-stage-header .stage-name { font-size: 15px; font-weight: 600; }
  .pipeline-stage-header .stage-count {
    font-size: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 999px;
    color: var(--text-muted);
  }
  .pipeline-stage-header .stage-revenue { font-size: 14px; }
  /* Hide column-titles row (Název / Firma / Realizace / ...) — desktop only */
  .pipeline-deal-header { display: none !important; }

  /* Two-line deal card: name+amount on top, company+date below */
  .pipeline-deal {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 3px 12px;
    padding: 12px 16px;
    min-height: 60px;
    align-items: center;
  }
  .pipeline-deal .pd-name {
    grid-column: 1; grid-row: 1;
    font-size: 14px; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .pipeline-deal .pd-revenue {
    grid-column: 2; grid-row: 1;
    text-align: right;
    font-size: 14px; font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .pipeline-deal .pd-company {
    grid-column: 1; grid-row: 2;
    font-size: 12.5px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .pipeline-deal .pd-date {
    grid-column: 2; grid-row: 2;
    font-size: 12.5px; color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
    margin-top: 0;
  }
  /* Drop heavy desktop columns on mobile */
  .pipeline-deal .pd-costs,
  .pipeline-deal .pd-profit { display: none; }

  /* ── Companies: 3-col table, name truncated ───── */
  .company-table { font-size: 13px; table-layout: fixed; width: 100%; }
  .company-table th:nth-child(n+4),
  .company-table td:nth-child(n+4) { display: none; }
  .company-table th:nth-child(1),
  .company-table td:nth-child(1) { width: auto; }
  .company-table th:nth-child(2),
  .company-table td:nth-child(2) { width: 30%; }
  .company-table th:nth-child(3),
  .company-table td:nth-child(3) { width: 22%; }
  .company-table td, .company-table th { padding: 12px 8px; }
  .company-table tr { min-height: 48px; }
  .company-table .ct-name,
  .company-table td {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* ── Commission rows: stacked, full info ──────── */
  .commission-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 12px 14px;
  }
  .cr-main { grid-column: 1; grid-row: auto; }
  .cr-right {
    grid-column: 1; grid-row: auto;
    flex-wrap: wrap; gap: 8px; justify-content: flex-start;
  }
  .cr-deal {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 14px;
  }
  .cr-amount { font-size: 15px; }
  .cr-message { padding: 6px 10px; flex-wrap: wrap; }
  .cr-msg-text {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .commission-summary-bar { gap: 6px; }
  .commission-summary-item { font-size: 12px; padding: 6px 10px; }

  /* ── FAB + bottom nav: safe-area-aware ────────── */
  .fab {
    bottom: calc(72px + env(safe-area-inset-bottom));
    right: 16px;
    width: 56px; height: 56px;
  }
  .fab-menu {
    bottom: calc(140px + env(safe-area-inset-bottom));
    right: 16px;
  }
  .fab-menu-item {
    min-height: 44px;
    padding: 10px 18px;
    font-size: 14px;
  }

  /* ── Detail / form / palette overlays ─────────── */
  .detail-overlay { align-items: flex-end; padding: 0; }
  .detail-panel {
    width: 100vw; max-width: 100vw;
    max-height: 92vh;
    padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
    margin: 0;
  }
  .detail-drag-handle { display: block; }
  .detail-grid { grid-template-columns: 1fr; }

  .form-modal {
    max-height: 95vh;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  }
  .form-row { grid-template-columns: 1fr; }
  .items-builder-row { grid-template-columns: 1fr 1fr; gap: 4px; }

  .palette-overlay { padding: 32px 12px; align-items: flex-start; }
  .palette { max-width: 100%; }
  .capture-sheet {
    max-width: 100%;
    max-height: 92vh;
    padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  }

  /* Pull-to-refresh prevention on non-Dnes tabs */
  .tab-content { overscroll-behavior: contain; }

  /* ── Universal text overflow safety ───────────── */
  .pd-name, .deal-title, .company-name,
  .palette-item .pi-title,
  .upc-title, .stale-title, .act-title {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .alert-sub, .upc-meta, .stale-meta, .act-meta,
  .palette-item .pi-sub {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* ── Today list rows: bigger tap, 2-line layout ─ */
  .today-list { gap: 0; }
  .today-list > * {
    padding: 12px 12px;
    min-height: 56px;
    border-bottom: 1px solid var(--border);
  }
  .today-list > *:last-child { border-bottom: none; }

  /* ── Tap-target floor (44pt iOS HIG) ───────────── */
  .btn, .mob-tab, .fab-menu-item,
  .palette-item, .pipeline-deal, .commission-row,
  .crm-mobile-search-btn { min-height: 44px; }

  * { touch-action: manipulation; }
}

/* ── Skeleton loading placeholders ──────────────── */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-alt, #f0f0f0) 25%, var(--bg, #e8e8e8) 50%, var(--bg-alt, #f0f0f0) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

.skeleton-chart {
  height: 240px;
  min-height: 240px;
}

.skeleton-list-item {
  height: 44px;
  margin-bottom: 8px;
}

.skeleton-pipeline-card {
  height: 38px;
  margin-bottom: 6px;
}

/* Fade-in when real content replaces skeleton */
.fade-in {
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── COMMISSIONS ────────────────────────────────────── */

/* Commission status badge */
.commission-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.cs-k_fakturaci  { background: #FEF3C7; color: #92400E; }
.cs-notifikovan  { background: #DBEAFE; color: #1E40AF; }
.cs-vyfakturovano { background: #D1FAE5; color: #065F46; }
.cs-storno       { background: #F3F4F6; color: #6B7280; }

/* Commissions tab layout */
.commissions-summary { margin-bottom: 16px; }
.commission-summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.commission-summary-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
}
.cs-partner-name  { font-weight: 600; color: var(--text); }
.cs-partner-total { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.cs-partner-count { color: var(--text-muted); font-size: 11px; }

/* Commission row in commissions tab */
.commissions-list { display: flex; flex-direction: column; gap: 10px; }
.commission-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 6px 12px;
}
.cr-main  { grid-column: 1; grid-row: 1; }
.cr-right { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 10px; }
.cr-message { grid-column: 1 / -1; grid-row: 2; display: flex; align-items: center; gap: 10px;
  background: var(--bg); border-radius: 6px; padding: 8px 12px; }
.cr-deal  { font-size: 14px; font-weight: 600; }
.cr-meta  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.cr-sep   { margin: 0 4px; }
.cr-amount { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cr-status-select {
  font-size: 12px; padding: 3px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); cursor: pointer;
}
.cr-msg-text { flex: 1; font-size: 12px; color: var(--text-muted); }
.cr-copy-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 6px; font-size: 12px;
  border: 1px solid var(--border); background: var(--bg-card);
  cursor: pointer; white-space: nowrap; color: var(--text);
  transition: background 0.15s;
}
.cr-copy-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* Commission section in deal detail */
.commission-partner-picker { position: relative; }
.commission-partner-picker input[type=text] {
  width: 100%; box-sizing: border-box; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
  background: var(--bg);
}
.btn-save-commission {
  padding: 5px 16px; border-radius: 7px; font-size: 13px;
  background: var(--accent); color: white; border: none; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-save-commission:hover { opacity: 0.85; }
.btn-copy-msg {
  padding: 5px 14px; border-radius: 7px; font-size: 13px;
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  cursor: pointer;
}
.btn-copy-msg:hover { border-color: var(--accent); color: var(--accent); }
