/* ══════════════════════════════════════════
   TrakNet.AI - Field Service Management
   Light mode default · Dark mode optional
   ══════════════════════════════════════════ */

:root, [data-theme="light"] {
  --primary: #0a1628;
  --primary-light: #f8fafc;
  --primary-dark: #0f172a;
  --accent: #00bcd4;
  --accent-light: #4dd0e1;
  --accent-dark: #0097a7;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-dark: #0f172a;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --sidebar-width: 240px;
  --header-height: 56px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
}

[data-theme="dark"] {
  --primary: #0a1628;
  --primary-light: #122240;
  --primary-dark: #060e1a;
  --accent: #00bcd4;
  --accent-light: #4dd0e1;
  --accent-dark: #0097a7;
  --success: #00c853;
  --warning: #ff9800;
  --danger: #f44336;
  --info: #2196f3;
  --text: #e0e6ed;
  --text-muted: #8899aa;
  --text-dark: #1a2332;
  --bg: #0d1b2a;
  --bg-card: #1b2838;
  --bg-input: #162231;
  --border: #1e3a5f;
  --border-light: #2a4a6b;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* Keep sidebar dark in light mode for branding consistency */
[data-theme="light"] .sidebar {
  background: #0a1628 !important;
  border-right-color: #1e3a5f !important;
}
[data-theme="light"] .sidebar-brand h1,
[data-theme="light"] .sidebar-brand h1 span { color: #fff; }
[data-theme="light"] .sidebar-brand h1 span { color: #00bcd4; }
[data-theme="light"] .sidebar-brand small { color: #8899aa; }
[data-theme="light"] .sidebar-nav a { color: #8899aa; }
[data-theme="light"] .sidebar-nav a:hover { color: #e0e6ed; background: rgba(0,188,212,0.05); }
[data-theme="light"] .sidebar-nav a.active { color: #00bcd4; background: rgba(0,188,212,0.08); border-left-color: #00bcd4; }
[data-theme="light"] .sidebar-footer { border-top-color: #1e3a5f; color: #8899aa; }
[data-theme="light"] .sidebar-footer .user-info div:first-of-type + div div:first-child { color: #e0e6ed; }
[data-theme="light"] .sidebar-footer .avatar { background: #00bcd4; color: #060e1a; }
[data-theme="light"] .sidebar-footer a { color: #00bcd4; }
[data-theme="light"] .sidebar-logo { border-top-color: #1e3a5f; }

/* Light mode top bar — clean white */
[data-theme="light"] .top-bar {
  background: #ffffff !important;
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: 0 1px 3px rgba(15,23,42,0.05) !important;
}
[data-theme="light"] .top-bar .page-title { color: #0f172a; font-weight: 600; }
[data-theme="light"] .top-bar .search-bar { background: #f1f5f9; border-radius: 8px; border: 1px solid #e2e8f0; }
[data-theme="light"] .top-bar .search-bar input { background: transparent; border-color: transparent; color: #0f172a; }
[data-theme="light"] .top-bar .search-bar svg { color: #64748b; }
[data-theme="light"] .top-bar .btn-secondary { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }
[data-theme="light"] .top-bar .hamburger span { background: #334155; }

/* Light mode — ensure all text is dark and readable */
[data-theme="light"] table thead th { background: #f8fafc; color: #64748b; border-bottom-color: #e2e8f0; }
[data-theme="light"] table tbody td { color: #0f172a; }
[data-theme="light"] .card-header h3 { color: #0f172a; }
[data-theme="light"] .stat-card .stat-value { color: #0f172a !important; }
[data-theme="light"] .stat-card .stat-label { color: #64748b; }
[data-theme="light"] h2, [data-theme="light"] h3 { color: #0f172a; }
[data-theme="light"] .form-control { color: #0f172a; background: #f1f5f9; border-color: #e2e8f0; }
[data-theme="light"] select.form-control { color: #0f172a; }
[data-theme="light"] .tab { color: #64748b; }
[data-theme="light"] .tab.active { color: #0097a7; }
[data-theme="light"] .modal { background: #ffffff; border-color: #e2e8f0; }
[data-theme="light"] .modal-header { border-bottom-color: #e2e8f0; }
[data-theme="light"] .modal-header h2 { color: #0f172a; }
[data-theme="light"] .modal-footer { border-top-color: #e2e8f0; }
[data-theme="light"] .modal-body { color: #0f172a; }
[data-theme="light"] .pagination button { background: #fff; border-color: #e2e8f0; color: #64748b; }
[data-theme="light"] .pagination button.active { background: #00bcd4; color: #fff; }
[data-theme="light"] .empty-state { color: #64748b !important; }
[data-theme="light"] .loading { color: #64748b; }
[data-theme="light"] label { color: #334155; }
[data-theme="light"] .form-group label { color: #334155; }
[data-theme="light"] strong { color: #0f172a; }
[data-theme="light"] .search-bar input { color: #0f172a; background: transparent; border-color: transparent; }
[data-theme="light"] .login-error { color: #dc2626; }
[data-theme="light"] .card { box-shadow: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04); }
[data-theme="light"] .stat-card { box-shadow: 0 1px 3px rgba(15,23,42,0.06); }

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  overflow-x: hidden;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-light); }

/* ── Login Page ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #0a2a3f 100%);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0,188,212,0.1);
}

.login-card .logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-card .logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}

.login-card .logo h1 span {
  color: var(--accent);
}

.login-card .logo p {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.login-card label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 16px;
}

.login-card input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border 0.2s;
}

.login-card input:focus {
  border-color: var(--accent);
}

.login-card button {
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  background: var(--accent);
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.login-card button:hover {
  background: var(--accent-light);
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  display: none;
}

/* ── App Layout ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-brand {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand h1 {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.sidebar-brand h1 span {
  color: var(--accent);
}

.sidebar-brand small {
  display: block;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 14px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  color: var(--text);
  background: rgba(0,188,212,0.05);
}

.sidebar-nav a.active {
  color: var(--accent);
  background: rgba(0,188,212,0.08);
  border-left-color: var(--accent);
}

.sidebar-nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-footer .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

.sidebar-logo {
  margin-top: 12px;
  text-align: center;
}

.sidebar-logo img {
  width: 100%;
  max-width: 160px;
  height: auto;
  border-radius: 6px;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.sidebar-logo img:hover {
  opacity: 1;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  min-width: 0;
  overflow-x: hidden;
}

.top-bar {
  height: var(--header-height);
  background: var(--primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar .page-title {
  font-size: 18px;
  font-weight: 600;
}

.top-bar .actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-content {
  padding: 24px 32px;
}

@media (min-width: 1200px) {
  .page-content { padding: 28px 40px; }
}

@media (min-width: 1600px) {
  .page-content { padding: 32px 48px; }
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--primary-dark);
}
.btn-primary:hover { background: var(--accent-light); }

.btn-secondary {
  background: var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--border-light); }

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

/* ── Stats Cards (Dashboard) ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-card .stat-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 8px;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
}

.stat-card.accent::after { background: var(--accent); }
.stat-card.success::after { background: var(--success); }
.stat-card.warning::after { background: var(--warning); }
.stat-card.danger::after { background: var(--danger); }
.stat-card.info::after { background: var(--info); }

/* ── Tables ── */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

table thead th:hover {
  color: var(--text);
}

table thead th .col-sort {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  opacity: 0.4;
}

table thead th.sorted .col-sort {
  opacity: 1;
  color: var(--accent);
}

/* Column Filter Icon */
table thead th .col-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  margin-left: 4px;
  padding: 0;
  vertical-align: middle;
  transition: all 0.15s;
}

table thead th .col-filter-btn:hover {
  background: rgba(0,188,212,0.15);
  color: var(--accent);
}

/* Column Filter Dropdown */
.col-filter-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 150;
  padding: 8px;
  animation: scaleIn 0.15s ease;
}

.col-filter-dropdown input[type="text"] {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  margin-bottom: 6px;
  outline: none;
}

.col-filter-dropdown input[type="text"]:focus {
  border-color: var(--accent);
}

.col-filter-dropdown .filter-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  border-radius: 3px;
}

.col-filter-dropdown .filter-option:hover {
  background: rgba(0,188,212,0.08);
}

.col-filter-dropdown .filter-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Settings Dropdown */
.settings-dropdown {
  position: absolute;
  top: calc(var(--header-height) - 4px);
  right: 16px;
  width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  z-index: 200;
  padding: 8px 0;
  animation: scaleIn 0.15s ease;
  display: none;
}

.settings-dropdown.open {
  display: block;
}

.settings-dropdown a {
  display: block;
  padding: 10px 20px;
  color: var(--text);
  font-size: 13px;
  transition: background 0.1s;
}

.settings-dropdown a:hover {
  background: rgba(0,188,212,0.06);
  color: var(--accent);
}

/* Dropdown in tables — lift the active row above siblings so dropdown is visible */
table tbody tr:has(.settings-dropdown.open) {
  position: relative;
  z-index: 1000;
}
table .settings-dropdown {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  z-index: 1001;
}
table .settings-dropdown a {
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
table .settings-dropdown a:hover {
  background: rgba(0,188,212,0.1);
  color: var(--accent);
}

table tbody td {
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

table tbody tr:hover {
  background: rgba(0,188,212,0.03);
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-cyan { background: rgba(0,188,212,0.15); color: var(--accent); }
.badge-green { background: rgba(0,200,83,0.15); color: var(--success); }
.badge-orange { background: rgba(255,152,0,0.15); color: var(--warning); }
.badge-red { background: rgba(244,67,54,0.15); color: var(--danger); }
.badge-blue { background: rgba(33,150,243,0.15); color: var(--info); }
.badge-grey { background: rgba(136,153,170,0.15); color: var(--text-muted); }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Forms ── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border 0.2s;
}

.form-control:focus {
  border-color: var(--accent);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238899aa' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 600px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,0.4);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
}

.pagination button {
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}

.pagination button:hover { border-color: var(--accent); color: var(--text); }
.pagination button.active { background: var(--accent); color: var(--primary-dark); border-color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ── Search Bar ── */
.search-bar {
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.search-bar input:focus {
  border-color: var(--accent);
}

.search-bar svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 10px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text);
}

/* ── Donut Chart ── */
.chart-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chart-center-text {
  position: absolute;
  text-align: center;
}

.chart-center-text .value {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
}

.chart-center-text .label {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Quick Create Button ── */
.quick-create {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--primary-dark);
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,188,212,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  z-index: 50;
}

.quick-create:hover {
  transform: scale(1.1);
}

/* ── Responsive ── */
/* ── Hamburger Button ── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-right: 8px;
  z-index: 1001;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* ── Sidebar Overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 1000;
    transition: transform 0.3s ease;
    width: 240px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .top-bar {
    padding: 8px 12px;
    gap: 8px;
  }
  .page-title {
    font-size: 16px;
  }
  .search-bar {
    display: none;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  /* Table horizontal scroll — contained within viewport */
  table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  table thead, table tbody, table tr {
    display: table;
    width: 100%;
    table-layout: auto;
  }
  /* Dashboard cards */
  .dashboard-grid, .stage-cards {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  /* Job stats panel */
  .jobs-stage-cards {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }
  .jobs-stage-cards > div {
    font-size: 12px;
  }
  /* Schedule tabs horizontal scroll */
  .schedule-tabs, .status-tabs {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
  }
  .schedule-tabs::-webkit-scrollbar,
  .status-tabs::-webkit-scrollbar {
    display: none;
  }
  /* Kanban board horizontal scroll */
  .kanban-board {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
  }
  .kanban-col {
    min-width: 260px;
    flex-shrink: 0;
  }
  /* Slide-out panel full width on mobile */
  .slide-panel {
    width: 100% !important;
    max-width: 100% !important;
  }
  /* Ticket stat cards */
  .ticket-stats {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
  }
  .ticket-stats > div {
    padding: 8px !important;
  }
  /* Quote/Invoice stats */
  .accounting-stats {
    flex-direction: column;
  }
  .quotes-by-status {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px;
  }
  /* Buttons */
  .btn-group {
    flex-wrap: wrap;
    gap: 4px;
  }
  .btn-sm {
    font-size: 11px;
    padding: 4px 8px;
  }
  /* Donut charts smaller on mobile */
  canvas.donut {
    max-width: 100px;
    max-height: 100px;
  }
  /* FAB button position on mobile */
  .fab-btn {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
  /* Card padding */
  .card {
    padding: 12px;
  }
  .card h3 {
    font-size: 14px;
  }
  /* Modal adjustments */
  .modal-content {
    width: 95% !important;
    max-width: 95% !important;
    margin: 10px auto;
    max-height: 90vh;
  }
  /* Filters row */
  .filters-row {
    flex-direction: column;
    gap: 8px;
  }
  /* Date range picker */
  .date-range {
    flex-direction: column;
    gap: 4px;
  }
  /* Scheduler calendar responsive */
  #schedulerGrid > div {
    grid-template-columns: 1fr !important;
  }
  /* Form builder fields panel */
  .form-designer-layout {
    grid-template-columns: 1fr !important;
  }
  /* Inventory stats cards */
  .inventory-stats {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ── Small mobile (< 480px) ── */
@media (max-width: 480px) {
  .stats-grid, .dashboard-grid, .stage-cards {
    grid-template-columns: 1fr !important;
  }
  .ticket-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .quotes-by-status {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .top-bar .actions {
    gap: 4px;
  }
  .btn-sm {
    font-size: 10px;
    padding: 3px 6px;
  }
  .screen {
    padding: 8px !important;
  }
}

/* ── Mobile utility classes ── */
@media (max-width: 640px) {
  .mob-hide { display: none !important; }
  .mob-stack { flex-direction: column !important; align-items: stretch !important; }
  .mob-stack button, .mob-stack a { width: 100%; text-align: center; }
  .mob-2col { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
}

/* ── Screen visibility ── */
.screen { display: none; padding: 24px 32px; }
.screen.active { display: block; }
@media (min-width: 1200px) { .screen { padding: 28px 40px; } }
@media (max-width: 768px) { .screen { padding: 16px; } }

/* ── SaaS Animations ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Stat cards animate in staggered */
.stats-grid .stat-card {
  animation: fadeInUp 0.5s ease both;
}
.stats-grid .stat-card:nth-child(1) { animation-delay: 0.05s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.1s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.15s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.2s; }
.stats-grid .stat-card:nth-child(5) { animation-delay: 0.25s; }
.stats-grid .stat-card:nth-child(6) { animation-delay: 0.3s; }

/* Cards animate in */
.card {
  animation: scaleIn 0.4s ease both;
}

/* Table rows animate in */
table tbody tr {
  animation: fadeIn 0.3s ease both;
}
table tbody tr:nth-child(1) { animation-delay: 0.02s; }
table tbody tr:nth-child(2) { animation-delay: 0.04s; }
table tbody tr:nth-child(3) { animation-delay: 0.06s; }
table tbody tr:nth-child(4) { animation-delay: 0.08s; }
table tbody tr:nth-child(5) { animation-delay: 0.1s; }
table tbody tr:nth-child(6) { animation-delay: 0.12s; }
table tbody tr:nth-child(7) { animation-delay: 0.14s; }
table tbody tr:nth-child(8) { animation-delay: 0.16s; }
table tbody tr:nth-child(9) { animation-delay: 0.18s; }
table tbody tr:nth-child(10) { animation-delay: 0.2s; }

/* Badges pulse on appear */
.badge {
  animation: scaleIn 0.3s ease both;
}

/* Donut chart container glow */
canvas {
  filter: drop-shadow(0 0 8px rgba(0,188,212,0.15));
}

/* Smooth hover lift on stat cards */
.stat-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* Tabs slide indicator */
.tab {
  transition: all 0.2s ease;
}
.tab.active {
  transform: translateY(-1px);
}

/* Button press effect */
.btn {
  transition: all 0.15s ease;
}
.btn:active {
  transform: scale(0.97);
}

/* Toast slide-in enhanced */
.toast {
  animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInRight {
  from { transform: translateX(100%) scale(0.9); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}

/* Page title fade */
.page-title {
  animation: fadeIn 0.3s ease;
}

/* Sidebar nav links hover glow */
.sidebar-nav a:hover {
  text-shadow: 0 0 8px rgba(0,188,212,0.2);
}
.sidebar-nav a.active {
  text-shadow: 0 0 12px rgba(0,188,212,0.3);
}

/* Settings nav */
.settings-nav-item {
  display: block;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.settings-nav-item:hover { color: var(--text); background: rgba(0,188,212,0.04); }
.settings-nav-item.active { color: var(--accent); border-left-color: var(--accent); background: rgba(0,188,212,0.06); }

/* Kanban board */
.kanban-col { flex: 1; min-width: 220px; }
.kanban-items { transition: background 0.15s; }
.kanban-items.drag-over { background: rgba(0,188,212,0.1) !important; }

/* Slide-out Panel */
.slide-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000;
  opacity: 0; transition: opacity 0.3s ease;
}
.slide-overlay.active { opacity: 1; }
.slide-panel {
  position: fixed; top: 0; right: -520px; bottom: 0; width: 500px; max-width: 90vw;
  background: var(--bg, #0d1b2a); z-index: 1001; display: flex; flex-direction: column;
  box-shadow: -4px 0 30px rgba(0,0,0,0.5); transition: right 0.3s ease;
  border-left: 1px solid var(--border);
}
[data-theme="light"] .slide-panel { background: #ffffff; box-shadow: -4px 0 30px rgba(0,0,0,0.15); }
.slide-panel-body .form-group label { color: var(--text); font-size: 12px; font-weight: 600; margin-bottom: 4px; display: block; }
.slide-panel-body .form-control { background: var(--bg-input, var(--primary-light)); border: 1px solid var(--border); color: var(--text); }
[data-theme="light"] .slide-panel-body .form-control { background: #f5f6f8; border-color: #e0e4ea; color: #1a2332; }
.slide-panel-header { background: var(--bg, #0d1b2a); }
[data-theme="light"] .slide-panel-header { background: #ffffff; }
.slide-panel-footer { background: var(--bg, #0d1b2a); }
[data-theme="light"] .slide-panel-footer { background: #ffffff; }
.slide-panel.active { right: 0; }
.slide-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
}
.slide-panel-header h3 { font-size: 18px; font-weight: 600; }
.slide-close {
  background: none; border: none; color: var(--text-muted); font-size: 24px;
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius);
  transition: all 0.2s;
}
.slide-close:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.slide-panel-body {
  flex: 1; overflow-y: auto; padding: 24px;
}
.slide-panel-footer {
  display: flex; justify-content: flex-end; gap: 12px;
  padding: 16px 24px; border-top: 1px solid var(--border);
}

/* Toggle Switch */
.toggle-switch {
  width: 44px; height: 24px; background: var(--border); border-radius: 12px;
  position: relative; cursor: pointer; transition: background 0.2s;
  display: inline-block;
}
.toggle-switch.on { background: var(--accent); }
.toggle-knob {
  width: 20px; height: 20px; background: #fff; border-radius: 50%;
  position: absolute; top: 2px; left: 2px; transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch.on .toggle-knob { left: 22px; }

/* ── Scheduler Calendar ── */
.scheduler-job-block:active { transform: scale(0.98); }

/* ── Scheduler Klipboard-style ── */
.sched-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #3b2978;
  border-radius: 10px;
  padding: 8px 12px;
  flex-wrap: wrap;
}
.sched-today-btn {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 5px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.sched-today-btn:hover { background: rgba(255,255,255,0.12); }
.sched-nav-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 22px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  border-radius: 4px;
}
.sched-nav-btn:hover { background: rgba(255,255,255,0.1); }
.sched-date-pill {
  border: 1.5px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 5px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.sched-filter-btn {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.9);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}
.sched-filter-btn:hover { background: rgba(255,255,255,0.1); }
.sched-view-group {
  display: flex;
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  padding: 2px;
  margin-left: auto;
  gap: 1px;
}
.sched-view-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.sched-view-btn.active {
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-weight: 500;
}
.sched-view-btn:hover:not(.active) { color: rgba(255,255,255,0.85); }
.sched-strip-wrapper {
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
}
.sched-strip-wrapper::-webkit-scrollbar { display: none; }
.sched-strip { display: flex; min-width: max-content; }
.sched-strip-item {
  flex-shrink: 0;
  width: 64px;
  text-align: center;
  padding: 8px 4px;
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: background 0.1s;
}
.sched-strip-item:hover { background: var(--bg); }
.sched-strip-item.today-strip { background: #fefce8; }
.sched-strip-item .sdi-name {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
}
.sched-strip-item .sdi-num {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
  display: block;
}
.sched-strip-item.selected .sdi-num {
  background: #3b2978;
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.sched-resource-outer {
  overflow: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  max-height: 580px;
  position: relative;
}
.sched-resource-header {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  min-width: max-content;
}
.sched-gutter-head {
  flex-shrink: 0;
  width: 64px;
  border-right: 1px solid var(--border);
}
.sched-staff-head {
  flex-shrink: 0;
  width: 180px;
  padding: 10px;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  font-size: 12px;
}
.sched-staff-head.today-col { background: #fefce8; }
.sched-time-body { display: flex; min-width: max-content; position: relative; }
.sched-gutter-col {
  flex-shrink: 0;
  width: 64px;
  border-right: 1px solid var(--border);
  position: relative;
}
.sched-time-label {
  height: 40px;
  padding: 2px 8px 2px 4px;
  font-size: 10px;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(0,0,0,0.04);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}
.sched-staff-col {
  flex-shrink: 0;
  width: 180px;
  border-right: 1px solid var(--border);
  position: relative;
}
.sched-staff-col.today-col { background: #fefce8; }
.sched-slot {
  height: 40px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.1s;
  cursor: pointer;
}
.sched-slot:hover { background: rgba(59,41,120,0.05); }
.sched-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #ef4444;
  z-index: 20;
  pointer-events: none;
}
.sched-now-dot {
  position: absolute;
  left: -5px;
  top: -5px;
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
}
.sched-job-item {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  cursor: pointer;
  overflow: hidden;
  z-index: 5;
  min-height: 22px;
  line-height: 1.3;
}
.sched-job-item:hover { filter: brightness(0.88); }
.sched-biz-footer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 8px 16px;
}
.sched-biz-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
}
.sched-biz-btn:hover { background: var(--bg); }

/* ── Schedule Job Modal (Klipboard-style) ───────────────────────── */
.smp-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.smp-dialog {
  background: #fff; border-radius: 10px;
  width: 560px; max-width: 100%; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  display: flex; flex-direction: column;
}
.smp-header {
  background: #3b2978; color: #fff;
  padding: 18px 20px; display: flex;
  align-items: center; justify-content: space-between;
  border-radius: 10px 10px 0 0; flex-shrink: 0;
  font-size: 16px; font-weight: 600; letter-spacing: 0.2px;
}
.smp-close {
  background: none; border: none; color: #fff;
  font-size: 22px; cursor: pointer; padding: 0 4px;
  line-height: 1; opacity: 0.8;
}
.smp-close:hover { opacity: 1; }
.smp-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid #e2e8f0; flex-shrink: 0;
}
.smp-tab {
  background: #f5f3ff; border: none; padding: 14px 12px;
  cursor: pointer; text-align: left; transition: background 0.15s;
  border-right: 1px solid #e2e8f0; outline: none;
}
.smp-tab:last-child { border-right: none; }
.smp-tab.active { background: #3b2978; }
.smp-tab:hover:not(.active) { background: #ede9f6; }
.smt-title {
  display: block; font-size: 13px; font-weight: 600;
  color: #64748b;
}
.smp-tab.active .smt-title { color: #fff; }
.smt-sub {
  display: block; font-size: 11px; color: #94a3b8; margin-top: 3px;
}
.smp-tab.active .smt-sub { color: rgba(255,255,255,0.65); }
.smp-panel { padding: 20px; }
.smp-row { padding: 14px 0; border-bottom: 1px solid #f1f5f9; }
.smp-row:last-child { border-bottom: none; }
.smp-label {
  font-size: 12px; font-weight: 600; color: #3b2978;
  display: block; margin-bottom: 8px;
}
.smp-dt-row {
  display: flex; align-items: center; gap: 8px;
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 6px; padding: 8px 12px;
}
.smp-dt-val { flex: 1; font-size: 13px; color: #334155; }
.smp-hidden-inp {
  position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0;
}
.smp-icon-btn {
  background: #3b2978; border: none; border-radius: 5px;
  color: #fff; padding: 5px 7px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s;
}
.smp-icon-btn:hover { background: #2d1f5e; }
.smp-section { margin-bottom: 4px; }
.smp-section-title {
  font-size: 13px; font-weight: 700; color: #3b2978; margin-bottom: 10px;
}
.smp-hr { border: none; border-top: 1px solid #e2e8f0; margin: 16px 0; }
.smp-time-row { display: flex; align-items: center; gap: 6px; }
.smp-freq-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.smp-freq-pill {
  background: #f1f5f9; border: 1px solid #e2e8f0;
  border-radius: 20px; padding: 6px 16px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  color: #475569; transition: all 0.15s; outline: none;
}
.smp-freq-pill.active { background: #3b2978; border-color: #3b2978; color: #fff; }
.smp-freq-pill:hover:not(.active) { background: #e2e8f0; }
.smp-day-circles { display: flex; gap: 6px; }
.smp-day-circle {
  width: 36px; height: 36px; border-radius: 50%;
  background: #f1f5f9; border: 1px solid #e2e8f0;
  font-size: 12px; font-weight: 600; cursor: pointer;
  color: #475569; transition: all 0.15s; outline: none;
  display: flex; align-items: center; justify-content: center;
}
.smp-day-circle.active { background: #3b2978; border-color: #3b2978; color: #fff; }
.smp-day-circle:hover:not(.active) { background: #e2e8f0; }
.smp-summary {
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: 6px; padding: 12px 14px;
  font-size: 13px; color: #92400e; margin-top: 16px; line-height: 1.6;
}
.smp-footer {
  padding: 16px 20px; display: flex; justify-content: flex-end;
  border-top: 1px solid #e2e8f0; flex-shrink: 0;
  background: #fff; border-radius: 0 0 10px 10px;
  position: sticky; bottom: 0;
}
.smp-save-btn {
  background: #06b6d4; border: none; border-radius: 6px;
  color: #fff; font-size: 13px; font-weight: 700;
  padding: 10px 28px; cursor: pointer; letter-spacing: 0.5px;
  transition: background 0.15s;
}
.smp-save-btn:hover { background: #0891b2; }
.sched-staff-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .sched-view-group { display: none; }
  .sched-staff-head, .sched-staff-col { width: 140px; }
  .sched-gutter-head, .sched-gutter-col { width: 48px; }
}

/* ══════════════════════════════════════════
   GPS Tracking - Enhanced Styles
   ══════════════════════════════════════════ */
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}
@keyframes tracking-pulse-ring {
  0% { transform: translate(-50%,-50%) scale(1); opacity: 0.6; }
  100% { transform: translate(-50%,-50%) scale(2.5); opacity: 0; }
}

.tracking-pulse {
  position: absolute; top: 50%; left: 50%;
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid; transform: translate(-50%, -50%);
  animation: tracking-pulse-ring 2s ease-out infinite;
  pointer-events: none;
}

.tracking-label {
  position: absolute; top: 28px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 10px; font-weight: 600;
  color: #fff; background: rgba(0,0,0,0.75);
  padding: 2px 6px; border-radius: 4px;
  pointer-events: none; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.tracking-speed {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 9px; font-weight: 700;
  color: #fff; background: rgba(0,0,0,0.7);
  padding: 1px 5px; border-radius: 3px;
  pointer-events: none;
}

.tracking-stat-card {
  padding: 10px 16px; border-left: 3px solid;
  background: var(--bg-card); border-radius: var(--radius);
  min-width: 90px; transition: transform 0.15s;
}
.tracking-stat-card:hover { transform: translateY(-1px); }

/* Alerts Panel */
.tracking-alerts-panel {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 12px; border: 1px solid var(--border);
}

.alert-item {
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.alert-item:hover {
  transform: translateX(2px);
  background: rgba(255,255,255,0.05) !important;
}

/* ── GPS Device Panel ── */
.gps-tab-btn {
  flex: 1; padding: 4px 6px; font-size: 11px; font-weight: 600;
  border: 1px solid rgba(128,128,128,0.25); border-radius: 4px;
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gps-tab-btn.gps-tab-active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.gps-tab-btn:hover:not(.gps-tab-active) {
  background: rgba(128,128,128,0.1); color: var(--text);
}
.gps-device-row { transition: background 0.15s, border-color 0.15s; }
.gps-device-row:hover { background: rgba(128,128,128,0.1) !important; }

.gps-edit-tab {
  padding: 6px 16px; font-size: 13px; font-weight: 500;
  border: none; border-bottom: 2px solid transparent;
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.gps-edit-tab.active, .gps-edit-tab:hover { color: var(--text); }
.gps-edit-tab.active { border-bottom-color: var(--accent); color: var(--accent); }

/* Geofence labels on map */
.geofence-label {
  font-size: 11px; font-weight: 600;
  color: #00bcd4; background: rgba(10,22,40,0.85);
  padding: 2px 8px; border-radius: 4px;
  white-space: nowrap; text-align: center;
  transform: translateX(-50%);
  border: 1px solid rgba(0,188,212,0.3);
}

/* Replay speed slider */
#replaySpeed {
  -webkit-appearance: none; appearance: none;
  height: 4px; background: var(--border); border-radius: 2px; outline: none;
}
#replaySpeed::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

/* Responsive: stack map + alerts on small screens */
@media (max-width: 900px) {
  .tracking-alerts-panel { width: 100% !important; height: 200px !important; }
}

/* ══════════════════════════════════════════
   MOBILE RESPONSIVE — inline grid overrides
   Targets hardcoded grid/flex layouts in HTML
   ══════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Dashboard 4-col charts → 2-col */
  #dashboardCharts {
    grid-template-columns: 1fr 1fr !important;
  }

  /* AI dashboard 2-col row → single col */
  #screen-dashboard > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Job/Invoice 3-col form grids → single col */
  .form-row-3,
  div[style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Tracking stats row → 2 cols */
  #trackingStats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* Tracking map — reduce height on mobile */
  #trackingMap {
    height: 280px !important;
    min-height: 280px !important;
  }

  /* Top bar — hide non-essential actions */
  .top-bar .actions .btn-secondary:not(#themeToggle):not(#settingsBtn) {
    display: none;
  }

  /* Page content — tighter padding */
  .page-content {
    padding: 12px 14px !important;
  }

  /* Slide panel — full width */
  .slide-panel, [class*="slide-panel"] {
    width: 100% !important;
    max-width: 100% !important;
    border-left: none !important;
  }

  /* Card grids with inline 2-col → stack */
  div[style*="grid-template-columns:1fr 1fr"][style*="gap"] {
    grid-template-columns: 1fr !important;
  }

  /* Schedule / timeline grids */
  #schedulerGrid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Invoice / quote stats row → wrap */
  .invoice-stats-row, .quotes-stats-row {
    flex-wrap: wrap;
    gap: 8px !important;
  }
  .invoice-stats-row > *, .quotes-stats-row > * {
    flex: 1 1 calc(50% - 8px) !important;
    min-width: 120px;
  }

  /* Filter rows → vertical stack */
  .filters-bar, .toolbar-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .filters-bar .btn-group { flex-wrap: wrap; }

  /* Modal full-screen on mobile */
  .modal-overlay .modal-content,
  .modal-overlay [class*="modal"] {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 95vh !important;
    border-radius: 12px 12px 0 0 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    margin: 0 !important;
  }

  /* Table — horizontal scroll wrapper */
  .table-wrapper, .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* DVLA status badges in tracking */
  .dvla-badge {
    font-size: 10px !important;
    padding: 1px 5px !important;
  }

  /* Inputs and selects never wider than parent */
  input, select, textarea {
    max-width: 100%;
    min-width: 0;
  }

  /* Inline grid containers only — not flex (flex kills map/kanban layouts) */
  div[style*="display:grid"], div[style*="display: grid"] {
    max-width: 100% !important;
    min-width: 0;
  }

  /* Dashboard "Jobs By Stage" 6-col grid → 2-col on mobile */
  div[style*="grid-template-columns:repeat(6"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    border-left: none !important;
  }
  div[style*="grid-template-columns:repeat(6"] > div {
    border-right: none !important;
    border-bottom: 1px solid var(--border);
    padding: 12px 8px !important;
  }

  /* Dashboard span-5 card — full width on mobile */
  div[style*="grid-column: span 5"],
  div[style*="grid-column:span 5"] {
    grid-column: span 1 !important;
  }

  /* Tracking map — ensure it always has height */
  #trackingMap {
    height: 260px !important;
    min-height: 260px !important;
    width: 100% !important;
  }
}

/* ══════════════════════════════════════════
   UI POLISH — Dashboard interactive cards,
   hover states, scrollbars, badges, tables
   ══════════════════════════════════════════ */

/* ── Dashboard nav cards (POs, Quotes, Invoices, etc.) ── */
.dash-nav-card {
  transition: box-shadow 0.15s, border-color 0.15s, background 0.15s;
}
.dash-nav-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 16px rgba(0,188,212,0.12);
  background: var(--bg-card);
}

/* ── Dashboard stage columns ── */
.dash-stage-col:hover {
  background: rgba(0,188,212,0.05);
}

/* ── Card hover glow (general) ── */
.card {
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

/* ── Badge polish — consistent pill shape and spacing ── */
.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* ── Table row hover — more visible highlight ── */
table tbody tr:hover {
  background: rgba(0,188,212,0.05) !important;
  cursor: default;
}
table tbody tr.clickable-row:hover,
table tbody tr[onclick]:hover {
  background: rgba(0,188,212,0.08) !important;
  cursor: pointer;
}

/* ── All clickable elements get pointer ── */
[onclick],
[data-href],
.clickable {
  cursor: pointer;
}

/* ── Form inputs — consistent accent focus ring ── */
.form-control:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent) !important;
  outline: none;
  box-shadow: 0 0 0 2px rgba(0,188,212,0.15);
}

/* ── Button active states ── */
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary:active { opacity: 0.8; }
.btn-danger:hover { background: #e53935; }
.btn-danger:active { background: #c62828; }
.btn-success:hover { background: #14a341; }

/* ── Empty state — polished ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
}
.empty-state svg {
  opacity: 0.3;
  margin-bottom: 16px;
}
.empty-state p {
  font-size: 14px;
  line-height: 1.6;
  max-width: 320px;
}

/* ── Body text line height ── */
body {
  line-height: 1.6;
}
p, td, li {
  line-height: 1.6;
}

/* ── Custom webkit scrollbar — thin, styled ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ── Sidebar nav scrollbar ── */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(0,188,212,0.2);
  border-radius: 2px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(0,188,212,0.5);
}

/* ── Sidebar nav items — clearer active state ── */
.sidebar-nav a {
  position: relative;
}
.sidebar-nav a.active {
  font-weight: 600;
}
.sidebar-nav a:hover {
  border-left-color: rgba(0,188,212,0.35);
}

/* ── Stat cards — pointer on hover ── */
.stat-card {
  cursor: pointer;
}

/* ── Light mode scrollbar ── */
[data-theme="light"] ::-webkit-scrollbar-track {
  background: #f1f5f9;
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: #00bcd4;
}

@media (max-width: 480px) {
  /* Dashboard charts → single col on smallest screens */
  #dashboardCharts {
    grid-template-columns: 1fr !important;
  }

  /* Tracking stats → 2-col stays fine */

  /* Stat cards — compact */
  .stat-card { padding: 12px 10px; }
  .stat-card .stat-value { font-size: 22px; }

  /* Top bar — minimal */
  .top-bar { padding: 0 10px; gap: 6px; }
  .page-title { font-size: 15px !important; }

  /* Buttons in action rows → icon only where possible */
  .btn-lg { padding: 10px 16px; font-size: 13px; }
}

/* ── GPS Reports — print / PDF ── */
@media print {
  /* Hide everything except the report output */
  .sidebar, .top-bar, #rptGenBtn, #rptCSVBtn, #rptPrintBtn,
  #rptProgress, #rptEmpty, #rptPreset, #rptVehicle,
  label[for="rptFrom"], label[for="rptTo"],
  .screen:not(#screen-reports) { display: none !important; }

  #screen-reports { display: block !important; padding: 0; }

  /* Print header */
  #rptOutput::before {
    content: 'TrakNet GPS Activity Report';
    display: block; font-size: 18px; font-weight: 700;
    margin-bottom: 4px; color: #000;
  }

  /* Remove interactive chrome */
  button { display: none !important; }
  select, input[type="date"] { border: none; background: transparent; font-weight: 600; }

  /* Force white backgrounds and black text */
  body, .main-content, #screen-reports,
  #rptSummaryCards > div, #rptVehicleSections > div > div {
    background: #fff !important;
    color: #000 !important;
    border-color: #ccc !important;
  }

  /* Summary cards inline */
  #rptSummaryCards {
    display: flex !important;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
  }
  #rptSummaryCards > div { flex: 1; min-width: 100px; border: 1px solid #ccc; padding: 8px; }

  /* Keep trip rows readable */
  #rptVehicleSections > div { page-break-inside: avoid; margin-bottom: 20px; }
  #rptVehicleSections > div > div > div { page-break-inside: avoid; }

  a { color: inherit; text-decoration: none; }
}
