/* ═══════════════════════════════════════════════════════════════════════════
   GarageOS — Shared Stylesheet
   ═══════════════════════════════════════════════════════════════════════════ */

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

:root {
  --primary:    #2563eb;
  --primary-dk: #1d4ed8;
  --secondary:  #64748b;
  --success:    #16a34a;
  --warning:    #d97706;
  --danger:     #dc2626;
  --info:       #0891b2;
  --bg:         #f1f5f9;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --text-muted: #64748b;
  --sidebar-w:  240px;
  --header-h:   56px;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; font-size: 14px; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ─── Typography ─────────────────────────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.text-lg { font-size: 1rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }

/* ─── Layout Shell ───────────────────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #1e293b;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 18px 16px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logo span { color: var(--primary); }
.sidebar-section { padding: 12px 0; border-bottom: 1px solid #334155; }
.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #475569;
  padding: 0 16px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #94a3b8;
  cursor: pointer;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
  user-select: none;
}
.nav-item:hover { background: #334155; color: #e2e8f0; }
.nav-item.active { background: #1d3461; color: #fff; border-left-color: var(--primary); }
.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-user {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid #334155;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { color: #e2e8f0; font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { color: #64748b; font-size: 0.75rem; }

/* ─── Main Area ──────────────────────────────────────────────────────────── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}
.topbar-title { font-size: 1.05rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.page-content { flex: 1; overflow-y: auto; padding: 24px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 1.3rem; font-weight: 700; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-title { font-size: .95rem; font-weight: 600; }
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); background: #f8fafc; border-radius: 0 0 var(--radius) var(--radius); }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.stat-card.danger  .stat-value { color: var(--danger); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.primary .stat-value { color: var(--primary); }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 500;
  line-height: 1.4;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--primary);   color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dk); border-color: var(--primary-dk); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger    { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-warning   { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-info      { background: var(--info);    color: #fff; border-color: var(--info); }
.btn-ghost     { background: transparent; color: var(--primary); border-color: transparent; }
.btn-ghost:hover { background: #eff6ff; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-lg { padding: 10px 20px; font-size: 1rem; }
.btn-icon { padding: 6px; border-radius: 6px; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 0.85rem; }
.form-label .required { color: var(--danger); }
.form-control {
  width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-control.is-invalid { border-color: var(--danger); }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.78rem; color: var(--danger); margin-top: 4px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 14px; text-align: left; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); background: #f8fafc; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
.table-empty { text-align: center; padding: 40px; color: var(--text-muted); }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.badge-primary  { background: #dbeafe; color: #1d4ed8; }
.badge-success  { background: #dcfce7; color: #15803d; }
.badge-warning  { background: #fef9c3; color: #854d0e; }
.badge-danger   { background: #fee2e2; color: #b91c1c; }
.badge-info     { background: #cffafe; color: #0e7490; }
.badge-secondary{ background: #f1f5f9; color: #475569; }
.badge-purple   { background: #f3e8ff; color: #7c3aed; }

/* Severity badges */
.sev-critical { background: #fee2e2; color: #991b1b; }
.sev-high     { background: #ffedd5; color: #9a3412; }
.sev-medium   { background: #fef9c3; color: #713f12; }
.sev-low      { background: #f0fdf4; color: #166534; }

/* ─── Modals ─────────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn .15s ease-out;
}
.modal-lg   { max-width: 780px; }
.modal-xl   { max-width: 1000px; }
.modal-evhc { max-width: 860px; height: min(95vh, 1100px); max-height: 95vh; }
@media (max-width: 860px) {
  .modal-evhc { max-width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .modal-backdrop { padding: 0; }
}
@keyframes modalIn { from { transform: translateY(-20px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.3rem; color: var(--text-muted); padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px;
}

/* ─── Tabs ───────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 9px 18px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); border: 1px solid; margin-bottom: 16px; font-size: 0.87rem; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-danger   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning  { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info     { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ─── Line Item Tables (Estimates / Jobs / Invoices) ─────────────────────── */
.line-table { width: 100%; border-collapse: collapse; }
.line-table th { padding: 8px 10px; background: #f8fafc; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.line-table td { padding: 6px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.line-table tfoot td { padding: 8px 10px; font-weight: 600; border-top: 2px solid var(--border); }
.line-table .line-input { width: 100%; padding: 5px 8px; border: 1px solid transparent; border-radius: 4px; background: transparent; }
.line-table .line-input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.line-table tr:hover .line-input { background: #f8fafc; border-color: var(--border); }
.totals-box { text-align: right; margin-top: 12px; }
.totals-row { display: flex; justify-content: flex-end; gap: 40px; padding: 4px 0; font-size: 0.9rem; }
.totals-row.total-final { font-size: 1.1rem; font-weight: 700; border-top: 2px solid var(--border); padding-top: 8px; margin-top: 4px; }

/* ─── Kanban Board ───────────────────────────────────────────────────────── */
.kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col {
  min-width: 240px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}
.kanban-col-header {
  padding: 12px 14px;
  font-weight: 600;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: #f8fafc; border-radius: var(--radius) var(--radius) 0 0;
}
.kanban-col-header .col-count { background: var(--border); color: var(--text-muted); font-size: 0.72rem; border-radius: 999px; padding: 1px 7px; }
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  transition: box-shadow .15s;
  box-shadow: var(--shadow);
}
.kanban-card:hover { box-shadow: var(--shadow-md); border-color: #cbd5e1; }
.kanban-card-num { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }
.kanban-card-title { font-weight: 600; font-size: 0.88rem; margin: 3px 0; }
.kanban-card-sub { font-size: 0.78rem; color: var(--text-muted); }
.kanban-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

/* ─── Diary / Week Grid ──────────────────────────────────────────────────── */
.diary-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.diary-nav h2 { flex: 1; text-align: center; }
.diary-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  grid-template-rows: auto repeat(10, 40px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.diary-header {
  background: #f8fafc;
  padding: 10px 8px;
  text-align: center;
  font-weight: 600;
  font-size: 0.8rem;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
}
.diary-header:last-child { border-right: none; }
.diary-header.today { background: #dbeafe; color: var(--primary); }
.diary-time-col {
  padding: 6px 8px;
  text-align: right;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
}
.diary-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}
.diary-cell:hover { background: #f0f9ff; }
.diary-booking {
  margin: 2px;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  overflow: hidden;
  cursor: pointer;
  z-index: 1;
  display: flex;
  align-items: flex-start;
}
.diary-booking-blue   { background: #dbeafe; color: #1e40af; border-left: 3px solid #2563eb; }
.diary-booking-green  { background: #dcfce7; color: #166534; border-left: 3px solid #16a34a; }
.diary-booking-orange { background: #ffedd5; color: #9a3412; border-left: 3px solid #f97316; }
.diary-booking-purple { background: #f3e8ff; color: #7e22ce; border-left: 3px solid #9333ea; }

/* ─── Photo Gallery ──────────────────────────────────────────────────────── */
.photo-gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photo-thumb {
  width: 80px; height: 80px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
}
.photo-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.photo-upload-area:hover { border-color: var(--primary); background: #eff6ff; }
.photo-upload-area input[type=file] { display: none; }

/* ─── Login Page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 25px 50px rgba(0,0,0,.4);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
  padding: 28px;
  text-align: center;
  color: #fff;
}
.login-header h1 { font-size: 1.6rem; margin-bottom: 4px; }
.login-header p { opacity: .8; font-size: 0.88rem; }
.login-tabs { display: flex; border-bottom: 1px solid var(--border); }
.login-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  font-size: 0.9rem;
}
.login-tab:hover { color: var(--text); }
.login-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.login-body { padding: 24px; }
.login-tab-panel { display: none; }
.login-tab-panel.active { display: block; }

/* ─── Fleet Owner / Driver Portal ────────────────────────────────────────── */
.portal-header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #fff;
  padding: 0 24px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
}
.portal-header-logo { font-size: 1.1rem; font-weight: 700; flex: 1; }
.portal-header-logo span { color: #60a5fa; }
.portal-nav { display: flex; gap: 4px; }
.portal-nav-item {
  padding: 7px 14px;
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.88rem;
  transition: background .15s, color .15s;
}
.portal-nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.portal-nav-item.active { background: var(--primary); color: #fff; }

.portal-content { padding: 24px; max-width: 1100px; margin: 0 auto; }

/* ─── Vehicle Card ───────────────────────────────────────────────────────── */
.vehicle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.vehicle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s;
}
.vehicle-card:hover { box-shadow: var(--shadow-md); }
.vehicle-card-header {
  background: #1e293b;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.vehicle-card-reg { font-size: 1.2rem; font-weight: 800; letter-spacing: .05em; }
.vehicle-card-body { padding: 14px 16px; }
.vehicle-info-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 0.85rem; }
.vehicle-info-label { color: var(--text-muted); }

/* ─── Driver Card ────────────────────────────────────────────────────────── */
.driver-vehicle-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.driver-vehicle-reg { font-size: 2rem; font-weight: 900; letter-spacing: .06em; margin-bottom: 4px; }
.driver-vehicle-desc { color: #94a3b8; font-size: 0.9rem; margin-bottom: 16px; }
.driver-vehicle-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.driver-stat { text-align: center; }
.driver-stat-val { font-size: 1.1rem; font-weight: 700; }
.driver-stat-label { font-size: 0.72rem; color: #64748b; text-transform: uppercase; letter-spacing: .04em; }

/* ─── Overdue Banner ─────────────────────────────────────────────────────── */
.overdue-banner {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}
.overdue-banner-icon { font-size: 1.3rem; }
.overdue-cta {
  border: 2px solid #dc2626 !important;
  animation: overdue-pulse 2s ease-in-out infinite;
}
@keyframes overdue-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
  50%       { box-shadow: 0 0 0 6px rgba(220,38,38,0.18); }
}

/* ─── Spinner ────────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  z-index: 10;
}

/* ─── Search Bar ─────────────────────────────────────────────────────────── */
.search-bar { position: relative; }
.search-bar .form-control { padding-left: 34px; }
.search-bar::before { content: '🔍'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 0.85rem; pointer-events: none; }

/* ─── Pagination ─────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; }
.page-btn { padding: 5px 10px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text); cursor: pointer; font-size: 0.85rem; }
.page-btn:hover { background: var(--bg); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ─── Toast Notifications ────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999;
}
.toast {
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 240px;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn .2s ease-out;
  font-size: 0.87rem;
}
.toast.success { background: #166534; }
.toast.error   { background: #991b1b; }
.toast.warning { background: #92400e; }
@keyframes slideIn { from { transform: translateX(60px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.p-4 { padding: 16px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kanban { flex-direction: column; }
  .kanban-col { min-width: unset; max-height: none; }
  .diary-grid { font-size: 0.7rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }

  /* Portal header: stack nav below logo+actions row */
  .portal-header {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 16px;
    gap: 6px;
  }
  .portal-header-logo { flex: 1; }
  .portal-nav {
    display: flex;
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 4px;
  }
  .portal-nav::-webkit-scrollbar { display: none; }
  .portal-nav-item { white-space: nowrap; flex-shrink: 0; }
  .portal-content { padding: 16px; }
}

/* ─── Incoming Call Popup ─────────────────────────────────────────────────── */
#caller-popup {
  position: fixed; bottom: 24px; left: 24px; z-index: 1100;
  width: 300px;
  background: var(--surface);
  border: 2px solid var(--success);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  overflow: hidden;
  animation: callerIn .25s ease-out;
}
@keyframes callerIn { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.caller-popup-header {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--success); color: #fff;
  font-weight: 600; font-size: .85rem;
}
.caller-popup-ring   { font-size: 1.1rem; display: inline-block; animation: ring .5s infinite alternate; }
@keyframes ring { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }
.caller-popup-label  { flex: 1; }
.caller-popup-close  {
  background: none; border: none; color: rgba(255,255,255,.75);
  font-size: 1.1rem; cursor: pointer; padding: 0 4px; border-radius: 4px;
}
.caller-popup-close:hover { color: #fff; background: rgba(255,255,255,.2); }
.caller-popup-body    { padding: 12px 14px 6px; }
.caller-popup-name    { font-size: 1rem; font-weight: 700; color: var(--text); }
.caller-popup-phone   { font-size: .88rem; color: var(--text-muted); margin-top: 3px; }
.caller-popup-unknown { font-size: .8rem; color: var(--text-muted); margin-top: 6px; font-style: italic; }
.caller-popup-footer  { padding: 8px 14px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.caller-popup-timer   { font-size: .75rem; color: var(--text-muted); flex-shrink: 0; }
