/* ============================================================
   FlowTrack Pro — SaaS Platform Styles
   Mobile-first responsive design
   ============================================================ */

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

:root {
  /* Brand colors — from logo */
  --navy: #1B2D4F;
  --navy-dark: #132038;
  --navy-light: #f0f4f8;
  --navy-border: #c7d2e0;
  --accent: #2AABE0;
  --accent-dark: #1E8FBF;
  --accent-light: #e8f7fc;
  --accent-border: #a3ddf2;
  /* Keep green/red/amber for status indicators */
  --green: #16a34a;
  --green-dark: #15803d;
  --green-light: #f0fdf4;
  --green-border: #bbf7d0;
  --red: #dc2626;
  --red-light: #fef2f2;
  --red-border: #fecaca;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --amber-border: #fde68a;
  --blue: #2AABE0;
  --blue-light: #e8f7fc;
  --text: #1a1f2e;
  --text-secondary: #5a6478;
  --text-hint: #8d95a5;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e2e6ed;
  --border-strong: #cbd1dc;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(27,45,79,0.06);
  --shadow: 0 2px 8px rgba(27,45,79,0.08), 0 1px 2px rgba(27,45,79,0.04);
  --shadow-lg: 0 12px 28px rgba(27,45,79,0.12), 0 4px 8px rgba(27,45,79,0.06);
  --sidebar-w: 250px;
  --transition: 150ms ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- AUTH ---- */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  background: linear-gradient(145deg, var(--navy) 0%, #243a5e 50%, var(--navy-dark) 100%);
}
.auth-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  border: none;
}
.auth-logo { display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.auth-logo-icon { display: none; }
.auth-logo-icon svg { display: none; }
.auth-logo img { height: 80px; }
.auth-logo h1 { display: none; }
.auth-subtitle { color: var(--text-secondary); font-size: 14px; margin-bottom: 1.75rem; text-align: center; }
.auth-error {
  background: var(--red-light); color: var(--red); border: 1px solid var(--red-border);
  border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 1rem;
}
.auth-switch { text-align: center; font-size: 13px; color: var(--text-secondary); margin-top: 1.25rem; }
.auth-switch a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.auth-trial-note { text-align: center; font-size: 12px; color: var(--text-hint); margin-top: 8px; }

/* ---- SIDEBAR ---- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  border-right: none;
  display: flex; flex-direction: column;
  z-index: 60;
  transition: transform 0.25s ease;
}
.sidebar-header { padding: 16px 16px 14px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-icon { display: none; }
.brand-icon svg { display: none; }
.brand-logo { height: 40px; }
.brand-name { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: -0.3px; }

.sidebar-nav { flex: 1; padding: 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  color: rgba(255,255,255,0.6); text-decoration: none;
  font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all var(--transition);
  margin-bottom: 2px;
}
.nav-item[hidden] { display: none; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 8px 12px; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user { display: flex; align-items: center; justify-content: space-between; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,0.5); text-transform: capitalize; }
.sidebar-logout-btn {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500;
  color: #fff; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px; padding: 6px 12px; cursor: pointer; transition: all 0.15s;
  white-space: nowrap;
}
.sidebar-logout-btn:hover { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.35); }

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 55; backdrop-filter: blur(2px);
}

/* ---- MOBILE HEADER ---- */
.mobile-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--navy); border-bottom: none;
  padding: 0 16px; height: 56px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.mobile-menu-btn {
  background: none; border: none; cursor: pointer;
  padding: 4px; color: #fff;
}
.mobile-menu-btn svg { stroke: #fff; }
.mobile-header-title { font-weight: 700; font-size: 16px; flex: 1; color: #fff; }
.mobile-header-logo { height: 28px; margin-right: 4px; }

.show-mobile { display: none; }

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 24px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .show-mobile { display: flex; }
  .main-content { margin-left: 0; padding: 12px; padding-top: 68px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; justify-content: center; font-size: 14px; padding: 12px 8px; min-height: 44px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-tabs { overflow-x: auto; flex-shrink: 0; }
  .tab-btn { padding: 10px 16px; font-size: 14px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .form-group input, .form-group select, .form-group textarea { padding: 12px; font-size: 16px; min-height: 48px; }
  .form-group label { font-size: 14px; margin-bottom: 6px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 12px 14px; }
  .metric-value { font-size: 22px; }
  .settings-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .modal { padding: 1.25rem; margin: 0.5rem; }
  td, th { padding: 10px 12px; }
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-xs { min-height: 36px; padding: 6px 12px; font-size: 13px; }
  .btn-sm { min-height: 40px; padding: 8px 14px; font-size: 14px; }
  .actions { gap: 6px; }
  .badge { padding: 4px 12px; font-size: 13px; }
  .toast-container { left: 1rem; right: 1rem; bottom: 16px; }
  .toast { text-align: center; max-width: none; font-size: 15px; padding: 14px 20px; }
  .cmd-palette { max-width: calc(100vw - 2rem); }
  .cmd-backdrop { padding-top: 60px; }
  .hide-mobile, .hide-sm { display: none !important; }
}

@media (max-width: 480px) {
  .auth-card { padding: 1.5rem; }
  .metrics { gap: 8px; }
}

/* ---- LAYOUT ---- */
.page { display: none; }
.page.active { display: block; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 12px;
}
.page-header h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- CARDS ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- METRICS ---- */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 1.5rem; }
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 20px; box-shadow: var(--shadow-sm);
}
.metric.skeleton { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.metric-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.metric-value { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.metric-value.red { color: var(--red); }
.metric-value.amber { color: var(--amber); }
.metric-value.green { color: var(--green); }
.metric-sub { font-size: 12px; color: var(--text-hint); margin-top: 2px; }
.metric[style*="cursor:pointer"]:hover { border-color: var(--accent); box-shadow: var(--shadow); }

/* ---- ALERTS ---- */
.alert {
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px;
  font-size: 13px; display: flex; align-items: flex-start; gap: 10px; line-height: 1.5;
}
.alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-red { background: var(--red-light); color: var(--alert-red-text, #991b1b); border: 1px solid var(--red-border); }
.alert-amber { background: var(--amber-light); color: var(--alert-amber-text, #92400e); border: 1px solid var(--amber-border); }

/* ---- TOOLBAR ---- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar-tabs {
  display: flex; gap: 2px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 3px;
}
.tab-btn {
  padding: 6px 14px; border-radius: 6px; border: none; background: none;
  font-size: 13px; font-family: inherit; cursor: pointer;
  color: var(--text-secondary); white-space: nowrap;
  transition: all var(--transition); font-weight: 500;
}
.tab-btn.active { background: var(--accent); color: #fff; }
.tab-btn:hover:not(.active) { background: var(--bg); }
.search-wrap { flex: 1; min-width: 180px; position: relative; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-hint); }
.search-wrap input {
  width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--text);
}
.search-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(42,171,224,0.15); }

/* ---- BUTTONS ---- */
.btn {
  padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit;
  cursor: pointer; transition: all var(--transition); font-weight: 500; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; line-height: 1.4;
}
.btn:hover { background: var(--bg); border-color: var(--border-strong); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; }
.btn-danger { color: var(--red); border-color: var(--red-border); }
.btn-danger:hover { background: var(--red-light); }
.btn-full { width: 100%; justify-content: center; padding: 10px 16px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---- TABLES ---- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg); }
th {
  padding: 10px 16px; font-size: 12px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em; text-align: left;
  border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none;
}
th:hover { color: var(--text); }
th .sort-icon { font-size: 10px; margin-left: 3px; opacity: 0.4; }
th.sorted .sort-icon { opacity: 1; color: var(--accent); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }
.cell-primary { font-weight: 600; font-size: 14px; }
.cell-secondary { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.mono { font-family: 'SF Mono','Consolas', monospace; font-size: 12px; color: var(--text-secondary); }
.actions { display: flex; gap: 4px; flex-wrap: nowrap; }
td.actions-cell { padding: 8px 16px; white-space: nowrap; }

/* ---- BADGES ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-red { background: var(--red-light); color: var(--badge-red-text, #991b1b); }
.badge-amber { background: var(--amber-light); color: var(--badge-amber-text, #92400e); }
.badge-green { background: var(--green-light); color: var(--badge-green-text, #166534); }
.badge-blue { background: var(--blue-light); color: var(--badge-blue-text, #1e40af); }
.badge-gray { background: var(--badge-gray-bg, #f3f4f6); color: var(--badge-gray-text, #4b5563); }

/* ---- ACTIVITY FEED ---- */
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.activity-dot.pass { background: var(--green); }
.activity-dot.fail { background: var(--red); }
.activity-dot.inconclusive { background: var(--amber); }
.activity-info { flex: 1; }
.activity-title { font-weight: 500; font-size: 14px; }
.activity-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ---- REVENUE CARD ---- */
.revenue-stat { margin-bottom: 16px; }
.revenue-label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.revenue-value { font-size: 24px; font-weight: 700; color: var(--green); }

/* ---- EMPTY / LOADING ---- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-secondary); }
.empty h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.empty p { font-size: 13px; }
.loading { text-align: center; padding: 3rem; color: var(--text-secondary); font-size: 13px; }
.spinner {
  width: 24px; height: 24px; border: 2.5px solid var(--border);
  border-top-color: var(--green); border-radius: 50%;
  animation: spin 0.6s linear infinite; margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- MODALS ---- */
/* Base z-index is 200; App.openModal bumps inline style.zIndex by +10 per stacked
   modal (see App._modalStack in public/js/app.js). photo-lightbox uses static
   z-index:1100 inline as an escape hatch and bypasses the stack. */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem; backdrop-filter: blur(2px);
}
.modal-overlay.visible {
  display: flex;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); padding: 1.5rem;
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modalIn 0.2s ease;
}
.modal.wide { max-width: 680px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px; border: none; background: none;
  cursor: pointer; color: var(--text-secondary); font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ---- FORMS ---- */
.form-section { margin-bottom: 1.25rem; }
.form-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-secondary); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text);
  transition: border-color var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(42,171,224,0.15);
}
.form-group textarea { resize: vertical; min-height: 60px; }
.readonly-input { background: var(--bg) !important; cursor: default; }

/* ---- SETTINGS ---- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.email-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 10px 4px 12px; font-size: 13px; margin: 3px;
}
.email-tag button { background: none; border: none; cursor: pointer; color: var(--text-hint); font-size: 16px; padding: 0; }
.email-tag button:hover { color: var(--red); }
.email-add-row { display: flex; gap: 8px; margin-top: 8px; }
.email-add-row input { flex: 1; }
.user-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.user-item:last-child { border-bottom: none; }
.user-name { font-weight: 500; font-size: 14px; }
.user-email { font-size: 12px; color: var(--text-secondary); }

/* ---- IMPORT ---- */
.import-drop-zone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem; text-align: center; cursor: pointer;
  transition: all 0.2s; background: var(--bg);
}
.import-drop-zone:hover { border-color: var(--green); }
.import-drop-zone.dragover { border-color: var(--green); background: var(--green-light); }
.import-drop-zone svg { width: 36px; height: 36px; color: var(--text-hint); margin-bottom: 8px; }
.import-drop-zone p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.import-drop-zone strong { color: var(--text); }
.import-preview-table { width: 100%; font-size: 13px; margin-top: 12px; }
.import-preview-table td { padding: 4px 8px; vertical-align: top; }
.import-preview-table td:first-child { font-weight: 500; color: var(--text-secondary); white-space: nowrap; width: 140px; }

/* ---- HISTORY ---- */
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table th { padding: 8px 12px; font-size: 11px; text-align: left; background: var(--bg); cursor: default; }
.history-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }

/* ---- TOAST (enhanced with undo) ---- */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  display: flex; flex-direction: column-reverse; gap: 8px;
}
.toast {
  background: var(--text); color: #fff; padding: 12px 20px;
  border-radius: var(--radius); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: toastIn 0.25s ease;
  display: flex; align-items: center; gap: 12px; max-width: 400px;
  position: relative; overflow: hidden;
}
.toast.success { background: var(--accent); }
.toast.error { background: var(--red); }
.toast.info { background: var(--blue); }
.toast-msg { flex: 1; }
.toast-undo {
  background: rgba(255,255,255,0.25); border: none; color: #fff;
  padding: 3px 10px; border-radius: 4px; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap; font-family: inherit;
}
.toast-undo:hover { background: rgba(255,255,255,0.4); }
.toast-progress {
  position: absolute; bottom: 0; left: 0; height: 3px;
  background: rgba(255,255,255,0.4); animation: toastProgress linear forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(8px); } }
