/* TD-CRM — Light/Dark Theme */

/* Light theme (default) */
:root, [data-theme="light"] {
  --bg-main: #f5f7fa;
  --bg-panel: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f0f2f5;
  --border: #e5e7eb;
  --border-active: #4a7aff;
  --text: #1a1a2e;
  --text-dim: #6b7280;
  --text-bright: #0f172a;
  --accent: #4a7aff;
  --accent-dim: #eef2ff;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #ca8a04;
  --orange: #ea580c;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --code-bg: #f1f5f9;
}

/* Dark theme */
[data-theme="dark"] {
  --bg-main: #0a0e17;
  --bg-panel: #12171f;
  --bg-card: #161c27;
  --bg-hover: #1a2233;
  --border: #1e2633;
  --border-active: #203aff;
  --text: #c8ccd4;
  --text-dim: #6b7280;
  --text-bright: #e2e6ed;
  --accent: #4a7aff;
  --accent-dim: #0d1a4d;
  --green: #4ade80;
  --red: #ef4444;
  --yellow: #facc15;
  --orange: #fb923c;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
  --code-bg: #080b12;
}

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

body {
  background: var(--bg-main);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  transition: background 0.2s, color 0.2s;
}

/* ─── Layout ──────────────────────────────── */
.app { display: flex; height: 100vh; }

.sidebar {
  width: 200px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  color: var(--accent);
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  flex-shrink: 0;
}

.sidebar-nav { flex: 1; padding: 8px 0; }

