:root {
    --bg: #181f25;
    --bg-deep: #0b1220;
    --surface: rgba(15, 23, 42, 0.82);
    --surface-alt: rgba(30, 41, 59, 0.88);
    --surface-strong: rgba(15, 23, 42, 0.92);
    --line: rgba(148, 163, 184, 0.2);
    --line-strong: rgba(14, 165, 233, 0.3);
    --text: #e5e7eb;
    --muted: #94a3b8;
    --accent: #0ea5e9;
    --accent-dark: #0284c7;
    --accent-soft: rgba(14, 165, 233, 0.12);
    --success: #34d399;
    --danger: #f87171;
    --shadow: 0 22px 54px rgba(2, 6, 23, 0.36);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --font-display: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    --font-body: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(14, 165, 233, 0.18), transparent 26%),
        radial-gradient(circle at 85% 12%, rgba(59, 130, 246, 0.16), transparent 22%),
        linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 100%);
}

body.auth-page {
    display: grid;
    place-items: center;
    padding: 32px 18px;
}

.auth-shell-embedded {
    margin: 24px auto 40px;
}

.auth-shell {
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 24px;
}

.auth-shell-single {
    grid-template-columns: 1fr;
    max-width: 760px;
}

.auth-hero,
.auth-panel,
.sidebar,
.panel-card,
.stat-card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.auth-hero,
.auth-panel {
    border-radius: var(--radius-xl);
    padding: 38px;
}

.wide-panel {
    width: 100%;
}

.eyebrow {
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 12px;
    color: var(--accent);
    font-weight: 700;
}

.auth-hero h1,
.brand-block h1,
.page-header h2,
.panel-head h2 {
    margin: 0;
    font-family: var(--font-display);
    line-height: 1.02;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.auth-hero h1 {
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    max-width: 10ch;
}

.hero-copy,
.panel-head p,
.muted-line {
    color: var(--muted);
    line-height: 1.6;
}

.hero-card {
    margin-top: 30px;
    padding: 24px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), rgba(30, 41, 59, 0.86));
    border: 1px solid rgba(14, 165, 233, 0.16);
}

.setup-result {
    margin-top: 20px;
}

.setup-line {
    margin: 6px 0;
}

.hero-kicker {
    display: inline-block;
    margin-bottom: 10px;
    font-weight: 700;
    color: #7dd3fc;
}

.hero-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text);
    line-height: 1.8;
}

.panel-head {
    margin-bottom: 26px;
}

.panel-badge,
.header-chip,
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 8px 14px;
    background: var(--accent-soft);
    color: #7dd3fc;
    border: 1px solid rgba(14, 165, 233, 0.22);
    font-size: 13px;
    font-weight: 700;
}

.stack-form {
    display: grid;
    gap: 16px;
}

.stack-form label {
    display: grid;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.stack-form input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.86);
    padding: 14px 16px;
    font-size: 15px;
    color: var(--text);
}

.stack-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.86);
    padding: 14px 16px;
    font-size: 15px;
    color: var(--text);
    resize: vertical;
    min-height: 120px;
    font-family: var(--font-body);
}

.stack-form input::placeholder,
.stack-form textarea::placeholder,
.toolbar-row input::placeholder {
    color: rgba(148, 163, 184, 0.82);
}

.stack-form input:focus,
.stack-form textarea:focus {
    outline: 2px solid rgba(14, 165, 233, 0.18);
    border-color: rgba(14, 165, 233, 0.45);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.08);
}

