/* ============================================================
   Fahrschule Schnoor — Website-Statistik Dashboard
   Design System & Stylesheet
   ============================================================ */

/* --- Custom Properties ------------------------------------ */
:root {
    --color-primary:       #db2723;
    --color-primary-hover: #c4201c;
    --color-primary-light: #fde8e8;
    --color-secondary:     #214462;
    --color-secondary-dark:#1a3650;
    --color-bg:            #f2f2f2;
    --color-card:          #ffffff;
    --color-text:          #1f2120;
    --color-text-light:    #6c757d;
    --color-text-inverse:  #ffffff;
    --color-success:       #28a745;
    --color-success-bg:    #d4edda;
    --color-danger:        #dc3545;
    --color-danger-bg:     #f8d7da;
    --color-warning:       #ffc107;
    --color-warning-bg:    #fff3cd;
    --color-border:        #dee2e6;
    --color-border-light:  #e9ecef;
    --radius:              8px;
    --radius-sm:           4px;
    --radius-lg:           12px;
    --radius-full:         100px;
    --shadow-sm:           0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow:              0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
    --shadow-lg:           0 4px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
    --shadow-xl:           0 8px 32px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
    --font-family:         system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono:           ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, monospace;
    --transition:          150ms ease-in-out;
    --transition-slow:     250ms ease;
    --header-height:       60px;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

ul, ol {
    list-style: none;
}

table {
    border-collapse: collapse;
    width: 100%;
}

/* --- Skip Link (Accessibility) --------------------------- */
.skip-link {
    position: absolute;
    top: -100%;
    left: 8px;
    background: var(--color-secondary);
    color: var(--color-text-inverse);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    z-index: 10000;
    font-size: 0.875rem;
    text-decoration: none;
    transition: top var(--transition);
}

.skip-link:focus {
    top: 8px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* --- Focus --------------------------------------------------- */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* --- App Header ---------------------------------------------- */
.app-header {
    background: var(--color-secondary);
    color: var(--color-text-inverse);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    height: var(--header-height);
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    gap: 24px;
}

.header-brand {
    flex-shrink: 0;
}

.header-logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--color-text-inverse);
    text-decoration: none;
}

.header-logo-link:hover {
    text-decoration: none;
    opacity: 0.9;
}

.header-logo {
    height: 32px;
    width: auto;
}

.header-title {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.header-nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.header-nav-list {
    display: flex;
    gap: 4px;
}

.header-nav-link {
    display: block;
    padding: 8px 16px;
    color: rgba(255,255,255,0.78);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.header-nav-link:hover,
.header-nav-link:focus-visible {
    background: rgba(255,255,255,0.10);
    color: var(--color-text-inverse);
    text-decoration: none;
}

.header-nav-link.active {
    color: var(--color-text-inverse);
    background: rgba(255,255,255,0.14);
    font-weight: 600;
}

.header-user {
    flex-shrink: 0;
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.08);
    color: var(--color-text-inverse);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-full);
    padding: 5px 14px 5px 5px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    transition: background var(--transition);
    line-height: 1;
}

.user-menu-trigger:hover,
.user-menu-trigger:focus-visible {
    background: rgba(255,255,255,0.14);
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8125rem;
    text-transform: uppercase;
}

.user-name {
    font-weight: 500;
}

.user-chevron {
    color: rgba(255,255,255,0.55);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--color-card);
    color: var(--color-text);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    padding: 4px;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity var(--transition), transform var(--transition);
}

.user-menu-trigger[aria-expanded="true"] + .user-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.user-dropdown-link {
    display: block;
    padding: 8px 14px;
    font-size: 0.875rem;
    color: var(--color-text);
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.user-dropdown-link:hover {
    background: var(--color-bg);
    text-decoration: none;
}

/* --- App Footer ---------------------------------------------- */
.app-footer {
    margin-top: auto;
    padding: 16px 24px;
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.8125rem;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-card);
}

/* --- App Content --------------------------------------------- */
.app-content {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
}

