/* GIA CRM — main.css | Version: v1.0.0 */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --sidebar-w: 240px;
  --topbar-h: 56px;

  --bg: #0f1117;
  --bg-2: #161b26;
  --surface: #1e2433;
  --surface-2: #252d3e;
  --border: rgba(255,255,255,0.07);
  --border-2: rgba(255,255,255,0.12);

  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --accent: #6366f1;
  --accent-hover: #4f52d9;
  --accent-soft: rgba(99,102,241,0.15);

  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --font: 'Inter', system-ui, sans-serif;
  --transition: 0.18s ease;
}

[data-bs-theme="light"] {
  --bg: #f1f5f9;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: rgba(0,0,0,0.08);
  --border-2: rgba(0,0,0,0.13);
  --text: #1e293b;
  --text-muted: #64748b;
  --text-dim: #475569;
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 22px; flex-shrink: 0; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.brand-logo { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; border-radius: 4px; }

/* Logo upload zone */
.logo-upload-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}
.logo-upload-zone:hover, .logo-upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.logo-upload-zone input[type=file] { display:none; }
.logo-preview-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.logo-preview-img { height: 48px; object-fit: contain; max-width: 160px; }
.logo-preview-formats { display: flex; gap: 8px; flex-wrap: wrap; }
.logo-fmt {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.logo-fmt img { height: 20px; object-fit: contain; }

/* Currency table */
.currency-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.currency-row:last-child { border-bottom: none; }
.currency-code {
  font-weight: 700;
  font-size: 15px;
  min-width: 48px;
  color: var(--accent);
}
.currency-name { flex: 1; color: var(--text-dim); font-size: 13px; }
.currency-rate {
  font-weight: 600;
  font-size: 15px;
  min-width: 90px;
  text-align: right;
}
.currency-rate-date { font-size: 11px; color: var(--text-muted); min-width: 70px; text-align: right; }
.rate-fresh { color: var(--success); }
.rate-stale { color: var(--warning); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  list-style: none;
}

.sidebar-nav .nav-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.sidebar-nav .nav-item a:hover { background: var(--surface); color: var(--text); }
.sidebar-nav .nav-item.active a { background: var(--accent-soft); color: var(--accent); }
.sidebar-nav .nav-item a i { font-size: 15px; width: 18px; text-align: center; }

.nav-divider { height: 1px; background: var(--border); margin: 8px 10px; }

.badge-notif {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  border-radius: 20px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }
.sidebar-actions { display: flex; gap: 6px; }

/* ── Main wrap ─────────────────────────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.sidebar-toggle { display: none; }
.topbar-title { flex: 1; font-size: 14px; color: var(--text-muted); }
.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: 50%;
}

/* ── Content ───────────────────────────────────────────────────────────────── */
.content { flex: 1; padding: 24px; max-width: 1400px; width: 100%; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border-2); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }
.w-100 { width: 100%; }
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  font-size: 16px;
}
.btn-icon:hover { background: var(--surface); color: var(--text); }
.btn-icon.active { color: var(--accent); }
.btn-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.btn-back:hover { background: var(--surface-2); color: var(--text); }
.btn-link { background: none; border: none; cursor: pointer; color: var(--accent); font-size: 13px; display: flex; align-items: center; gap: 4px; }
.btn-link:hover { color: var(--accent-hover); }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-control, .form-select {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 13.5px;
  width: 100%;
  transition: border var(--transition), box-shadow var(--transition);
  font-family: var(--font);
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-dim); margin-bottom: 6px; display: block; }
.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-group { margin-bottom: 18px; }
.form-section { padding: 20px 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.form-section:last-child { border-bottom: none; }
.form-section-title { font-size: 13px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 16px; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 20px; }
.input-icon-wrap { position: relative; }
.input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.input-icon-wrap .form-control { padding-left: 38px; }
.input-icon-right { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }

/* ── Cards & Panels ────────────────────────────────────────────────────────── */
.card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  font-weight: 600;
}
.panel-body { padding: 16px 18px; }