.primary-button,
.ghost-button {
    border: none;
    border-radius: 16px;
    padding: 14px 18px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
    background: linear-gradient(135deg, var(--accent) 0%, #38bdf8 100%);
    color: #fff;
    box-shadow: 0 14px 28px rgba(14, 165, 233, 0.26);
}

.ghost-button {
    background: rgba(30, 41, 59, 0.72);
    color: var(--text);
    border: 1px solid var(--line);
}

.primary-button:hover,
.ghost-button:hover {
    transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled {
    cursor: wait;
    opacity: 0.7;
    transform: none;
}

.primary-button:hover {
    box-shadow: 0 18px 34px rgba(14, 165, 233, 0.32);
}

.whatsapp-button {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    box-shadow: 0 14px 28px rgba(37, 211, 102, 0.28);
}

.whatsapp-button:hover {
    box-shadow: 0 18px 34px rgba(37, 211, 102, 0.34);
}

.ghost-button:hover {
    background: rgba(14, 165, 233, 0.1);
    border-color: rgba(14, 165, 233, 0.28);
}

.form-message {
    margin: 14px 0 0;
    min-height: 22px;
    color: var(--muted);
}

body.dashboard-page footer {
    padding-top: 20px !important;
    padding-bottom: 20px !important;
}

body.dashboard-page footer .footer-logos {
    display: none !important;
}

.dashboard-page {
    padding: 22px;
}

.dashboard-shell-embedded {
    margin: 8px auto 40px;
}

.dashboard-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 22px;
    align-items: start;
}

.sidebar {
    border-radius: 30px;
    padding: 26px 22px;
    min-height: calc(100vh - 44px);
    position: sticky;
    top: 22px;
    background:
        linear-gradient(180deg, rgba(14, 165, 233, 0.08) 0%, rgba(15, 23, 42, 0.95) 18%),
        var(--surface-strong);
}

.sidebar-nav {
    display: grid;
    gap: 10px;
    margin: 26px 0 24px;
}

.sidebar-nav a {
    color: var(--text);
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid var(--line);
    font-weight: 600;
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.is-active {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.18), rgba(30, 41, 59, 0.9));
    border-color: rgba(14, 165, 233, 0.42);
    color: #fff;
    transform: translateY(-1px);
}

.content-area {
    display: grid;
    gap: 18px;
}

.content-switcher {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin: 2px 0 4px;
}

.inline-mode-switch {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.switch-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.72);
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.14);
    transition: background 160ms ease, color 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.switch-chip:hover,
.switch-chip.is-active {
    background: linear-gradient(135deg, var(--accent) 0%, #38bdf8 100%);
    color: #fff;
    border-color: transparent;
    transform: translateY(-1px);
}

.page-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 18px;
    padding: 10px 4px;
}

.page-header h2 {
    font-size: clamp(2rem, 3vw, 3rem);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat-card,
.panel-card {
    border-radius: 24px;
    padding: 22px;
}

.panel-card {
    background: var(--surface-strong);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 14px;
}

.stat-card strong {
    display: block;
    margin-top: 10px;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    font-family: var(--font-display);
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::before,
.panel-card::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.65), transparent 56%);
    pointer-events: none;
}

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

.module-stack {
    display: none;
}

.module-stack.is-active {
    display: grid;
    animation: module-fade-in 180ms ease;
}

.visits-module-grid {
    grid-template-columns: minmax(0, 1.4fr) minmax(360px, 0.92fr);
    align-items: start;
}

.visit-primary-card {
    min-width: 0;
}

.visits-side-stack {
    display: grid;
    gap: 16px;
    align-self: start;
    min-width: 0;
}

.side-card {
    min-width: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-grid-full {
    grid-column: 1 / -1;
    display: grid;
    gap: 10px;
}

.wide-card {
    grid-column: 1 / -1;
}

.section-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.compact-head {
    margin-bottom: 12px;
}

.section-head h3 {
    margin: 0;
    font-size: 1.5rem;
    font-family: var(--font-display);
}

.section-head h4 {
    margin: 0;
    font-size: 1.15rem;
    font-family: var(--font-display);
}

.toolbar-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar-row input,
.stack-form select,
.select-inline {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.86);
    padding: 14px 16px;
    font-size: 15px;
    color: var(--text);
}

