/* ==========================================================================
   RoadFloat Dashboard — app.css
   Modern, clean SaaS UI
   ========================================================================== */

/* --------------------------------------------------------------------------
   Custom properties
   -------------------------------------------------------------------------- */
:root {
  --blue:          #0070f3;
  --blue-dark:     #005ed1;
  --blue-light:    #e8f2ff;
  --green:         #10b981;
  --red:           #ef4444;
  --yellow:        #f59e0b;

  --sidebar-bg:    #0f172a;
  --sidebar-w:     240px;

  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --border:        #e2e8f0;

  --text-primary:  #0f172a;
  --text-secondary:#64748b;
  --text-muted:    #94a3b8;

  --radius:        10px;
  --radius-sm:     6px;
  --radius-lg:     16px;

  --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:        0 4px 16px rgba(0,0,0,.07);
  --shadow-lg:     0 12px 40px rgba(0,0,0,.12);

  --transition:    150ms ease;
  --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                   "Helvetica Neue", Arial, sans-serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

/* --------------------------------------------------------------------------
   Auth pages (sign-in, forgot password)
   -------------------------------------------------------------------------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 28px 40px 40px;
  animation: fadeUp .35s ease both;
}



.auth-logo .logo-mark {
  width: 40px;
  height: 40px;
  background: var(--blue);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}

.auth-logo .logo-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.auth-logo .logo-text span { color: var(--blue); }

.auth-heading-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}


.auth-heading-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  flex-shrink: 0;
}

.auth-heading {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.auth-subheading {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.auth-heading-row .auth-heading,
.auth-heading-row .auth-subheading {
  	margin-bottom:0px;
}
.auth-heading-row .auth-heading {
  	margin-bottom:-7px;
}

/* --------------------------------------------------------------------------
   Form elements
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: .01em;
}

.input-wrap {
  position: relative;
}

.input-wrap .input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
  transition: color var(--transition);
}

.form-control {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: var(--font);
  color: var(--text-primary);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}

.form-control.has-icon { padding-left: 38px; }

textarea.form-control {
  height: auto;
  padding-top: 10px;
  padding-bottom: 10px;
}

select.form-control {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,112,243,.12);
}

.form-control:focus + .input-icon,
.input-wrap:focus-within .input-icon {
  color: var(--blue);
}

.form-control.is-error { border-color: var(--red); }
.form-control.is-error:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.12); }

.field-error {
  font-size: 12px;
  color: var(--red);
  margin-top: 5px;
  display: none;
}

.field-error.visible { display: block; }

/* Toggle password visibility */
.btn-toggle-pw {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  padding: 4px;
  line-height: 1;
  transition: color var(--transition);
}
.btn-toggle-pw:hover { color: var(--text-secondary); }

/* Form extras */
.form-row-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.form-link {
  font-size: 13px;
  color: var(--blue);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background var(--transition), box-shadow var(--transition),
              border-color var(--transition), opacity var(--transition);
  white-space: nowrap;
  outline: none;
  text-decoration: none !important;
}

.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(0,112,243,.25);
}
.btn-primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  box-shadow: 0 4px 14px rgba(0,112,243,.35);
}