/* ── Page header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.page-actions { display: flex; align-items: center; gap: 10px; }

/* ── Filter bar ────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-search { max-width: 280px; }
.filter-select { max-width: 180px; }

/* ── KPI Grid ──────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color var(--transition);
}
.kpi-card:hover { border-color: var(--border-2); }
.kpi-card.loading { opacity: 0.5; }
.kpi-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.kpi-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-crm {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table-crm thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-crm tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-crm tbody tr:last-child td { border-bottom: none; }
.table-crm tbody tr.tr-clickable { cursor: pointer; transition: background var(--transition); }
.table-crm tbody tr.tr-clickable:hover { background: var(--surface-2); }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.bg-primary { background: rgba(99,102,241,0.15); color: #818cf8; }
.bg-success { background: rgba(34,197,94,0.15); color: #4ade80; }
.bg-danger  { background: rgba(239,68,68,0.15); color: #f87171; }
.bg-warning { background: rgba(245,158,11,0.15); color: #fbbf24; }
.bg-info    { background: rgba(6,182,212,0.15); color: #22d3ee; }
.bg-secondary { background: rgba(100,116,139,0.15); color: #94a3b8; }

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination-bar { padding: 12px 16px; }
.pagination { display: flex; gap: 4px; }
.page-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition);
}
.page-btn:hover { background: var(--surface-2); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Detail grid ───────────────────────────────────────────────────────────── */
.detail-grid { display: grid; gap: 14px; }
.detail-row { display: flex; gap: 12px; align-items: baseline; }
.detail-label { font-size: 12px; color: var(--text-muted); width: 120px; flex-shrink: 0; }
.detail-value { font-size: 13.5px; }
.notes-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* ── Finance ───────────────────────────────────────────────────────────────── */
.finance-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.finance-item {}
.finance-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.finance-value { font-size: 18px; font-weight: 700; }
.progress-bar-wrap { display: flex; align-items: center; gap: 10px; }
.progress-bar-track { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--success); border-radius: 3px; transition: width 0.5s ease; }
.progress-label { font-size: 12px; font-weight: 600; color: var(--text-muted); width: 35px; }

/* ── Kanban ────────────────────────────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
}
.kanban-col {
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-shrink: 0;
}
.kanban-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kanban-count {
  background: var(--surface-2);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.kanban-cards { padding: 10px; min-height: 60px; }
.kanban-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.kanban-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.kc-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.kc-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.kc-footer { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
.kanban-empty { font-size: 12px; color: var(--text-muted); text-align: center; padding: 16px 0; }

/* ── Tours grid ────────────────────────────────────────────────────────────── */
.tours-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.tour-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
}
.tour-card:hover { border-color: var(--border-2); transform: translateY(-2px); box-shadow: var(--shadow); }
.tour-cover {
  height: 150px;
  background: var(--surface-2);
  background-size: cover;
  background-position: center;
  position: relative;
}
.tour-badge { position: absolute; top: 10px; right: 10px; }
.tour-body { padding: 14px; }
.tour-country { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.tour-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.tour-meta { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-muted); }