/* --- Flash Messages ------------------------------------------ */
.flash-container {
    margin-bottom: 20px;
}

.alert {
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 8px;
    border-left: 4px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success {
    background: var(--color-success-bg);
    color: #155724;
    border-left-color: var(--color-success);
}

.alert-error {
    background: var(--color-danger-bg);
    color: #721c24;
    border-left-color: var(--color-danger);
}

.alert-warning {
    background: var(--color-warning-bg);
    color: #856404;
    border-left-color: var(--color-warning);
}

.alert-title {
    font-weight: 700;
    margin-bottom: 2px;
}

.alert-message {
    margin: 0;
}

/* --- Alerts Section ------------------------------------------ */
.alerts-section {
    margin-bottom: 24px;
}

/* --- Page Header --------------------------------------------- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header-left {
    flex: 1;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-top: 4px;
}

.page-header-right {
    flex-shrink: 0;
}

/* --- Date Range Picker --------------------------------------- */
.date-range-form {
    display: flex;
}

.date-range-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 6px 8px 6px 14px;
    box-shadow: var(--shadow-sm);
}

.date-range-separator {
    color: var(--color-text-light);
    font-size: 0.875rem;
}

/* --- KPI Grid ------------------------------------------------ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-grid--4col {
    grid-template-columns: repeat(4, 1fr);
}

.kpi-card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
    animation: fadeIn 0.4s ease both;
}

.kpi-card:nth-child(1) { animation-delay: 0s; }
.kpi-card:nth-child(2) { animation-delay: 0.05s; }
.kpi-card:nth-child(3) { animation-delay: 0.10s; }
.kpi-card:nth-child(4) { animation-delay: 0.15s; }
.kpi-card:nth-child(5) { animation-delay: 0.20s; }
.kpi-card:nth-child(6) { animation-delay: 0.25s; }
.kpi-card:nth-child(7) { animation-delay: 0.30s; }
.kpi-card:nth-child(8) { animation-delay: 0.35s; }

.kpi-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.kpi-card--status {
    border-left: 4px solid transparent;
    padding-left: 20px;
}

.kpi-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-light);
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.kpi-value--medium {
    font-size: 1.5rem;
    font-weight: 700;
}

.kpi-change {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.kpi-change.up .kpi-change-arrow,
.kpi-change.up .kpi-change-value {
    color: var(--color-success);
}

.kpi-change.down .kpi-change-arrow,
.kpi-change.down .kpi-change-value {
    color: var(--color-danger);
}

.kpi-change-period {
    color: var(--color-text-light);
    font-weight: 400;
    margin-left: 2px;
}

/* --- Chart Container ----------------------------------------- */
.chart-container {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
    animation: slideUp 0.35s ease both;
}

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

.chart-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-secondary);
    line-height: 1.3;
}

.chart-subtitle {
    font-size: 0.8125rem;
    color: var(--color-text-light);
    margin-top: 2px;
}

.chart-meta {
    font-size: 0.8125rem;
    color: var(--color-text-light);
}

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

.chart-canvas {
    width: 100%;
    max-height: 380px;
}

.chart-canvas--donut {
    max-height: 260px;
    max-width: 260px;
    margin: 0 auto;
    display: block;
}

/* --- Charts Row (two columns) -------------------------------- */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.chart-container--half {
    margin-bottom: 0;
}

.chart-container--two-thirds {
    margin-bottom: 0;
    grid-column: span 2;
}

.charts-row:has(.chart-container--two-thirds) {
    grid-template-columns: 2fr 1fr;
}