.toolbar-row input {
    flex: 1 1 280px;
}

.followup-toolbar {
    align-items: end;
}

.followup-control {
    display: grid;
    gap: 8px;
    min-width: 180px;
    font-size: 14px;
    font-weight: 600;
}

.followup-control input {
    width: 100%;
}

.followup-toggle {
    min-height: 52px;
    padding: 0 2px;
}

.toolbar-row input:focus,
.stack-form select:focus,
.select-inline:focus {
    outline: 2px solid rgba(14, 165, 233, 0.18);
    border-color: rgba(14, 165, 233, 0.45);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.08);
}

.list-shell,
.cards-list {
    display: grid;
    gap: 12px;
}

#recentVisits,
#rewardsList,
#servicesList,
#locationsList,
#customersList,
#followUpList,
#customerVehiclesList,
#customerVisitsList,
#customerRewardsList,
#visitCustomerSearchResults,
#customerFollowUpHistory,
#salesByDayReport,
#topServicesReport,
#topCustomersReport {
    max-height: 420px;
    overflow: auto;
    padding-right: 4px;
}

#recentVisits {
    max-height: 320px;
}

#customerFollowUpHistory {
    max-height: 320px;
}

#salesByDayReport {
    max-height: 320px;
}

#topServicesReport,
#topCustomersReport {
    max-height: 260px;
}

.visit-row,
.location-card {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.64);
}

.visit-row {
    display: grid;
    grid-template-columns: 1.3fr auto auto;
    gap: 12px;
    align-items: center;
}

.visit-meta,
.location-meta {
    color: var(--muted);
    font-size: 14px;
}

.location-card {
    display: grid;
    gap: 12px;
}

.followup-body {
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--text);
    font-size: 14px;
}

.customer-card {
    display: grid;
    gap: 12px;
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.64);
}

.customer-card-selected {
    border-color: rgba(14, 165, 233, 0.45);
    box-shadow: 0 10px 24px rgba(14, 165, 233, 0.12);
}

.service-meta-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.select-inline {
    min-width: 180px;
}

.compact-button {
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 12px;
}

.visit-customer-toolbar {
    margin-bottom: 0;
}

.visit-customer-choice {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.visit-customer-choice strong {
    display: block;
    margin-bottom: 4px;
}

.location-headline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.location-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.customer-headline {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.customer-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.mini-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 11px;
    background: rgba(14, 165, 233, 0.1);
    color: #bae6fd;
    font-size: 12px;
    font-weight: 700;
}

.link-button {
    border: none;
    background: transparent;
    color: #7dd3fc;
    cursor: pointer;
    font-weight: 700;
    padding: 0;
}

.empty-state {
    padding: 18px;
    border-radius: 18px;
    border: 1px dashed var(--line);
    color: var(--muted);
    background: rgba(15, 23, 42, 0.4);
}

.compact-form {
    gap: 14px;
}

.inline-toggle {
    display: flex !important;
    align-items: center;
    gap: 10px !important;
}

.inline-toggle input {
    width: auto;
}

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hidden-button {
    display: none;
}

.is-success {
    color: var(--success);
}

.is-error {
    color: var(--danger);
}

.hidden-section {
    display: none;
}

.detail-summary {
    margin-bottom: 16px;
}

.detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.compact-note {
    padding: 14px 16px;
    font-size: 13px;
    line-height: 1.6;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.detail-block {
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(30, 41, 59, 0.42);
}

.compact-quick-panel {
    padding: 16px 18px;
}

.quick-service-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.quick-service-button {
    display: grid;
    gap: 6px;
    align-items: start;
    text-align: left;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.72);
    color: var(--text);
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.quick-service-button strong {
    font-size: 15px;
}

.quick-service-button span,
.quick-service-button small {
    color: var(--muted);
}

.quick-service-button:hover,
.quick-service-button.is-active {
    transform: translateY(-1px);
    border-color: rgba(14, 165, 233, 0.42);
    background: rgba(14, 165, 233, 0.12);
    box-shadow: 0 12px 24px rgba(14, 165, 233, 0.12);
}

.reports-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.report-toolbar {
    align-items: center;
    justify-content: flex-end;
}

.report-block {
    display: grid;
    gap: 12px;
}

.report-list {
    gap: 10px;
}

.report-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.64);
}

