body { background: var(--paper); }

/* ---- Auth screens (split layout) ---- */
.auth-screen { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-brand-panel { background: var(--black); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-brand-panel::before { content: ''; position: absolute; width: 500px; height: 500px; border-radius: 50%; background: radial-gradient(circle, rgba(1,255,219,0.16), transparent 70%); top: -180px; right: -180px; }
.auth-brand-logo-link { display: inline-block; position: relative; z-index: 1; }
.auth-brand-logo { height: auto; width: 65px; aspect-ratio: 184 / 85; filter: brightness(0) invert(1); display: block; }
.auth-mobile-logo-link { display: inline-block; }
.auth-brand-quote { position: relative; z-index: 1; }
.auth-brand-quote h2 { font-family: var(--font-display); font-weight: 500; font-size: 32px; line-height: 1.25; letter-spacing: -0.01em; max-width: 420px; }
.auth-brand-quote p { color: rgba(255,255,255,0.55); font-size: 13.5px; margin-top: 16px; }
.auth-brand-stats { display: flex; gap: 32px; position: relative; z-index: 1; }
.auth-brand-stats div { display: flex; flex-direction: column; }
.auth-brand-stats strong { font-family: var(--font-display); font-size: 24px; font-weight: 500; color: var(--mint); }
.auth-brand-stats span { font-size: 11.5px; color: rgba(255,255,255,0.5); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

.auth-form-panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-card { width: 100%; max-width: 400px; border: none; box-shadow: none; padding: 0; }
.auth-mobile-logo { display: none; height: 28px; width: auto; aspect-ratio: 184 / 85; margin-bottom: 28px; }
.auth-title { font-family: var(--font-display); font-weight: 500; font-size: 27px; margin-bottom: 6px; letter-spacing: -0.01em; }
.auth-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.auth-switch { text-align: center; margin-top: 22px; font-size: 13.5px; color: var(--text-muted); }
.auth-switch a { color: var(--black); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.demo-hint { margin-top: 18px; padding: 12px 14px; background: var(--mint-tint); border-radius: var(--radius-sm); font-size: 12px; color: var(--mint-deep); font-weight: 600; }

.role-toggle { display: flex; gap: 8px; margin-bottom: 20px; background: var(--stone-100); padding: 4px; border-radius: var(--radius-sm); }
.role-toggle button { flex: 1; padding: 8px; border: none; background: transparent; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 13.5px; color: var(--text-muted); }
.role-toggle button.active { background: #fff; color: var(--black); box-shadow: var(--shadow-sm); }

/* ---- App shell ---- */
.app-shell { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 26px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar-logo-img { height: 26px; width: auto; aspect-ratio: 184 / 85; padding: 0 10px 30px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.sidebar-nav a { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; color: var(--text-muted); display: flex; align-items: center; gap: 12px; }
.sidebar-nav a:hover { background: var(--paper); color: var(--text); }
.sidebar-nav a.active { background: var(--black); color: #fff; }
.sidebar-nav a.active .icon { color: var(--mint); }

.nav-badge { background: var(--mint); color: var(--black); font-size: 11px; font-weight: 800; line-height: 1; padding: 3px 7px; border-radius: 999px; }

/* Mobile-only drawer controls (hamburger + backdrop) — hidden on desktop, see the ≤900px media query below for the sidebar's fixed/off-canvas behavior. */
.topbar-menu-btn { display: none; width: 38px; height: 38px; border-radius: 50%; align-items: center; justify-content: center; color: var(--text-muted); background: transparent; border: 1px solid var(--border); cursor: pointer; padding: 0; flex-shrink: 0; }
.topbar-menu-btn:hover { background: var(--paper); color: var(--text); }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(10,10,10,0.5); z-index: 105; }
.sidebar-backdrop.open { display: block; }
body.sidebar-open-lock { overflow: hidden; }

.content-col { display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }
.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 14px 44px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.topbar-bell { position: relative; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-muted); background: transparent; border: 1px solid var(--border); cursor: pointer; padding: 0; flex-shrink: 0; }
.topbar-bell:hover { background: var(--paper); color: var(--text); }
.topbar-bell .nav-badge { position: absolute; top: -3px; right: -3px; margin-left: 0; }
.topbar-user { position: relative; }
.topbar-user-btn { display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px; border-radius: 999px; border: 1px solid var(--border); background: transparent; cursor: pointer; }
.topbar-user-btn:hover { background: var(--paper); }
.topbar-user-btn strong { font-size: 13.5px; font-weight: 700; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user-btn .icon { color: var(--text-muted); }
.topbar-dropdown { position: absolute; top: calc(100% + 8px); right: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); min-width: 190px; padding: 6px; z-index: 30; display: none; }
.topbar-dropdown.open { display: block; }
.topbar-dropdown a, .topbar-dropdown button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; color: var(--text); background: none; border: none; text-align: left; cursor: pointer; }
.topbar-dropdown a:hover, .topbar-dropdown button:hover { background: var(--paper); }
.topbar-dropdown-divider { height: 1px; background: var(--border); margin: 5px 2px; }
.avatar-img { border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-initials { border-radius: 50%; background: var(--black); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }

.main-content { padding: 36px 44px; max-width: 1120px; min-width: 0; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; flex-wrap: wrap; gap: 12px; }
.page-title { font-family: var(--font-display); font-size: 28px; font-weight: 500; margin: 0 0 5px; letter-spacing: -0.01em; }
.page-sub { color: var(--text-muted); font-size: 14.5px; margin: 0; }

.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 32px; }
.stat-cards-4 { grid-template-columns: repeat(4, 1fr); }
.stat-card { padding: 22px; }
.stat-card .stat-label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; }
.stat-card .stat-value { font-family: var(--font-display); font-size: 28px; font-weight: 500; }

.booking-list { display: flex; flex-direction: column; gap: 12px; }
.booking-row { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; gap: 16px; flex-wrap: wrap; transition: box-shadow 0.15s ease, border-color 0.15s ease; }
.booking-row.booking-row-clickable:hover { box-shadow: var(--shadow-md); border-color: var(--stone-300); }
.booking-row .br-main { display: flex; flex-direction: column; gap: 4px; }
.booking-row .br-ref { font-weight: 700; font-size: 14.5px; }
.booking-row .br-meta { font-size: 13px; color: var(--text-muted); }
.booking-row .br-right { display: flex; align-items: center; gap: 14px; }
.booking-row .br-price { font-weight: 700; font-family: var(--font-display); font-size: 16px; }

.empty-state { text-align: center; padding: 64px 20px; color: var(--text-muted); }
.empty-state .empty-icon { width: 44px; height: 44px; margin: 0 auto 16px; color: var(--stone-300); }
.empty-state h3 { font-family: var(--font-display); font-weight: 500; font-size: 18px; margin-bottom: 6px; color: var(--text); }

.wizard-steps { display: flex; gap: 8px; margin-bottom: 28px; }
.wizard-step { flex: 1; height: 5px; border-radius: 4px; background: var(--stone-200); }
.wizard-step.active, .wizard-step.done { background: var(--black); }
.wizard-step.done { background: var(--mint-deep); }

.move-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.move-type-option { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 18px; cursor: pointer; text-align: center; background: var(--surface); transition: all 0.15s ease; }
.move-type-option:hover { border-color: var(--stone-300); }
.move-type-option.selected { border-color: var(--black); background: var(--stone-100); }
.move-type-option .mt-name { font-weight: 700; font-size: 14px; }
.move-type-option .mt-price { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

.extras-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 24px; }
.extra-option { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 13px 15px; cursor: pointer; font-size: 14px; transition: all 0.15s ease; }
.extra-option:hover { border-color: var(--stone-300); }
.extra-option.selected { border-color: var(--black); background: var(--stone-100); }

.quote-summary { background: var(--black); color: #fff; border-radius: var(--radius-md); padding: 26px; margin: 20px 0; }
.quote-summary .qs-row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; color: rgba(255,255,255,0.72); }
.quote-summary .qs-total { display: flex; justify-content: space-between; padding-top: 14px; margin-top: 8px; border-top: 1px solid rgba(255,255,255,0.15); font-weight: 700; font-size: 20px; font-family: var(--font-display); color: var(--mint); }

.budget-options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.budget-card { border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: 22px; cursor: pointer; transition: all 0.15s ease; }
.budget-card:hover { border-color: var(--stone-300); }
.budget-card.selected { border-color: var(--black); background: var(--stone-100); }
.budget-card h4 { margin: 0 0 6px; font-family: var(--font-sans); font-size: 15px; font-weight: 700; }

.offer-card { padding: 20px 22px; margin-bottom: 12px; transition: box-shadow 0.15s ease; }
.offer-card.is-best { border-color: var(--mint-deep); box-shadow: 0 0 0 1.5px var(--mint-deep); }
.offer-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.offer-driver { font-weight: 700; font-size: 15px; }
.offer-meta { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.offer-amount { font-family: var(--font-display); font-size: 24px; font-weight: 500; color: var(--black); }
.offer-actions { display: flex; gap: 8px; margin-top: 14px; }

.wizard-nav { display: flex; justify-content: space-between; margin-top: 26px; }

.tracker { display: flex; flex-direction: column; gap: 0; margin: 24px 0; }
.tracker-item { display: flex; gap: 14px; padding-bottom: 26px; position: relative; }
.tracker-item:last-child { padding-bottom: 0; }
.tracker-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--stone-200); flex-shrink: 0; margin-top: 3px; z-index: 1; }
.tracker-item.done .tracker-dot { background: var(--mint-deep); }
.tracker-item.current .tracker-dot { background: var(--black); box-shadow: 0 0 0 4px var(--stone-100); }
.tracker-line { position: absolute; left: 6px; top: 16px; bottom: -8px; width: 2px; background: var(--stone-200); }
.tracker-item:last-child .tracker-line { display: none; }
.tracker-item.done .tracker-line { background: var(--mint-deep); }
.tracker-label { font-weight: 700; font-size: 14px; }
.tracker-time { font-size: 12px; color: var(--text-muted); }

.star-rating { display: flex; gap: 6px; font-size: 30px; cursor: pointer; }
.star-rating span { color: var(--stone-200); transition: color 0.1s ease; }
.star-rating span.filled { color: var(--mint-deep); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(10,10,10,0.55); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 20px; backdrop-filter: blur(2px); }
.modal-card { width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; border-radius: var(--radius-lg); }

.pending-quote-banner { background: var(--mint-tint); border: 1.5px solid var(--mint-deep); border-radius: var(--radius-md); padding: 16px 20px; margin-bottom: 24px; display: flex; align-items: center; gap: 14px; }
.pending-quote-banner .icon { color: var(--mint-deep); }
.pending-quote-banner strong { display: block; font-size: 14px; }
.pending-quote-banner span { font-size: 13px; color: var(--mint-deep); }

@media (max-width: 900px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-brand-panel { display: none; }
  .auth-mobile-logo { display: block; }
  .app-shell { grid-template-columns: 1fr; }
  /* Sidebar becomes an off-canvas drawer (slides in from the left over a
     backdrop) instead of a labelless horizontally-scrolling icon row — the
     nav keeps its normal column layout with full icon+label rows, same as
     desktop, since the drawer has the full width to itself. Admin has 13
     nav items, so this is the only mobile pattern that scales here. */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 280px; max-width: 82vw;
    transform: translateX(-100%); transition: transform 0.25s ease; z-index: 110;
    box-shadow: var(--shadow-lg); overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar { padding: 12px 18px; }
  .topbar-menu-btn { display: flex; margin-right: auto; }
  .topbar-user-btn strong { display: none; }
  .main-content { padding: 18px; }
  /* The 8-metric overview block keeps a compact 2-up grid; the earnings
     block has long sentence-length labels ("Colectar commission (15% of
     completed moves)") that need the full row width, so it stacks to 1. */
  .stat-cards-4 { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-cards-4 .stat-card { padding: 12px 10px; }
  .stat-cards-4 .stat-card .stat-label { font-size: 10.5px; margin-bottom: 4px; }
  .stat-cards-4 .stat-card .stat-value { font-size: 18px; }
  .stat-cards:not(.stat-cards-4), .move-type-grid, .extras-grid, .budget-options { grid-template-columns: 1fr; }
  /* minmax(0, 1fr), not a bare 1fr: a grid track's automatic minimum is its
     content's min-content size, and a .table-wrap's min-content is the whole
     unscrolled table. A bare 1fr therefore stretches the column - and the
     page with it - to the width of the widest table, which is what made the
     admin pages pan sideways on a phone. */
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Admin-specific additions ---- */
.qs-row { padding: 10px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.qs-row:last-child { border-bottom: none; }

.admin-doc-list { display: flex; flex-direction: column; }
.admin-doc-row { display: flex; align-items: center; gap: 16px; padding: 16px 4px; border-bottom: 1px solid var(--border); }
.admin-doc-row:last-child { border-bottom: none; }
.admin-doc-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.admin-doc-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-doc-title-row .doc-name { font-weight: 700; font-size: 14px; }
.admin-doc-actions { flex: 0 0 auto; }
@media (max-width: 640px) {
  .admin-doc-row { flex-wrap: wrap; }
  .admin-doc-actions { width: 100%; }
}

.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { text-align: left; padding: 11px 16px; color: var(--text-muted); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1.5px solid var(--border); }
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--paper); }
.table-card { padding: 0; overflow-x: auto; position: relative; }
.data-table th.sticky-col, .data-table td.sticky-col { position: sticky; right: 0; background: var(--surface); box-shadow: -8px 0 10px -8px rgba(10,10,10,0.15); }
.data-table tr:hover td.sticky-col { background: var(--paper); }
.table-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 18px 20px; flex-wrap: wrap; }
.action-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions { position: relative; display: inline-block; }
.row-actions-btn { padding: 6px 8px; }
.row-actions-menu { position: fixed; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); min-width: 190px; padding: 6px; z-index: 1500; display: none; }
.row-actions-menu.open { display: block; }
.row-actions-menu button, .row-actions-menu a { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; color: var(--text); background: none; border: none; text-align: left; cursor: pointer; white-space: nowrap; }
.row-actions-menu button:hover, .row-actions-menu a:hover { background: var(--paper); }
.row-actions-menu button.danger { color: var(--color-danger); }
.row-actions-menu-divider { height: 1px; background: var(--border); margin: 5px 2px; }
.admin-tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-tabs a { padding: 9px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 700; background: var(--stone-100); color: var(--text-muted); }
.admin-tabs a.active { background: var(--black); color: #fff; }
.admin-subtabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1.5px solid var(--border); flex-wrap: wrap; }
.admin-subtabs a { padding: 9px 14px; font-size: 13px; font-weight: 700; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1.5px; }
.admin-subtabs a:hover { color: var(--text); }
.admin-subtabs a.active { color: var(--black); border-bottom-color: var(--black); }
.config-section { margin-bottom: 32px; }
.config-section h3 { margin-bottom: 14px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.inline-form .form-group { margin-bottom: 0; min-width: 140px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; }

/* ---- Analytics page (#/analytics) ----
   The page is a narrative, so the styling leans on two devices: a funnel
   whose bar widths are proportional to volume (so a collapse is visible
   before you read a single number), and colour-coded callouts that name the
   likely cause when a symptom has more than one explanation. ---- */
/* Tables inside an analytics .card scroll horizontally rather than pushing
   the page wider. (.table-card can't be reused here - that variant zeroes
   the card padding, which these mixed text+table cards still need.) */
/* min-width: 0 so this can actually shrink inside a flex/grid parent; without
   it the scroll container reports the full table width as its minimum. */
.table-wrap { min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

.an-rangebar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.an-rangebar .form-input { width: auto; min-width: 150px; }

.an-h { margin: 30px 0 12px; font-size: 15px; font-weight: 700; letter-spacing: 0.02em; color: var(--text-muted); text-transform: uppercase; }

.an-story { border-left: 4px solid var(--mint-deep); }
.an-story p { font-size: 14.5px; line-height: 1.6; }

/* Diagnosis callout. The two variants deliberately look different: a supply
   problem and a driver problem need different people to act on them. */
.an-callout { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.55; font-weight: 600; }
.an-callout-card { padding: 16px 18px; font-size: 13.5px; line-height: 1.55; font-weight: 600; }
.an-callout-driver, .an-callout.an-callout-driver { background: #FFF4E5; border: 1px solid #F0C36D; color: #7A4B00; }
.an-callout-supply, .an-callout.an-callout-supply { background: #FDECEA; border: 1px solid #F5A9A0; color: #8A1F12; }

/* Funnel: label | proportional bar | count | % of previous step. */
.an-funnel { display: flex; flex-direction: column; gap: 10px; }
.an-funnel-row { display: grid; grid-template-columns: 170px 1fr 60px 54px; align-items: center; gap: 12px; }
.an-funnel-label { font-size: 13px; font-weight: 600; color: var(--text); }
.an-funnel-track { background: var(--stone-100, #F5F5F4); border-radius: 6px; height: 26px; overflow: hidden; }
.an-funnel-bar { height: 100%; background: var(--mint-deep); border-radius: 6px; transition: width 0.3s ease; min-width: 3px; }
/* Losing more than half the previous step is the thing worth looking at. */
.an-funnel-bar.weak { background: #E8834A; }
.an-funnel-count { font-family: var(--font-display); font-size: 17px; font-weight: 500; text-align: right; }
.an-funnel-pct { font-size: 12px; font-weight: 700; color: var(--text-muted); text-align: right; }
.an-funnel-pct.weak { color: #C0561F; }

/* Record-level tables: route, device, and the hour-of-day bars. */
.an-route { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.an-route-end { display: inline-flex; flex-direction: column; line-height: 1.25; }
.an-route-end em { font-style: normal; font-size: 11px; color: var(--text-faint); }
.an-route-arrow { color: var(--text-faint); font-weight: 400; }
.an-device { white-space: nowrap; font-size: 12.5px; text-transform: capitalize; }

.an-bars { display: flex; flex-direction: column; gap: 5px; }
.an-bar-row { display: grid; grid-template-columns: 44px 1fr 38px; align-items: center; gap: 8px; }
.an-bar-label { font-size: 12px; color: var(--text-muted); }
.an-bar-track { background: var(--stone-100, #F5F5F4); border-radius: 4px; height: 14px; overflow: hidden; }
.an-bar-fill { display: block; height: 100%; background: var(--mint-deep); border-radius: 4px; }
.an-bar-n { font-size: 12px; font-weight: 700; text-align: right; }

.an-delta { display: block; margin-top: 6px; font-size: 11.5px; font-weight: 700; }
.an-delta.up { color: var(--mint-deep); }
.an-delta.down { color: #C0561F; }

@media (max-width: 900px) {
  /* The bar stops being readable this narrow; drop it and keep the numbers,
     which is what the funnel is actually for on a phone. */
  .an-funnel-row { grid-template-columns: 1fr 58px 50px; }
  .an-funnel-track { display: none; }
  .an-rangebar .form-input { flex: 1 1 130px; min-width: 0; }
}