/* ── Countries grid ────────────────────────────────────────────────────────── */
.countries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.country-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
}
.country-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.country-cover {
  height: 130px;
  background: var(--surface-2);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  padding: 10px;
}
.country-code {
  background: rgba(0,0,0,0.5);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.country-body { padding: 14px; }
.country-name { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.country-meta { font-size: 12px; margin-bottom: 8px; }
.visa-badge { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; }
.visa-free { color: var(--success); }

/* ── Campaigns ─────────────────────────────────────────────────────────────── */
.campaigns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.campaign-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: all var(--transition);
}
.campaign-card:hover { border-color: var(--border-2); }
.campaign-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.campaign-channel { font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center; }
.campaign-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.campaign-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.cstat-v { font-size: 16px; font-weight: 700; }
.cstat-l { font-size: 11px; color: var(--text-muted); }
.cpl-badge { font-size: 12px; color: var(--text-muted); }

/* ── Tour/Package ───────────────────────────────────────────────────────────── */
.package-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.package-row:last-child { border-bottom: none; }
.package-date { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.package-meta { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }

/* ── Tourist/Doc rows ───────────────────────────────────────────────────────── */
.tourist-row, .doc-row, .transfer-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.tourist-row:last-child, .doc-row:last-child, .transfer-row:last-child { border-bottom: none; }

/* ── Notifications panel ────────────────────────────────────────────────────── */
.notif-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 16px;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  max-height: 400px;
  overflow-y: auto;
}
.notif-header { padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--border); }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-title { font-size: 13px; font-weight: 600; }
.notif-msg { font-size: 12.5px; color: var(--text-muted); }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.notif-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ── AI Panel ──────────────────────────────────────────────────────────────── */
.ai-panel {
  position: fixed;
  right: -420px;
  top: var(--topbar-h);
  bottom: 0;
  width: 420px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 150;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
  box-shadow: var(--shadow);
}
.ai-panel.show { right: 0; }
.ai-panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}
.ai-tabs {
  display: flex;
  padding: 10px 14px;
  gap: 6px;
  border-bottom: 1px solid var(--border);
}
.ai-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  transition: all var(--transition);
}
.ai-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.ai-chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ai-welcome { color: var(--text-muted); text-align: center; font-size: 13.5px; padding: 30px 20px; }
.ai-msg { display: flex; }
.ai-msg.user { justify-content: flex-end; }
.ai-msg.bot { justify-content: flex-start; }
.ai-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.6;
}
.ai-msg.user .ai-bubble { background: var(--accent); color: #fff; border-radius: 12px 12px 2px 12px; }
.ai-msg.bot .ai-bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: 2px 12px 12px 12px; }
.ai-meta { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.ai-input-wrap {
  padding: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.ai-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: var(--font);
  resize: none;
  transition: border var(--transition);
}
.ai-input:focus { outline: none; border-color: var(--accent); }

/* AI Assistants page */
.ai-assistant-cards { display: flex; flex-direction: column; gap: 10px; }
.ai-assistant-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.ai-assistant-card:hover { border-color: var(--border-2); background: var(--surface-2); }
.ai-assistant-card.active { border-color: var(--accent); background: var(--accent-soft); }
.ai-asst-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.ai-asst-name { font-weight: 600; font-size: 13.5px; }
.ai-asst-desc { font-size: 12px; color: var(--text-muted); }
.quick-q {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 12.5px;
  cursor: pointer;
  margin-bottom: 6px;
  transition: all var(--transition);
  color: var(--text-dim);
}
.quick-q:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

/* ── Settings ──────────────────────────────────────────────────────────────── */
.settings-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.stab {
  padding: 10px 18px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: -1px;
}
.stab:hover { color: var(--text); background: var(--surface-2); }
.stab.active { background: var(--surface); color: var(--text); border-color: var(--border); }
.bot-config-grid { display: flex; flex-direction: column; gap: 0; }
.bot-cfg-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.bot-cfg-row:last-child { border-bottom: none; }
.bot-cfg-role { width: 140px; font-size: 13px; font-weight: 500; }
.bot-cfg-module { flex: 1; font-size: 13px; color: var(--text-muted); }
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
  border-radius: 22px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); background: #fff; }

/* ── Modals ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-lg { max-width: 680px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 600;
}
.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 14px;
}
.alert-danger { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }

/* ── Client suggestions ────────────────────────────────────────────────────── */
.client-suggestions {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  z-index: 100;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: var(--shadow);
  display: none;
}
.suggestion-item {
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 13.5px;
}
.suggestion-item:hover { background: var(--surface-2); }
.suggestion-item.new-client { color: var(--accent); border-top: 1px solid var(--border); }

/* ── View toggle ───────────────────────────────────────────────────────────── */
.view-toggle {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.view-toggle .btn-icon {
  border-radius: 0;
  padding: 8px 12px;
}
.view-toggle .btn-icon.active { background: var(--accent-soft); color: var(--accent); }

/* ── Loading states ────────────────────────────────────────────────────────── */
.loading-center {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.loading-row {
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.empty-state {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ── Dropdown ──────────────────────────────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown-toggle { cursor: pointer; }
.dropdown-toggle::after { content: '▾'; margin-left: 6px; font-size: 10px; }
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-width: 180px;
  z-index: 100;
  box-shadow: var(--shadow);
  display: none;
}
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--surface-2); }

/* ── Utilities ─────────────────────────────────────────────────────────────── */
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-muted   { color: var(--text-muted) !important; }
.small { font-size: 12px; }
.me-1 { margin-right: 4px; }
.me-2 { margin-right: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 18px; }
.mb-4 { margin-bottom: 18px; }
.p-0 { padding: 0; }
.p-3 { padding: 12px; }
.p-4 { padding: 18px; }
.d-flex { display: flex; }
.d-block { display: block; }
.align-items-center { align-items: center; }
.justify-content-center { justify-content: center; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 18px; }
.flex-grow-1 { flex-grow: 1; }
.flex-column { flex-direction: column; }
.h-100 { height: 100%; }
.w-100 { width: 100%; }
.mb-0 { margin-bottom: 0; }
.fs-2 { font-size: 1.5rem; }
.fs-3 { font-size: 1.25rem; }
.fs-6 { font-size: 12px; }
.position-relative { position: relative; }

/* ── Spin animation ────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; display: inline-block; }

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-wrap { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-icon { font-size: 40px; display: block; margin-bottom: 10px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 14px; }

/* ── Row / Col grid (Bootstrap-lite) ────────────────────────────────────────── */
.row { display: flex; flex-wrap: wrap; margin: -8px; }
.row.g-4 { margin: -10px; }
.row.g-4 > * { padding: 10px; }
[class^="col-"] { padding: 8px; }
.col-12 { width: 100%; }
.col-md-3 { width: 25%; }
.col-md-4 { width: 33.333%; }
.col-md-6 { width: 50%; }
.col-md-8 { width: 66.666%; }
@media (max-width: 768px) {
  .col-md-3,.col-md-4,.col-md-6,.col-md-8 { width: 100%; }
}
.col-lg-4 { width: 33.333%; }
.col-lg-7 { width: 58.333%; }
.col-lg-8 { width: 66.666%; }
.col-xl-5 { width: 41.666%; }
.col-xl-7 { width: 58.333%; }
@media (max-width: 992px) {
  .col-lg-4,.col-lg-7,.col-lg-8,.col-xl-5,.col-xl-7 { width: 100%; }
}
.justify-content-center { justify-content: center; }

/* ── Voice Input ────────────────────────────────────────────────────────────── */
.btn-voice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
  font-size: 15px;
}
.btn-voice:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.btn-voice.voice-recording {
  background: rgba(239,68,68,0.15);
  color: #f87171;
  border-color: #ef4444;
  animation: voice-pulse 1.2s ease-in-out infinite;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

.voice-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}
.voice-field-wrap .form-control,
.voice-field-wrap textarea {
  flex: 1;
}