.report-row strong:last-child {
    flex: 0 0 auto;
    text-align: right;
}

.report-summary-grid .summary-item strong {
    line-height: 1.35;
}

.visits-side-stack .reports-grid {
    grid-template-columns: 1fr;
}

.visits-side-stack .report-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.summary-item {
    padding: 14px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid var(--line);
}

.summary-item span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.summary-item strong {
    font-size: 1.1rem;
}

.scroll-top-button {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 60;
    border: none;
    border-radius: 999px;
    min-width: 110px;
    min-height: 48px;
    padding: 0 18px;
    background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.02em;
    box-shadow: 0 18px 36px rgba(14, 165, 233, 0.24);
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.navbar.bg-dark {
    background: rgba(11, 18, 32, 0.92) !important;
    backdrop-filter: blur(12px);
}

.navbar-brand,
.navbar .nav-link.active,
.navbar .nav-link:hover {
    color: var(--accent) !important;
}

.navbar .nav-link {
    color: var(--text) !important;
}

.navbar .btn-outline-info {
    border-color: var(--accent);
    color: var(--accent);
}

.navbar .btn-outline-info:hover {
    background: var(--accent);
    color: #fff;
}

#recentVisits::-webkit-scrollbar,
#rewardsList::-webkit-scrollbar,
#servicesList::-webkit-scrollbar,
#locationsList::-webkit-scrollbar,
#customersList::-webkit-scrollbar,
#followUpList::-webkit-scrollbar,
#customerVehiclesList::-webkit-scrollbar,
#customerVisitsList::-webkit-scrollbar,
#customerRewardsList::-webkit-scrollbar,
#visitCustomerSearchResults::-webkit-scrollbar,
#customerFollowUpHistory::-webkit-scrollbar,
#salesByDayReport::-webkit-scrollbar,
#topServicesReport::-webkit-scrollbar,
#topCustomersReport::-webkit-scrollbar {
    width: 10px;
}

#recentVisits::-webkit-scrollbar-thumb,
#rewardsList::-webkit-scrollbar-thumb,
#servicesList::-webkit-scrollbar-thumb,
#locationsList::-webkit-scrollbar-thumb,
#customersList::-webkit-scrollbar-thumb,
#followUpList::-webkit-scrollbar-thumb,
#customerVehiclesList::-webkit-scrollbar-thumb,
#customerVisitsList::-webkit-scrollbar-thumb,
#customerRewardsList::-webkit-scrollbar-thumb,
#visitCustomerSearchResults::-webkit-scrollbar-thumb,
#customerFollowUpHistory::-webkit-scrollbar-thumb,
#salesByDayReport::-webkit-scrollbar-thumb,
#topServicesReport::-webkit-scrollbar-thumb,
#topCustomersReport::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.34);
    border-radius: 999px;
}

.scroll-top-button.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

@keyframes module-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 980px) {
    .auth-shell,
    .dashboard-shell,
    .visits-module-grid,
    .panel-grid,
    .stats-grid,
    .detail-grid,
    .summary-grid,
    .reports-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
        position: static;
    }

    .content-switcher {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }

    .switch-chip {
        flex: 0 0 auto;
    }

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

    .visit-row {
        grid-template-columns: 1fr;
    }

    .quick-service-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .visits-side-stack .report-summary-grid {
        grid-template-columns: 1fr;
    }

    .scroll-top-button {
        right: 16px;
        bottom: 16px;
        min-width: 96px;
    }
}