/* Nav groups */
.nav-group { border-bottom: 1px solid var(--border); }
.nav-group-title {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.nav-group-title::after { content: '▸'; transition: transform 0.2s; font-size: 10px; }
.nav-group.open .nav-group-title::after { transform: rotate(90deg); }
.nav-group .nav-item { display: none; }
.nav-group.open .nav-item { display: block; }

.nav-item {
  display: block;
  padding: 7px 16px 7px 24px;
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  font-size: 13px;
}

.nav-item:hover { color: var(--text); background: var(--bg-hover); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: var(--bg-hover); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}

.sidebar-footer a { color: var(--text-dim); text-decoration: none; }
.sidebar-footer a:hover { color: var(--red); }

.main { flex: 1; overflow-y: auto; padding: 20px 24px; animation: fadeIn 0.15s ease; }

/* ─── Cards ───────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-link { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.card-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.card-link:active { transform: translateY(0); }

.card-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.card-value { font-size: 22px; color: var(--text-bright); margin-top: 4px; }
.card-value.green { color: var(--green); }
.card-value.red { color: var(--red); }
.card-value.yellow { color: var(--yellow); }
.card-value.accent { color: var(--accent); }
.card-value.orange { color: var(--orange); }

/* ─── Tables ──────────────────────────────── */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.table-title {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 8px 14px; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
td { padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }

/* ─── Badges ──────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: 11px; font-weight: 500; }
.badge-green { background: #0d3320; color: var(--green); }
.badge-red { background: #3b1111; color: var(--red); }
.badge-yellow { background: #3b2f05; color: var(--yellow); }
.badge-blue { background: var(--accent-dim); color: var(--accent); }
.badge-gray { background: #1e2633; color: var(--text-dim); }
.badge-orange { background: #3b2205; color: var(--orange); }

/* ─── Buttons ─────────────────────────────── */
.btn {
  padding: 8px 16px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--border-active);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { background: var(--accent); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* ─── Tabs (sub-filters) ─────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab { padding: 6px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; color: var(--text-dim); font-size: 13px; transition: all 0.15s; }
.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab.active { color: #fff; border-color: var(--accent); background: var(--accent); }

/* ─── Log viewer ──────────────────────────── */
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-active:hover { background: #3a6aef; }

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.log-viewer {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
  max-height: 500px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-dim);
}

/* ─── Section headers ─────────────────────── */
.section-title {
  font-size: 16px;
  color: var(--text-bright);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ─── Charts ─────────────────────────────── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.chart-grid-full { grid-template-columns: 1fr; }
@media (max-width: 800px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  min-height: 0;
}
.chart-box canvas { max-height: 260px; }
.chart-pie-wrap { max-width: 260px; max-height: 260px; margin: 0 auto; }
.chart-title {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 10px;
}

/* ─── Slide Panel (right drawer) ─────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.overlay.show { opacity: 1; pointer-events: auto; }

.slide-panel {
  position: fixed; top: 0; right: -420px; width: 420px; height: 100vh;
  background: var(--bg-panel); border-left: 1px solid var(--border);
  z-index: 101; transition: right 0.25s ease;
  display: flex; flex-direction: column;
  overflow-y: auto;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}
.slide-panel.show { right: 0; }
@media (max-width: 500px) { .slide-panel { width: 100vw; right: -100vw; } }

.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-size: 14px; color: var(--accent); font-weight: bold;
  flex-shrink: 0;
}
.panel-close { cursor: pointer; font-size: 22px; color: var(--text-dim); line-height: 1; }
.panel-close:hover { color: var(--red); }

.panel-body { padding: 16px 18px; flex: 1; overflow-y: auto; }

.panel-section { margin-bottom: 16px; }
.panel-section-title { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.panel-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.panel-label { color: var(--text-dim); flex-shrink: 0; margin-right: 12px; }
.panel-actions {
  padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px;
  position: sticky; bottom: 0; background: var(--bg-panel); z-index: 10;
  flex-wrap: wrap;
}

/* ─── Tags ───────────────────────────────── */
.tag {
  display: inline-block; padding: 3px 8px; margin: 2px;
  background: var(--accent-dim); color: var(--accent);
  border-radius: 6px; font-size: 11px; font-weight: 500;
}

/* ─── Anon block ─────────────────────────── */
.anon-block {
  background: #080b12; border: 1px solid var(--border); border-radius: 4px;
  padding: 10px; font-size: 11px; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-all; max-height: 300px; overflow-y: auto;
}

/* ─── Search / toolbar ───────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .tabs { margin-bottom: 0; }
.search-input {
  padding: 8px 14px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-family: inherit; font-size: 13px;
  min-width: 240px; transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ─── Form inputs ────────────────────────── */
.input, select.input, textarea.input {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.input::placeholder { color: var(--text-dim); }

/* ─── Clickable rows ─────────────────────── */
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: var(--accent-dim) !important; }

/* ─── Delete button ──────────────────────── */
.btn-del { background: transparent; color: var(--text-dim); border-color: transparent; padding: 3px 6px; font-size: 13px; line-height: 1; }
.btn-del:hover { color: var(--red); background: #3b1111; }

/* ─── Green button ───────────────────────── */
.btn-green { background: var(--green); color: #fff; border-color: var(--green); }
.btn-green:hover { opacity: 0.85; }

/* ─── Kanban ─────────────────────────────── */
.kanban {
  display: flex; gap: 10px; overflow-x: auto;
  padding-bottom: 8px;
}
.kanban-col {
  flex: 0 0 180px; min-width: 160px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.kanban-col-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.3px;
}
.kanban-count {
  background: var(--accent-dim); color: var(--accent);
  padding: 1px 6px; border-radius: 3px; font-size: 10px;
}
.kanban-col-over { background: var(--bg-hover); border-color: var(--accent); }
.kanban-cards { padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 60px; }
.kanban-card {
  background: var(--bg-hover); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; cursor: grab; transition: box-shadow 0.15s;
}
.kanban-card:hover { box-shadow: var(--shadow); }
.kanban-card:active { cursor: grabbing; opacity: 0.7; }
.kanban-card-title { font-size: 12px; color: var(--text-bright); margin-bottom: 2px; }
.kanban-card-meta { font-size: 11px; color: var(--text-dim); }
.kanban-card-amount { font-size: 12px; color: var(--green); margin-top: 4px; }
.kanban-next { margin-top: 6px; width: 100%; text-align: center; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }

/* Mobile accordion (hidden on desktop) */
.kanban-mobile { display: none; }

.accordion-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 6px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.accordion-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px;
  font-size: 13px; color: var(--text-bright);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.accordion-header:active { background: var(--bg-hover); }
.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0 10px;
}
.accordion-section.open .accordion-body {
  max-height: 2000px;
  padding: 6px 10px 10px;
}
.accordion-section.open .accordion-header {
  border-bottom: 1px solid var(--border);
}

/* ─── Match cards ────────────────────────── */
.match-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 4px; margin-bottom: 6px; cursor: pointer;
}
.match-card:hover { border-color: var(--border-active); background: var(--bg-hover); }
.match-rank { font-size: 14px; color: var(--accent); font-weight: bold; width: 24px; text-align: center; flex-shrink: 0; }
.match-info { flex: 1; }
.match-name { font-size: 13px; color: var(--text-bright); }
.match-meta { font-size: 11px; color: var(--text-dim); }

/* ─── Resume dropzone ────────────────────── */
.resume-dropzone {
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
  transition: border-color 0.2s;
  cursor: pointer;
}
.resume-dropzone:hover { border-color: var(--accent); }

/* ─── Empty state ─────────────────────────── */
.empty { text-align: center; padding: 40px; color: var(--text-dim); }

/* ─── Loading ─────────────────────────────── */
.loading { text-align: center; padding: 20px; color: var(--text-dim); }
.loading::after { content: '...'; animation: dots 1s steps(3) infinite; }
@keyframes dots { 0% { content: '.'; } 33% { content: '..'; } 66% { content: '...'; } }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Global search */
.global-search-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 300;
}
.global-search-box {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  width: 560px; max-width: calc(100vw - 32px);
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); z-index: 301;
  animation: fadeIn 0.15s ease;
  overflow: hidden;
}
.gs-item {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.gs-item:hover { background: var(--bg-hover); }
.gs-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.gs-info { flex: 1; min-width: 0; }
.gs-title { font-size: 13px; color: var(--text-bright); }
.gs-sub { font-size: 11px; color: var(--text-dim); }

/* ─── Funnel ─────────────────────────────── */
.funnel-stage {
  flex: 1; min-width: 80px; text-align: center;
}
.funnel-val {
  font-size: 16px; font-weight: bold; color: var(--text-bright);
  margin-bottom: 4px;
}
.funnel-bar {
  height: 28px; border-radius: 4px;
  margin: 0 auto; min-width: 24px;
  transition: width 0.3s;
}
.funnel-label {
  font-size: 10px; color: var(--text-dim);
  margin-top: 4px; text-transform: uppercase; letter-spacing: 0.3px;
}

/* ─── Sortable headers ───────────────────── */
.sortable-th { cursor: pointer; user-select: none; }
.sortable-th:hover { color: var(--accent); }

/* ─── Nav badges ─────────────────────────── */
.nav-badge {
  display: none;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ─── Burger (mobile) ────────────────────── */
.burger {
  display: none;
  position: fixed; top: 8px; left: 8px; z-index: 200;
  background: var(--bg-panel); color: var(--accent);
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 20px; padding: 4px 10px; cursor: pointer;
}
.mob-search-btn {
  display: none;
  position: fixed; top: 8px; right: 8px; z-index: 200;
  background: var(--bg-panel); color: var(--accent);
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 18px; padding: 4px 10px; cursor: pointer;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 140;
  opacity: 0; transition: opacity 0.25s;
}
.sidebar-overlay.show { display: block; opacity: 1; }

/* ─── Bottom Nav (mobile only) ───────────── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  z-index: 200;
  justify-content: space-around;
  padding: 4px 0;
  padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
}
.bnav-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 8px;
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  min-width: 60px;
}
.bnav-item.active { color: var(--accent); }
.bnav-item:active { opacity: 0.7; }
.bnav-icon { font-size: 20px; line-height: 1; }
.bnav-label { font-size: 10px; margin-top: 2px; }
.bnav-badge {
  display: none;
  position: absolute; top: 2px; right: 6px;
  background: var(--red); color: #fff;
  font-size: 9px; min-width: 16px; height: 16px;
  line-height: 16px; text-align: center;
  border-radius: 8px; padding: 0 4px;
}

/* ─── Tablet (≤1024px) ───────────────────── */
@media (max-width: 1024px) {
  .sidebar { width: 180px; }
  .main { padding: 16px 16px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .kanban-col { flex: 0 0 160px; min-width: 140px; }
  .chart-grid { grid-template-columns: 1fr; }
}

/* ─── Mobile (≤768px) ────────────────────── */
@media (max-width: 768px) {
  .burger { display: block; }
  .mob-search-btn { display: block; }

  .sidebar {
    position: fixed; left: -240px; top: 0; height: 100vh;
    z-index: 150; transition: left 0.25s ease;
    width: 220px;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }
  .sidebar.open { left: 0; }

  .main { padding: 52px 10px 20px; }

  /* Cards: 2 columns */
  .cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card { padding: 10px; }
  .card-value { font-size: 18px; }

  /* Tables: horizontal scroll + compact */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }
  th, td { padding: 6px 8px; font-size: 12px; }

  /* Toolbar: stack vertically */
  .toolbar { flex-direction: column; align-items: stretch; gap: 6px; }
  .toolbar .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .search-input { min-width: 100%; width: 100%; }

  /* Section title */
  .section-title { font-size: 14px; margin-bottom: 12px; }

  /* Bottom nav visible */
  .bottom-nav { display: flex; }
  .main { padding-bottom: 70px !important; }

  /* Kanban: switch to accordion on mobile */
  .kanban-desktop { display: none !important; }
  .kanban-mobile { display: block !important; }

  /* Slide panel: full width */
  .slide-panel { width: 100vw; right: -100vw; }
  .panel-body { padding: 12px 14px; }
  .panel-row { flex-wrap: wrap; gap: 4px; }
  .panel-label { width: 100%; margin-bottom: 2px; }

  /* Charts */
  .chart-grid { grid-template-columns: 1fr; }
  .chart-box { padding: 10px; }
  .chart-box canvas { max-height: 200px; }

  /* Tags: smaller */
  .tag { font-size: 10px; padding: 1px 5px; }

  /* Buttons: touch-friendly */
  .btn { padding: 8px 14px; font-size: 13px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; }

  /* Log viewer */
  .log-viewer { font-size: 11px; max-height: 300px; }

  /* Tabs: scrollable */
  .tabs { gap: 2px; }
  .tab { padding: 6px 10px; font-size: 11px; white-space: nowrap; }
}

/* ─── Small phones (≤480px) ──────────────── */
@media (max-width: 480px) {
  .main { padding: 48px 6px 16px; }

  /* Cards: single column */
  .cards { grid-template-columns: 1fr; }

  /* Kanban: accordion already active from 768px */
  .kanban-card { padding: 12px; }
  .kanban-card-title { font-size: 13px; }
  .kanban-card .btn { min-height: 44px; font-size: 13px; }
  .accordion-header { padding: 14px 12px; font-size: 14px; }

  /* Panel: tighter */
  .panel-header { padding: 10px 12px; font-size: 13px; }
  .panel-body { padding: 10px 12px; }
  .panel-section { margin-bottom: 12px; }

  /* Table: even more compact */
  th, td { padding: 5px 6px; font-size: 11px; }

  /* Sidebar full width */
  .sidebar { width: 100vw; left: -100vw; }
  .sidebar.open { left: 0; }

  /* Burger */
  .burger { top: 6px; left: 6px; font-size: 18px; padding: 3px 8px; }
}

/* ─── Touch improvements ─────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets */
  .nav-item { padding: 12px 16px; }
  .btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .btn-sm { min-height: 34px; }
  .tab { min-height: 36px; display: inline-flex; align-items: center; }
  .clickable-row td { padding: 10px 8px; }

  /* No hover effects on touch */
  .clickable-row:hover td { background: inherit !important; }
  .nav-item:hover { background: inherit; color: inherit; }

  /* Active states instead */
  .clickable-row:active td { background: var(--accent-dim) !important; }
  .nav-item:active { background: var(--bg-hover); color: var(--text); }
  .btn:active { opacity: 0.7; }
}

/* ─── Mobile cards ─────────────────────────── */
.mob-card-list { display: flex; flex-direction: column; gap: 8px; }
.mob-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mob-card:active { background: var(--bg-hover); }
.mob-card-overdue { border-left: 3px solid var(--red); }
.mob-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px; font-size: 14px;
}
.mob-card-age { font-size: 12px; color: var(--text-dim); }
.mob-card-age.overdue { color: var(--red); font-weight: 600; }
.mob-card-body { font-size: 13px; color: var(--text); margin-bottom: 8px; }
.mob-card-body > div { margin-bottom: 2px; }
.mob-card-actions {
  display: flex; gap: 6px; align-items: center;
  padding-top: 8px; border-top: 1px solid var(--border);
}
.mob-card-actions .btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }

/* ─── Swipe card ──────────────────────────── */
.swipe-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  margin-bottom: 8px;
}
.swipe-bg {
  position: absolute; top: 0; bottom: 0;
  display: flex; align-items: center;
  padding: 0 18px;
  font-size: 13px; font-weight: 600;
  color: #fff;
  pointer-events: none;
}
.swipe-bg-right { left: 0; right: 50%; background: var(--green); justify-content: flex-start; }
.swipe-bg-left { right: 0; left: 50%; background: var(--red); justify-content: flex-end; }
.swipe-card {
  position: relative;
  transition: transform 0.2s ease;
  z-index: 1;
  touch-action: pan-y;
}
.swipe-card.swiping { transition: none; }

/* ─── FAB (floating action button) ────────── */
.fab {
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  border: none;
  box-shadow: 0 4px 12px rgba(74,122,255,0.4);
  cursor: pointer;
  z-index: 199;
  display: none;
  align-items: center; justify-content: center;
}
.fab.visible { display: flex; }
.fab:active { transform: scale(0.92); }

/* ─── Modal (replaces confirm/prompt) ────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal-box {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; width: 340px; max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 14px; font-weight: 600; color: var(--text-bright); margin-bottom: 12px; }
.modal-text { font-size: 13px; color: var(--text); margin-bottom: 16px; }
.modal-input { width: 100%; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-actions .btn { min-height: 40px; }

/* ─── Pull to refresh ────────────────────── */
.ptr-indicator {
  display: none;
  text-align: center;
  padding: 12px;
  color: var(--accent);
  font-size: 12px;
  transition: opacity 0.2s;
}
.ptr-indicator.visible { display: block; }
.ptr-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Joiner dashboard ───────────────────── */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.joiner-body:not(.open) { max-height: 0 !important; padding: 0 !important; overflow: hidden; }

/* ─── Safe areas (iPhone notch) ──────────── */
@supports (padding-top: env(safe-area-inset-top)) {
  .sidebar { padding-top: env(safe-area-inset-top); }
  .burger { top: calc(8px + env(safe-area-inset-top)); }
  .mob-search-btn { top: calc(8px + env(safe-area-inset-top)); }
  .main { padding-top: calc(52px + env(safe-area-inset-top)); }
  .slide-panel { padding-top: env(safe-area-inset-top); }
}