/* --- Tables -------------------------------------------------- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th {
    background: var(--color-bg);
    padding: 10px 14px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-light);
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid var(--color-border);
    cursor: pointer;
    user-select: none;
}

.data-table th:hover {
    color: var(--color-text);
}

.data-table th.sort-asc::after {
    content: ' ▲';
    font-size: 0.625rem;
}

.data-table th.sort-desc::after {
    content: ' ▼';
    font-size: 0.625rem;
}

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text);
}

.data-table tbody tr:hover {
    background: rgba(33, 68, 98, 0.03);
}

.data-table tbody tr:nth-child(even) {
    background: rgba(0,0,0,0.012);
}

.data-table tbody tr:nth-child(even):hover {
    background: rgba(33, 68, 98, 0.04);
}

.cell-truncate {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Filter Bar ---------------------------------------------- */
.filter-bar {
    margin-bottom: 24px;
}

.filter-form {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
    background: var(--color-card);
    padding: 16px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.form-group--inline {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-reset {
    align-self: flex-end;
}

/* --- Input Search -------------------------------------------- */
.input-search {
    display: flex;
    gap: 0;
}

.input-search .form-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.input-search .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Forms --------------------------------------------------- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
}

.form-input,
.form-select {
    display: block;
    width: 100%;
    padding: 9px 13px;
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.form-input-sm {
    padding: 6px 10px;
    font-size: 0.8125rem;
    width: auto;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(219, 39, 35, 0.12);
    outline: none;
}

.form-input::placeholder {
    color: var(--color-text-light);
    opacity: 0.6;
}

.form-input[type="date"] {
    width: auto;
    min-width: 140px;
}

.form-select {
    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 d='M3 4.5L6 7.5L9 4.5' fill='none' stroke='%236c757d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    width: auto;
}

/* --- Buttons ------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border-color: var(--color-primary);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

.btn-primary:focus-visible {
    box-shadow: 0 0 0 3px rgba(219, 39, 35, 0.35);
}

.btn-secondary {
    background: var(--color-secondary);
    color: var(--color-text-inverse);
    border-color: var(--color-secondary);
}

.btn-secondary:hover {
    background: var(--color-secondary-dark);
}

.btn-outline {
    background: transparent;
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-outline:hover {
    background: var(--color-bg);
    border-color: var(--color-text-light);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}

.btn-block {
    display: flex;
    width: 100%;
    justify-content: center;
}

.btn-icon {
    flex-shrink: 0;
}

/* --- Cards --------------------------------------------------- */
.card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 16px;
}

/* --- Login Page ---------------------------------------------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 40px 36px;
    animation: fadeIn 0.5s ease;
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo-img {
    height: 56px;
    width: auto;
    margin: 0 auto;
}

.login-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-secondary);
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: center;
    font-size: 0.9375rem;
    color: var(--color-text-light);
    margin-bottom: 28px;
}

.login-form .btn {
    margin-top: 8px;
}

/* --- Login Page on base layout (with header) ----------------- */
body .login-page {
    min-height: 0;
}

/* --- Page Groups (Content Groups) ---------------------------- */
.page-groups {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.page-group-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px 18px;
    text-decoration: none;
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 140px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.page-group-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.page-group-card--active {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.page-group-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
}

.page-group-count {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
}

.page-group-share {
    font-size: 0.75rem;
    color: var(--color-text-light);
}

/* --- Location Cards ------------------------------------------ */
.locations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.location-card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}

.location-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.location-card-header {
    padding: 18px 20px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.location-name {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--color-secondary);
}

.location-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-primary);
    background: var(--color-primary-light);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.location-card-body {
    padding: 0 20px 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.location-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.location-stat-value {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--color-text);
}

.location-stat-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-light);
}

.location-card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--color-border-light);
}

/* --- Data Volume Stats --------------------------------------- */
.data-volume-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.data-volume-item {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.data-volume-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-light);
    margin-bottom: 6px;
    font-weight: 600;
}

.data-volume-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-secondary);
}

/* --- Trend Indicators in Tables ------------------------------ */
.trend-up {
    color: var(--color-success);
    font-weight: 700;
}

.trend-down {
    color: var(--color-danger);
    font-weight: 700;
}

.trend-flat {
    color: var(--color-text-light);
}

/* --- Tooltips ------------------------------------------------ */
.tooltip-trigger {
    position: relative;
    display: inline-flex;
    cursor: help;
    color: var(--color-text-light);
}