.btn-secondary {
  background: #fff;
  color: var(--text-primary);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { border-color: #c0cdd9; background: var(--bg); }

.btn-danger {
  background: #fff;
  color: var(--red);
  border-color: #fca5a5;
}
.btn-danger:hover { background: #fef2f2; border-color: var(--red); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

.btn-full { width: 100%; }
.btn-sm   { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-lg   { height: 50px; padding: 0 28px; font-size: 15px; }

/* Loading spinner inside button */
.btn .spinner-sm {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: none;
}
.btn.loading .spinner-sm { display: block; }
.btn.loading .btn-label   { opacity: .7; }

/* --------------------------------------------------------------------------
   Dashboard layout
   -------------------------------------------------------------------------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;        /* fallback */
  height: 100dvh;       /* iOS Safari: excludes browser chrome */
  overflow: hidden;     /* sidebar itself doesn't scroll */
  z-index: 300;
  transition: transform .25s ease;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;   /* don't compress on short screens */
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none !important;
}

.sidebar-logo .logo-mark {
  width: 36px;
  height: 36px;
  background: var(--blue);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.4px;
}

.sidebar-logo .logo-text span { color: var(--blue); }

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 12px 8px 6px;
}

/* Collapsible section header */
.nav-section-label.collapsible {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding-right: 8px;
}

.nav-section-label.collapsible:hover {
  color: rgba(255,255,255,.55);
}

.nav-section-caret {
  font-size: 9px;
  transition: transform 250ms ease;
  transform: rotate(-90deg);   /* collapsed = pointing right */
}

.nav-section-label.collapsible.open .nav-section-caret {
  transform: rotate(0deg);     /* expanded = pointing down */
}

/* Collapsible wrapper — hidden when closed */
.nav-collapsible {
  display: none;
  overflow: hidden;
}

.nav-collapsible.open {
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none !important;
  margin-bottom: 2px;
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.nav-item.active {
  background: rgba(0,112,243,.2);
  color: #fff;
}

.nav-item.active i { color: var(--blue); }

/* ── Shared pagination ─────────────────────────────────────────────────────── */
.footer-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  line-height: 1;
}
.pagination-label { font-size: 13px; color: var(--text-muted); line-height: 1; }
.footer-pagination > div { display: flex; align-items: center; gap: 8px; }


/* ── Shared list toolbar (customers, inventory, etc.) ──────────────────────── */
.list-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
.search-wrap .search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}
.search-wrap .form-control {
  padding-left: 36px;
}

/* Parent nav item with children */
.nav-item-parent { justify-content: flex-start; }
.nav-sub-caret {
  margin-left: auto;
  font-size: 11px !important;
  width: auto !important;
  transition: transform 0.2s ease;
  opacity: .5;
}
.nav-item-parent.sub-open .nav-sub-caret { transform: rotate(180deg); }

/* Sub-menu */
.nav-sub-menu {
  display: none;
  overflow: hidden;
  padding-left: 28px;
}
.nav-sub-menu.open { display: block; }
.nav-sub-item {
  font-size: 13px;
  padding: 7px 10px;
  color: rgba(255,255,255,.5);
  position: relative;
}
.nav-sub-item i { font-size: 13px !important; }
.nav-sub-item.active {
  background: none;
  color: #fff;
}
.nav-sub-item.active i { color: #fff; }
.nav-sub-item.active::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}

/* Sidebar footer / user badge */
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;   /* always visible — never scrolled off screen */
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.user-badge:hover { background: rgba(255,255,255,.07); }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue) 0%, #7c3aed 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
  text-transform: uppercase;
}