@keyframes toastProgress { from { width: 100%; } to { width: 0%; } }

/* ---- GLOBAL SEARCH (Command Palette) ---- */
.cmd-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 250; backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center;
  padding-top: min(20vh, 160px);
}
.cmd-backdrop.visible { display: flex; }
.cmd-palette {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 580px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); overflow: hidden;
  animation: modalIn 0.15s ease;
}
.cmd-input-wrap {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.cmd-input-wrap svg { width: 20px; height: 20px; color: var(--text-hint); flex-shrink: 0; }
.cmd-input {
  flex: 1; border: none; outline: none; font-size: 16px;
  font-family: inherit; background: none; color: var(--text);
}
.cmd-input::placeholder { color: var(--text-hint); }
.cmd-kbd { font-size: 11px; color: var(--text-hint); background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; font-family: inherit; }
.cmd-results { max-height: 360px; overflow-y: auto; }
.cmd-group-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-hint); padding: 10px 16px 4px; }
.cmd-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  cursor: pointer; transition: background 80ms;
}
.cmd-item:hover, .cmd-item.active { background: var(--accent-light); }
.cmd-item.active { border-left: 3px solid var(--accent); }
.cmd-item-icon { width: 32px; height: 32px; border-radius: 8px; background: var(--bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; }
.cmd-item-text { flex: 1; min-width: 0; }
.cmd-item-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd-item-sub { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd-item-badge { font-size: 11px; color: var(--text-hint); background: var(--bg); border-radius: 4px; padding: 2px 8px; flex-shrink: 0; }
.cmd-empty { padding: 24px; text-align: center; color: var(--text-hint); font-size: 14px; }
.cmd-footer { padding: 8px 16px; border-top: 1px solid var(--border); display: flex; gap: 16px; justify-content: center; }
.cmd-footer span { font-size: 11px; color: var(--text-hint); display: flex; align-items: center; gap: 4px; }
.cmd-footer kbd { font-size: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-family: inherit; }

/* ---- FLOATING ACTION BUTTON (mobile) ---- */
/* ---- PAGE TRANSITIONS ---- */
.page { animation: pageIn 0.2s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---- INLINE EDITING ---- */
.inline-edit {
  padding: 4px 8px; border: 2px solid var(--accent); border-radius: 4px;
  font-size: 14px; font-family: inherit; background: var(--surface);
  color: var(--text); outline: none; width: 100%; min-width: 60px;
}
td.editing { padding: 6px 10px; background: var(--accent-light) !important; }

/* ---- FIELD MAPPING ---- */
.field-map-row {
  display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 8px;
  align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.field-map-row:last-child { border-bottom: none; }
.field-map-label { font-weight: 500; font-size: 12px; }
.field-map-arrow { color: var(--text-hint); }
.field-map-row select { padding: 4px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: 4px; font-family: inherit; }
.form-status-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; }

/* ---- DRAG-AND-DROP CALENDAR ---- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
@media (max-width: 768px) { .cal-grid { grid-template-columns: repeat(2, 1fr); } }
.cal-cell { background: var(--surface); min-height: 100px; padding: 6px; transition: background 0.15s; }
.cal-cell.cal-today { background: var(--blue-light); }
.cal-cell.cal-drag-over { background: var(--accent-light); outline: 2px dashed var(--accent); outline-offset: -2px; }
.cal-cell-header { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.cal-dow { font-size: 11px; font-weight: 500; color: var(--text-hint); text-transform: uppercase; }
.cal-day { font-size: 13px; font-weight: 600; }
.cal-day-today { background: var(--accent); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.cal-jobs { display: flex; flex-direction: column; gap: 3px; }
.cal-job { padding: 4px 6px; border-radius: 4px; cursor: grab; font-size: 12px; border-left: 3px solid; transition: box-shadow 0.15s; }
.cal-job:hover { box-shadow: var(--shadow); }
.cal-job:active { cursor: grabbing; }
.cal-job-blue { background: var(--blue-light); border-color: var(--accent); }
.cal-job-green { background: var(--green-light); border-color: var(--green); }
.cal-job-red { background: var(--red-light); border-color: var(--red); }
.cal-job-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-job-info { color: var(--text-hint); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- DEVICE TIMELINE ---- */
.device-timeline { position: relative; padding-left: 20px; }
.device-timeline::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -20px; top: 2px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--surface); z-index: 1; }
.tl-dot-green { background: var(--green); }
.tl-dot-red { background: var(--red); }
.tl-dot-amber { background: var(--amber); }
.tl-dot-blue { background: var(--accent); }
.tl-body { padding-left: 4px; }
.tl-header { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl-date { font-size: 12px; color: var(--text-hint); }
.tl-detail { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ---- KEYBOARD SHORTCUT HINTS ---- */
.kbd-hint {
  font-size: 10px; color: var(--text-hint); background: var(--bg);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 1px 5px; font-family: inherit; margin-left: 6px; vertical-align: middle;
}

/* ---- INK SIGNATURE WARNING ---- */
.ink-warning {
  background: var(--amber-light); border: 1px solid var(--amber-border);
  border-radius: var(--radius); padding: 8px 12px; font-size: 12px;
  color: #92400e; display: flex; align-items: center; gap: 6px; margin-top: 4px;
}

/* ---- MAP VIEW ---- */
.map-controls {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.map-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.toggle-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.toggle-label input[type="checkbox"] { accent-color: var(--accent); }
.map-popup { font-family: 'Inter', sans-serif; line-height: 1.4; }
.map-popup strong { font-size: 14px; }
.mapboxgl-popup-content { border-radius: 8px !important; padding: 12px !important; box-shadow: 0 4px 12px rgba(0,0,0,.15) !important; }

/* ---- TOGGLE SWITCH ---- */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border-strong); border-radius: 24px; transition: 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute; height: 18px; width: 18px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ---- DARK MODE ---- */
[data-theme="dark"] {
  --navy: #0d1520;
  --navy-dark: #080e18;
  --navy-light: #1a2332;
  --navy-border: #2a3545;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-hint: #64748b;
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --border-strong: #475569;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 2px 8px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg: 0 12px 28px rgba(0,0,0,0.4), 0 4px 8px rgba(0,0,0,0.2);
  --green-light: #052e16;
  --green-border: #166534;
  --red-light: #450a0a;
  --red-border: #991b1b;
  --amber-light: #451a03;
  --amber-border: #92400e;
  --blue-light: #0c2d48;
  --accent-light: #0c2d48;
  --accent-border: #1e5a7a;
  --badge-red-text: #fca5a5;
  --badge-amber-text: #fcd34d;
  --badge-green-text: #86efac;
  --badge-blue-text: #93c5fd;
  --badge-gray-bg: var(--surface);
  --badge-gray-text: var(--text-secondary);
  --alert-red-text: #fca5a5;
  --alert-amber-text: #fcd34d;
}
[data-theme="dark"] .sidebar { background: #080e18; }
[data-theme="dark"] .auth-screen { background: linear-gradient(145deg, #080e18 0%, #0f172a 50%, #0d1520 100%); }
[data-theme="dark"] .auth-card { background: var(--surface); box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
[data-theme="dark"] .toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
[data-theme="dark"] .toast.success { background: var(--accent); color: #fff; border: none; }
[data-theme="dark"] .toast.error { background: var(--red); color: #fff; border: none; }
[data-theme="dark"] .toast.info { background: var(--blue); color: #fff; border: none; }
[data-theme="dark"] .ink-warning { background: var(--amber-light); color: #fbbf24; }
[data-theme="dark"] .import-drop-zone { background: var(--surface); }
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.6); }
[data-theme="dark"] .cmd-backdrop { background: rgba(0,0,0,0.6); }
/* Landing page */
.landing-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; }
.landing-section-alt { background: #f9fafb; }
.landing-hero { color: #1e293b; }
.landing-subtitle { color: #6b7280; }
.landing-feature-title { color: #1e293b; }
.landing-feature-desc { color: #6b7280; }
.landing-price { color: #1e293b; }
.landing-price-desc { color: #6b7280; }

[data-theme="dark"] .landing-card { background: var(--card, var(--surface)); border-color: var(--border); }
[data-theme="dark"] .landing-section-alt { background: var(--bg); }
[data-theme="dark"] .landing-hero,
[data-theme="dark"] .landing-feature-title,
[data-theme="dark"] .landing-price { color: var(--text); }
[data-theme="dark"] .landing-subtitle,
[data-theme="dark"] .landing-feature-desc,
[data-theme="dark"] .landing-price-desc { color: var(--muted, var(--text-secondary)); }

/* Password toggle */
.pw-toggle { position:absolute;right:8px;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--text-hint,#9ca3af);padding:4px;display:flex;align-items:center; }
.pw-toggle:hover { color:var(--text-secondary,#6b7280); }
.pw-toggle.active { color:var(--accent,#2AABE0); }

/* Pagination & table footer */
.table-footer { display:flex;justify-content:space-between;align-items:center;padding:10px 12px;font-size:13px;color:var(--text-secondary,#6b7280);border-top:1px solid var(--border,#e5e7eb); }
.pagination { display:flex;align-items:center;gap:6px;flex-wrap:wrap; }
.page-info { font-size:13px;color:var(--text-secondary,#6b7280);white-space:nowrap; }
.page-size-select { padding:3px 6px;font-size:12px;border:1px solid var(--border,#e5e7eb);border-radius:var(--radius,6px);background:var(--card,#fff);color:var(--text,#111827);cursor:pointer; }
th[style*="cursor:pointer"]:hover { color:var(--accent,#2AABE0); }

/* Skeleton loading */
.skeleton { background:linear-gradient(90deg,var(--border,#e5e7eb) 25%,var(--bg,#f9fafb) 50%,var(--border,#e5e7eb) 75%);background-size:200% 100%;animation:skeleton-pulse 1.5s ease-in-out infinite;border-radius:var(--radius,6px); }
@keyframes skeleton-pulse { 0% { background-position:200% 0; } 100% { background-position:-200% 0; } }
.skeleton-row { display:flex;gap:12px;padding:12px;border-bottom:1px solid var(--border,#e5e7eb); }
.skeleton-cell { height:16px;border-radius:4px; }
.skeleton-cell.w1 { width:30%; }
.skeleton-cell.w2 { width:25%; }
.skeleton-cell.w3 { width:15%; }
.skeleton-cell.w4 { width:10%; }
.skeleton-header { height:32px;margin-bottom:16px; }

[data-theme="dark"] img { opacity: 0.92; }

/* Mobile sticky CTA for landing page */
.mobile-sticky-cta { display:none; position:fixed; bottom:0; left:0; right:0; padding:12px 16px; background:var(--card,#fff); border-top:1px solid var(--border,#e5e7eb); z-index:100; text-align:center; box-shadow:0 -2px 8px rgba(0,0,0,0.1); }
@media (max-width: 768px) { .mobile-sticky-cta { display:block; } }

/* ============================================================
   FEAT-QW-01 — Global PDF drop overlay (Phase 3 Plan 03-04)
   Created + toggled by public/js/core/bootstrap.js.
   z-index intentionally below .modal-overlay (200) so an open
   modal visually covers it; shouldAcceptDrop() also guards the
   modal case so both never co-render in practice.
   ============================================================ */
.ft-drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 45, 79, 0.72); /* matches brand navy */
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 150;
  pointer-events: none;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.ft-drop-overlay.visible {
  display: flex;
  pointer-events: auto;
}
.ft-drop-overlay-inner {
  border: 2px dashed #fff;
  padding: 2rem 3rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
}