/* Поле ввода в состоянии записи */
.voice-active {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.12) !important;
}

/* Кнопка голоса в AI-панели — встроена в ai-input-wrap */
.ai-input-wrap .btn-voice {
  width: 40px;
  height: 40px;
  font-size: 16px;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrap { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .sidebar-overlay.open { display: block; }
  .content { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .filter-search { max-width: 100%; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .ai-panel { width: 100%; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ── Smart Application v2 ──────────────────────────────────────────────────── */

/* Mode toggle */
.mode-toggle { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: var(--radius-sm); }
.mode-btn { padding: 6px 14px; border-radius: 4px; border: none; background: transparent; color: var(--text-muted); font-size: 13px; cursor: pointer; transition: var(--transition); }
.mode-btn.active { background: var(--accent); color: #fff; }

/* Voice textarea */
.voice-textarea { min-height: 120px; resize: vertical; }

/* Tourist form rows */
.tourist-form-row { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 4px; }
.tourist-header { display: flex; justify-content: space-between; align-items: center; }
.tourist-num { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.tourist-card { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px; }
.form-label-sm { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 3px; }
.input-warn { border-color: var(--warning) !important; }
.warn-banner { background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.3); border-radius: 4px; padding: 5px 10px; font-size: 12px; color: var(--warning); }

/* Input with suggestions */
.input-with-suggest { position: relative; }
.suggestion-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm); z-index: 100; display: none; max-height: 200px; overflow-y: auto; }
.sug-item { padding: 9px 12px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--border); }
.sug-item:last-child { border-bottom: none; }
.sug-item:hover { background: var(--accent-soft); }
.sug-new { color: var(--accent); }

/* Mini table for payments */
.mini-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.mini-table th { font-size: 11px; text-transform: uppercase; color: var(--text-muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.mini-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.mini-table tr:last-child td { border-bottom: none; }

/* Event log */
.event-log { display: flex; flex-direction: column; gap: 0; }
.event-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.event-row:last-child { border-bottom: none; }
.event-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; background: var(--text-muted); }
.event-dot.event-created { background: var(--success); }
.event-dot.event-status_changed { background: var(--accent); }
.event-dot.event-payment { background: var(--info); }
.event-dot.event-tourist_added { background: var(--warning); }
.event-dot.event-comment { background: var(--text-muted); }
.event-body { flex: 1; }
.event-title { font-size: 13px; font-weight: 500; }
.event-sub { margin-top: 2px; }
.event-meta { margin-top: 2px; }

/* Modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 1000; align-items: center; justify-content: center; }
.modal.show { display: flex; }
.modal-dialog { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 500px; margin: 20px; box-shadow: var(--shadow); max-height: 90vh; display: flex; flex-direction: column; }
.modal-dialog.modal-sm { max-width: 380px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-content { display: flex; flex-direction: column; width: 100%; }
.btn-icon-sm { background: none; border: none; padding: 3px 6px; cursor: pointer; color: var(--text-muted); border-radius: 4px; }
.btn-icon-sm:hover { background: var(--surface-2); color: var(--text); }