.tooltip-trigger:hover,
.tooltip-trigger:focus-within {
    color: var(--color-text);
}

.tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-secondary);
    color: var(--color-text-inverse);
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
    z-index: 100;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--color-secondary);
}

.tooltip-trigger:hover .tooltip,
.tooltip-trigger:focus-within .tooltip {
    opacity: 1;
}

/* --- Pagination ---------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition);
}

.pagination-link:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
    text-decoration: none;
}

.pagination-link--active {
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border-color: var(--color-primary);
    font-weight: 700;
}

.pagination-link--active:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

/* --- Loading / Skeleton -------------------------------------- */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 24px auto;
}

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

.skeleton-pulse {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* --- Utility Classes ----------------------------------------- */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-left    { text-align: left; }
.text-muted   { color: var(--color-text-light); }
.mb-0   { margin-bottom: 0; }
.mb-8   { margin-bottom: 8px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.mt-0   { margin-top: 0; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.flex        { display: flex; }
.flex-wrap   { flex-wrap: wrap; }
.gap-8       { gap: 8px; }
.gap-16      { gap: 16px; }
.grid        { display: grid; }

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Responsive: Tablet (max 992px) -------------------------- */
@media (max-width: 992px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

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

    .charts-row:has(.chart-container--two-thirds) {
        grid-template-columns: 1fr;
    }

    .chart-container--two-thirds {
        grid-column: span 1;
    }

    .chart-container--half {
        margin-bottom: 24px;
    }

    .charts-row .chart-container--half:last-child {
        margin-bottom: 0;
    }

    .header-nav {
        display: none;
    }

    .header-title {
        font-size: 0.9375rem;
    }
}

/* --- Responsive: Mobile (max 768px) -------------------------- */
@media (max-width: 768px) {
    .app-content {
        padding: 14px;
    }

    .app-header {
        height: auto;
        position: relative;
    }

    .header-bar {
        padding: 10px 14px;
        gap: 10px;
    }

    .header-title {
        font-size: 0.875rem;
    }

    .header-logo {
        height: 26px;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .kpi-grid--4col {
        grid-template-columns: 1fr 1fr;
    }

    .kpi-card {
        padding: 14px 16px;
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .kpi-value--medium {
        font-size: 1.125rem;
    }

    .page-header {
        flex-direction: column;
    }

    .page-header-right {
        width: 100%;
    }

    .date-range-form {
        width: 100%;
    }

    .date-range-picker {
        width: 100%;
        flex-wrap: wrap;
    }

    .date-range-picker .form-input[type="date"] {
        flex: 1;
        min-width: 0;
    }

    .chart-header {
        padding: 14px 16px;
    }

    .chart-body {
        padding: 14px 16px;
    }

    .chart-canvas {
        max-height: 260px;
    }

    .charts-row {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .chart-container--half {
        margin-bottom: 14px;
    }

    .charts-row .chart-container--half:last-child {
        margin-bottom: 0;
    }

    .filter-form {
        flex-direction: column;
        padding: 14px;
    }

    .form-group--inline {
        width: 100%;
    }

    .form-select {
        width: 100%;
    }

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

    .page-groups {
        flex-direction: column;
    }

    .page-group-card {
        min-width: 0;
    }

    .data-volume-stats {
        grid-template-columns: 1fr 1fr;
    }

    .login-card {
        padding: 28px 20px;
    }
}

/* --- Print Styles -------------------------------------------- */
@media print {
    .app-header,
    .app-footer,
    .header-nav,
    .header-user,
    .date-range-form,
    .filter-bar,
    .btn,
    .skip-link,
    .flash-container {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
        font-size: 11pt;
    }

    .app-content {
        max-width: 100%;
        padding: 0;
    }

    .kpi-card {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    .chart-container {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    a {
        color: #000;
        text-decoration: underline;
    }

    .kpi-grid {
        grid-template-columns: repeat(4, 1fr);
    }

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