.user-info { flex: 1; min-width: 0; }

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: rgba(255,255,255,.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-badge .chevron {
  color: rgba(255,255,255,.3);
  font-size: 12px;
  transition: transform var(--transition);
}

.user-badge.open .chevron { transform: rotate(180deg); }

/* User menu popup */
.user-menu {
  display: none;
  background: #1e293b;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  padding: 6px;
  margin-bottom: 6px;
}

.user-menu.open { display: block; }

.user-menu-role {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 4px 10px 8px;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,.75);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.user-menu-item:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.user-menu-item i { width: 14px; text-align: center; }

.user-menu-signout { color: rgba(239,68,68,.8); }
.user-menu-signout:hover { background: rgba(239,68,68,.1); color: #ef4444; }

.user-menu-divider {
  height: 1px;
  background: rgba(255,255,255,.07);
  margin: 4px 0;
}

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

/* Top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 64px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.topbar-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 15px;
}
.topbar-btn:hover { background: var(--blue-light); color: var(--blue); border-color: var(--blue); }

/* Page content */
.page-content {
  flex: 1;
  padding: 32px;
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.card-body { padding: 24px; }

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* --------------------------------------------------------------------------
   Welcome / stat cards
   -------------------------------------------------------------------------- */
.welcome-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e40af 100%);
  border-radius: var(--radius);
  padding: 32px;
  color: #fff;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.welcome-banner::after {
  content: '';
  position: absolute;
  right: -40px;
  top: -40px;
  width: 200px;
  height: 200px;
  background: rgba(255,255,255,.04);
  border-radius: 50%;
}

.welcome-banner::before {
  content: '';
  position: absolute;
  right: 60px;
  bottom: -60px;
  width: 280px;
  height: 280px;
  background: rgba(255,255,255,.03);
  border-radius: 50%;
}

.welcome-greeting {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
  position: relative;
  z-index: 1;
}

.welcome-sub {
  font-size: 14px;
  opacity: .7;
  position: relative;
  z-index: 1;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue   { background: var(--blue-light);       color: var(--blue); }
.stat-icon.green  { background: #d1fae5;                  color: var(--green); }
.stat-icon.yellow { background: #fef3c7;                  color: var(--yellow); }
.stat-icon.purple { background: #ede9fe;                  color: #7c3aed; }

/* --------------------------------------------------------------------------
   Page header (title + subtitle above content)
   -------------------------------------------------------------------------- */
.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Placeholder card — empty-state for views under construction
   -------------------------------------------------------------------------- */
.placeholder-card {
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 32px;
  text-align: center;
  max-width: 480px;
}

.placeholder-icon {
  font-size: 40px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.placeholder-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.placeholder-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Setup org card — shown on home view when user has no active organization
   -------------------------------------------------------------------------- */
.setup-org-wrap {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 28px;
  margin-bottom: 28px;
}

.setup-org-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(96, 165, 250, 0.12);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.setup-org-body {
  flex: 1;
}

.setup-org-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 6px;
}

.setup-org-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 16px;
  margin-bottom:10px;
}

@media (max-width: 600px) {
  .setup-org-wrap { flex-direction: column; align-items: flex-start; }
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Section headings
   -------------------------------------------------------------------------- */
.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  align-items: start;
}

/* --------------------------------------------------------------------------
   Toast notifications  — modal-style centred popup
   -------------------------------------------------------------------------- */
#toast-container {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
}

/* Backdrop shown behind the topmost toast */
#toast-container:not(:empty)::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  animation: fadeIn .2s ease both;
}

.toast {
  position: relative;
  z-index: 1;
  background: #fff;
  color: var(--text-primary);
  padding: 40px 36px 32px;
  border-radius: 18px;
  font-size: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
  width: 320px;
  pointer-events: all;
  animation: toastPop .25s cubic-bezier(.34,1.56,.64,1) both;
}

/* Icon circle */
.toast i {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 20px;
  flex-shrink: 0;
}

/* Title (first text node rendered by Toast.show) */
.toast .toast-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.2;
}

/* Message */
.toast .toast-msg {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 28px;
}

/* OK button */
.toast .toast-ok {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: opacity .15s;
}
.toast .toast-ok:hover { opacity: .88; }

/* Colour schemes */
.toast.success i { background: #e8faf4; color: var(--green); }
.toast.success .toast-ok { background: var(--green); }

.toast.error i { background: #fef2f2; color: var(--red); }
.toast.error .toast-ok { background: var(--red); }

.toast.warning i { background: #fffbeb; color: var(--yellow); }
.toast.warning .toast-ok { background: var(--yellow); color: var(--text-primary); }

.toast.info i { background: var(--blue-light); color: var(--blue); }
.toast.info .toast-ok { background: var(--blue); }

.toast.hiding { animation: toastPop .18s cubic-bezier(.36,.07,.19,.97) reverse both; }

/* --------------------------------------------------------------------------
   Dividers & utilities
   -------------------------------------------------------------------------- */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.text-muted   { color: var(--text-muted); }
.text-success { color: var(--green); }
.text-danger  { color: var(--red); }
.text-sm      { font-size: 13px; }
.fw-600       { font-weight: 600; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-blue   { background: var(--blue-light); color: var(--blue-dark); }
.badge-gray   { background: #f1f5f9; color: var(--text-secondary); }

/* Danger zone */
.danger-zone {
  border: 1.5px solid #fca5a5;
  border-radius: var(--radius);
  padding: 20px 24px;
}

.danger-zone-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 4px;
}

.danger-zone-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Page overlay / modal backdrop */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  backdrop-filter: blur(2px);
  animation: fadeIn .2s ease;
}
.overlay.visible { display: block; }

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes toastPop {
  from { opacity: 0; transform: scale(.85); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-content { margin-left: 0; }

  .menu-toggle { display: block; }

  .page-content { padding: 20px 16px; }

  .topbar { padding: 0 16px; }

  .auth-card { padding: 36px 24px; }

  .welcome-banner { padding: 24px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }

  .section-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }

  /* Push the login card to the top of the screen on small phones */
  .auth-page {
    align-items: flex-start;
    padding-top: 32px;
  }
}

/* --------------------------------------------------------------------------
   General-purpose modal
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modal-fade-in 0.18s ease;
}

.modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15,23,42,0.18), 0 4px 16px rgba(15,23,42,0.08);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  animation: modal-slide-up 0.2s cubic-bezier(.22,.68,0,1.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
}

/* --------------------------------------------------------------------------
   Confirmation modal
   -------------------------------------------------------------------------- */

.rf-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.rf-modal-backdrop.open {
  display: flex;
  animation: modal-fade-in 0.18s ease;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.rf-modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(15,23,42,0.18), 0 4px 16px rgba(15,23,42,0.08);
  padding: 36px 32px 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  animation: modal-slide-up 0.2s cubic-bezier(.22,.68,0,1.2);
}

@keyframes modal-slide-up {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.rf-modal-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #fff1f0;
  color: #dc2626;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  border: 2px solid #fecaca;
}

.rf-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 10px;
  letter-spacing: -0.2px;
}

.rf-modal-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 28px;
}

.rf-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.rf-modal-actions .btn {
  flex: 1;
}

/* --------------------------------------------------------------------------
   Avatar upload widget
   -------------------------------------------------------------------------- */

.avatar-upload-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.avatar-upload-frame {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  cursor: pointer;
}

/* The circular avatar image / initials circle */
.avatar-upload-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #1e3a5f;
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 3px solid var(--border);
  transition: filter var(--transition);
  user-select: none;
}

.avatar-upload-img.has-photo {
  background-size: cover;
  background-position: center;
  font-size: 0; /* hide icon/initials */
}

.avatar-upload-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Camera overlay — visible on hover or during upload */
.avatar-upload-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
  color: #fff;
  font-size: 18px;
}

.avatar-upload-frame:hover .avatar-upload-overlay,
.avatar-upload-frame.uploading .avatar-upload-overlay {
  opacity: 1;
}

/* Spinning ring shown during upload — replaces the camera icon */
.avatar-upload-frame.uploading .avatar-upload-overlay {
  background: rgba(0, 0, 0, 0.6);
}

.avatar-upload-frame.uploading .fa-camera { display: none; }

.avatar-upload-spinner {
  display: none;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

.avatar-upload-frame.uploading .avatar-upload-spinner { display: block; }

.avatar-upload-meta {
  flex: 1;
  min-width: 0;
}

.avatar-upload-meta strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.avatar-upload-meta span {
  font-size: 12px;
  color: var(--text-muted);
}

.avatar-upload-btn {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--blue);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.avatar-upload-btn:hover { text-decoration: underline; }

/* Sidebar avatar — photo mode */
.user-avatar.has-photo {
  background-size: cover;
  background-position: center;
  font-size: 0;   /* hide initials text when photo is shown */
}

/* Informational tip box */
.tip {
  background: #dbeafe;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #1e40af;
  line-height: 1.6;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.tip-icon {
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 15px;
}

