/*
 * Gittertier Pro – einheitliches Design (Vorlage: index.html)
 *
 * Wird auf jeder Seite NACH dem seitenspezifischen <style> eingebunden.
 * Es setzt die Design-Tokens aller Seiten auf die Werte der Scanner-Seite:
 * die Index-Familie (--color-accent, --radius …) und die frühere "Glass"-Familie
 * (--color-primary, --gradient-*, --glass-*) von user/loyalty/about/landing.
 * Dunkelmodus wird über body.dark-mode / body.light-mode gesteuert (GT.theme).
 */

:root {
    /* Index tokens */
    --color-bg: #ffffff;
    --color-bg-secondary: #f9fafb;
    --color-surface: #ffffff;
    --color-text: #111111;
    --color-text-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-accent: #2563eb;
    --color-accent-hover: #1d4ed8;
    --color-accent-light: rgba(37, 99, 235, 0.1);
    --color-success: #16a34a;
    --color-success-light: rgba(22, 163, 74, 0.1);
    --color-error: #dc2626;
    --color-error-light: rgba(220, 38, 38, 0.1);
    --color-warning: #d97706;
    --color-warning-light: rgba(217, 119, 6, 0.1);
    --color-info: #2563eb;
    --color-overlay: rgba(0, 0, 0, 0.5);

    --radius: 12px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 4px 10px -5px rgba(0, 0, 0, 0.06);
    --shadow-xl: var(--shadow-lg);
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.35);

    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-system: var(--font-family);
    --font-ui: var(--font-family);
    --header-height: 64px;

    /* Former "glass" family mapped onto the index look: flat, white, thin borders */
    --color-primary: var(--color-accent);
    --color-primary-dark: var(--color-accent-hover);
    --color-dark: #111111;
    --color-light: #f9fafb;
    --color-white: #ffffff;
    --color-gray: #6b7280;
    --color-gray-light: #e5e7eb;
    --color-gray-dark: #374151;
    --color-card-bg: var(--color-surface);
    --color-card-bg-glass: var(--color-surface);
    --color-sidebar-bg: var(--color-surface);
    --color-modal-bg: var(--color-surface);
    --color-hover-gray: rgba(0, 0, 0, 0.04);
    --color-hover-gray-medium: rgba(0, 0, 0, 0.06);
    --glass-blur: none;
    --glass-border: 1px solid var(--color-border);
    --glass-border-dark: 1px solid var(--color-border);
    --glass-shadow: var(--shadow);
    --glass-shadow-lg: var(--shadow-md);
    --glass-shadow-xl: var(--shadow-lg);
    --gradient-primary: linear-gradient(var(--color-accent), var(--color-accent));
    --gradient-accent: linear-gradient(var(--color-accent), var(--color-accent));
    --gradient-success: linear-gradient(var(--color-success), var(--color-success));
    --gradient-warning: linear-gradient(var(--color-warning), var(--color-warning));
    --gradient-error: linear-gradient(var(--color-error), var(--color-error));
    --gradient-glass: linear-gradient(var(--color-surface), var(--color-surface));
    --gradient-glass-dark: linear-gradient(var(--color-surface), var(--color-surface));
    --gradient-gray-hover: linear-gradient(var(--color-hover-gray), var(--color-hover-gray));
}

/* Dark tokens: system preference unless the customer chose light explicitly */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #111827;
        --color-bg-secondary: #1f2937;
        --color-surface: #1f2937;
        --color-text: #f3f4f6;
        --color-text-muted: #9ca3af;
        --color-border: #374151;
        --color-dark: #f3f4f6;
        --color-light: #1f2937;
        --color-white: #1f2937;
        --color-gray-light: #374151;
        --color-hover-gray: rgba(255, 255, 255, 0.05);
        --color-hover-gray-medium: rgba(255, 255, 255, 0.08);
    }
}

body.dark-mode {
    --color-bg: #111827;
    --color-bg-secondary: #1f2937;
    --color-surface: #1f2937;
    --color-text: #f3f4f6;
    --color-text-muted: #9ca3af;
    --color-border: #374151;
    --color-dark: #f3f4f6;
    --color-light: #1f2937;
    --color-white: #1f2937;
    --color-gray-light: #374151;
    --color-hover-gray: rgba(255, 255, 255, 0.05);
    --color-hover-gray-medium: rgba(255, 255, 255, 0.08);
    --color-card-bg: var(--color-surface);
    --color-card-bg-glass: var(--color-surface);
    --color-sidebar-bg: var(--color-surface);
    --color-modal-bg: var(--color-surface);
    --glass-border: 1px solid var(--color-border);
    --glass-border-dark: 1px solid var(--color-border);
}

body.light-mode {
    --color-bg: #ffffff;
    --color-bg-secondary: #f9fafb;
    --color-surface: #ffffff;
    --color-text: #111111;
    --color-text-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-dark: #111111;
    --color-light: #f9fafb;
    --color-white: #ffffff;
    --color-gray-light: #e5e7eb;
    --color-hover-gray: rgba(0, 0, 0, 0.04);
    --color-hover-gray-medium: rgba(0, 0, 0, 0.06);
}

/* ---------------------------------------------------------------- base */
body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
}

/* ---------------------------------------------------------------- header
 * Same bar as the scanner page: 64px, surface colour, hairline border, no blur */
body > header,
body > .admin-header,
.admin-header,
.about-header {
    background: var(--color-surface) !important;
    border-bottom: 1px solid var(--color-border) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    min-height: var(--header-height);
}

.admin-header .logo,
body > header .logo {
    font-weight: 700;
    color: var(--color-text);
}

.admin-header .logo i,
body > header .logo i {
    color: var(--color-accent);
}

/* ---------------------------------------------------------------- surfaces */
.admin-sidebar {
    background: var(--color-surface) !important;
    border-right: 1px solid var(--color-border) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

body .card,
body .setting-card,
body .settings-card,
body .stat-card,
body .feature-card,
body .tier-card,
body .payment-card,
body .scanner-card,
body .product-card,
body .cart-section,
body .login-container,
body .glass-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Modals: flat surface like the scanner page dialogs */
body .modal-content,
body .modal-container,
body .modal-box {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* ---------------------------------------------------------------- controls */
body .btn-primary,
body .btn.primary,
body .modal-btn.primary {
    background: var(--color-accent);
    color: #ffffff;
    border-color: var(--color-accent);
}

body .btn-primary:hover,
body .btn.primary:hover,
body .modal-btn.primary:hover {
    background: var(--color-accent-hover);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Premium accents stay gold on every page */
.gt-premium-badge {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #000;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

/* Cloud sync status pill (settings/products/archive) */
.gt-cloud-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    background: var(--color-surface);
}
.gt-cloud-pill.ok { color: var(--color-success); border-color: var(--color-success); }
.gt-cloud-pill.error { color: var(--color-error); border-color: var(--color-error); }
.gt-cloud-pill.syncing { color: var(--color-accent); border-color: var(--color-accent); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------------------------------------------------------------- admin navigation */
.gt-nav-section {
    padding: 14px 16px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
.gt-nav-section:first-child { padding-top: 4px; }
.gt-nav-divider {
    margin: 8px 16px;
    padding: 0;
    border-top: 1px solid var(--color-border);
}
.admin-sidebar .nav-link.active {
    background: var(--color-accent-light);
    color: var(--color-accent);
}

/* ---------------------------------------------------------------- mobile (all pages)
 * Grid/flex children default to min-width:auto and grow to their widest
 * content (e.g. 600px tables), which pushed whole admin pages wider than the
 * phone screen. Columns may shrink; wide content scrolls inside itself. */
.admin-container > *,
.admin-content,
.admin-content > *,
main {
    min-width: 0;
}

.admin-sidebar {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

img, video, canvas, svg {
    max-width: 100%;
}

input, select, textarea {
    max-width: 100%;
}

@media (max-width: 768px) {
    /* clip, not hidden: overflow-x: hidden turns html AND body into scroll containers
       (overflow-y becomes auto), so anchor links scroll the wrong element and Chrome
       paints blank areas. clip cuts off just the same without creating a scroller. */
    html, body {
        overflow-x: hidden;
    }
    @supports (overflow-x: clip) {
        html, body { overflow-x: clip; }
    }

    /* Tables scroll horizontally inside their card instead of widening the page */
    .admin-content table,
    main table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* iOS zooms into inputs below 16px */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea {
        font-size: max(16px, 1rem) !important;
    }

    /* Comfortable touch targets */
    .admin-sidebar .nav-link,
    .btn,
    .modal-btn,
    button.logout-btn {
        min-height: 44px;
    }

    /* Header: keep logo + actions, drop the clock */
    .admin-header .time-display {
        display: none;
    }
    .admin-header .logout-btn span,
    .admin-header .admin-link span {
        display: none;
    }

    /* Dialogs fill the width of the phone */
    body .modal-content,
    body .modal-container,
    body .modal-box,
    body .modal {
        max-width: calc(100vw - 24px);
    }
    body .modal-content,
    body .modal-container,
    body .modal-box {
        max-height: calc(100vh - 32px);
        overflow-y: auto;
    }

    /* Multi-column grids collapse to one column */
    .stats-grid, .summary-cards, .charts-grid, .dashboard-grid, .content-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ---------------------------------------------------------------- dynamics
 * Smooth cross-page transitions (Chrome/Edge/Safari 18+); other browsers
 * simply navigate as before. Disabled with "Animationen reduzieren". */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 180ms; }

.gt-reduce-motion *,
.gt-reduce-motion *::before,
.gt-reduce-motion *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
}
@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
}
.gt-reduce-motion::view-transition-old(root),
.gt-reduce-motion::view-transition-new(root) { animation: none; }

/* Subtle highlight when a list was refreshed with data from another device */
@keyframes gt-flash { from { background-color: var(--color-accent-light); } to { background-color: transparent; } }
.gt-flash { animation: gt-flash 1.2s ease-out; }

/* ---------------------------------------------------------------- compact admin view */
.gt-compact .admin-content { padding: 12px 16px !important; }
.gt-compact .setting-card,
.gt-compact .dashboard-card,
.gt-compact .card,
.gt-compact .stat-card { padding: 12px !important; margin-bottom: 10px !important; }
.gt-compact .page-header { margin-bottom: 12px !important; }
.gt-compact .data-table td,
.gt-compact .data-table th { padding-top: 6px !important; padding-bottom: 6px !important; }

/* ---------------------------------------------------------------- desktop
 * Wide screens: readable line lengths and centred content instead of
 * stretching cards across 2000px. */
@media (min-width: 1280px) {
    /* The sidebar is position: fixed and the pages keep their content next to it
     * with margin-left: var(--sidebar-width). Centre with padding instead of auto
     * margins, otherwise the content slides underneath the sidebar. */
    .admin-content {
        padding-left: max(var(--spacing-lg, 24px), calc((100vw - var(--sidebar-width, 260px) - 1440px) / 2)) !important;
        padding-right: max(var(--spacing-lg, 24px), calc((100vw - var(--sidebar-width, 260px) - 1440px) / 2)) !important;
    }
    .settings-grid {
        column-width: 360px;
    }
}

/* ---------------------------------------------------------------- small phones (≤ 380 px)
 * Nothing may be cut off: rows wrap, paddings shrink, long words break. */
@media (max-width: 380px) {
    .admin-content,
    main.admin-content { padding: 12px 10px !important; }
    .admin-header { padding: 0 8px !important; gap: 6px; }
    .admin-header .logo { gap: 8px !important; min-width: 0; }
    .admin-header .logo span {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 48vw;
    }
    .header-controls { gap: 6px !important; }
    .page-title, h1 { font-size: 1.3rem !important; overflow-wrap: anywhere; }
    h2 { font-size: 1.15rem; overflow-wrap: anywhere; }
    .setting-card, .dashboard-card, .card, .stat-card, .section-header { padding: 12px !important; }
    .settings-section .section-content { padding: 8px !important; }
    .setting-control, .setting-option, .card-header, .page-header {
        flex-wrap: wrap !important;
        gap: 8px;
    }
    .setting-control > div, .setting-option > div { min-width: 0; flex: 1 1 160px; }
    .action-buttons, .toolbar, .filter-controls, .sort-controls, .header-actions, .quick-actions {
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    .btn, .toolbar-btn, .modal-btn { white-space: normal; }
    .form-input, .form-control, select, textarea, input[type="text"], input[type="search"],
    input[type="number"], input[type="email"], input[type="password"], input[type="time"], input[type="date"] {
        width: 100%;
        min-width: 0;
    }
    .notification-duration { flex-wrap: wrap; }
    code, .key-cell { overflow-wrap: anywhere; }
}

/* ---------------------------------------------------------------- phone tables (≤ 640 px)
 * Tables with 4+ columns become one compact card per row: the first column is
 * the card title, the other values sit in two columns below with their column
 * name (data-label, set by gt-core.js) as a small caption. */
.tables-section > *, .charts-section > *, .table-card, .table-container { min-width: 0; }

@media (max-width: 640px) {
    .admin-content table.gt-stack,
    main table.gt-stack {
        display: block;
        overflow: visible;
        white-space: normal;
        border: 0 !important;
        background: transparent !important;
        min-width: 0 !important;
        width: 100% !important;
    }
    table.gt-stack thead { display: none; }
    table.gt-stack tbody { display: flex; flex-direction: column; gap: 8px; }
    table.gt-stack tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        column-gap: 12px;
        row-gap: 6px;
        background: var(--color-surface) !important;
        border: 1px solid var(--color-border);
        border-radius: 12px;
        padding: 10px 12px;
    }
    table.gt-stack tr:hover { transform: none; }
    table.gt-stack td {
        display: block;
        padding: 0 !important;
        border: 0 !important;
        text-align: left !important;
        white-space: normal;
        overflow-wrap: anywhere;
        min-width: 0;
        max-width: none !important;
        width: auto !important;
        background: transparent !important;
        font-size: 0.9rem;
    }
    table.gt-stack td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--color-text-muted);
        margin-bottom: 1px;
    }
    table.gt-stack td[data-label=""]::before,
    table.gt-stack td:first-child::before,
    table.gt-stack td.gt-full::before { display: none; }
    /* first column = card title */
    table.gt-stack td:first-child {
        grid-column: 1 / -1;
        font-weight: 600;
        font-size: 0.95rem;
        padding-bottom: 6px !important;
        border-bottom: 1px solid var(--color-border) !important;
    }
    /* checkbox column: title row shares the line with it */
    table.gt-stack td:first-child:has(> input[type="checkbox"]:only-child) {
        grid-column: auto; border: 0 !important; padding: 0 !important;
    }
    table.gt-stack td.gt-full { grid-column: 1 / -1; text-align: center !important; }
    /* buttons / action cells use the full card width */
    table.gt-stack td[data-label=""],
    table.gt-stack td:has(button):not(:first-child) {
        grid-column: 1 / -1;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-end;
        padding-top: 6px !important;
        border-top: 1px solid var(--color-border) !important;
    }
    table.gt-stack td:has(button)::before { flex: 1 0 100%; }
    table.gt-stack td > div { display: flex; flex-wrap: wrap; gap: 6px; }
    .table-container, .table-wrapper, .table-responsive { overflow-x: visible !important; }
    /* long lists (e.g. 24 hours) stay a scrolling table */
    .gt-scroll-box { max-height: 60vh; overflow: auto !important; overscroll-behavior: contain; }
}

/* ---------------------------------------------------------------- phone density (≤ 640 px)
 * Less empty space, smaller controls, filter buttons as chips. */
@media (max-width: 640px) {
    .admin-content, main.admin-content { padding: 14px 12px !important; }
    .page-header, .dashboard-header { margin-bottom: 14px !important; }
    .page-title, .admin-content h1 { font-size: 1.35rem !important; line-height: 1.25; }
    .page-subtitle, .page-description, .dashboard-subtitle { font-size: 0.85rem !important; line-height: 1.4; margin-top: 4px !important; }

    /* key figures two per row */
    .stats-grid, .summary-cards, .stats-overview, .kpi-grid, .um-stats, .stats-row, .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    .stat-card, .summary-card, .kpi-card, .um-stat, .metric-card { padding: 12px !important; min-height: 0 !important; }
    .stat-card .stat-value, .stat-value, .summary-card .value, .kpi-value { font-size: 1.25rem !important; overflow-wrap: anywhere; }
    .stat-label, .stat-title, .stat-card h3 { font-size: 0.75rem !important; }
    .stat-icon, .stat-card-icon { width: 30px !important; height: 30px !important; font-size: 0.85rem !important; }
    .stat-change, .stat-trend, .stat-card-change { font-size: 0.72rem !important; line-height: 1.3; }
    .stat-card-value { font-size: 1.25rem !important; overflow-wrap: anywhere; }
    .stat-card-header { margin-bottom: 8px !important; gap: 6px; }
    .stat-card-title { font-size: 0.75rem !important; }
    .welcome-card { padding: 16px !important; }
    .welcome-title { font-size: 1.2rem !important; }

    /* cards and sections tighter */
    .chart-card, .table-card, .insight-card, .export-section, .insights-section,
    .dashboard-card, .setting-card, .card, .section-card, .content-card {
        padding: 14px !important;
        margin-bottom: 12px;
        border-radius: 14px;
    }
    .charts-section, .tables-section, .insights-grid, .dashboard-grid, .content-grid { gap: 12px !important; margin-bottom: 12px !important; }
    .chart-container { height: 220px !important; }
    .table-card-header, .chart-card-header, .card-header, .section-header { margin-bottom: 10px !important; gap: 8px; }
    .table-card-title, .chart-card-title, .card-title { font-size: 1rem !important; }

    /* filter buttons as a compact chip row */
    .date-range-selector, .filter-buttons, .period-selector, .time-filters, .quick-filters, .filter-tabs {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 6px !important;
    }
    .date-range-selector > button, .date-btn, .period-btn, .filter-btn, .filter-tab, .range-btn {
        width: auto !important;
        flex: 0 0 auto;
        padding: 6px 12px !important;
        font-size: 0.82rem !important;
        min-height: 34px !important;
        border-radius: 999px !important;
    }
    .custom-date-inputs {
        flex: 1 1 100%;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        align-items: center;
        gap: 6px !important;
    }
    .custom-date-inputs .apply-date-btn { grid-column: 1 / -1; }
    .custom-date-inputs input { width: 100% !important; min-width: 0; font-size: 14px !important; }

    /* action button groups: two per row instead of one big column */
    .export-actions, .quick-actions, .action-grid, .welcome-actions, .hero-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }
    .export-actions > *, .quick-actions > *, .action-grid > *, .welcome-actions > *, .hero-actions > * { width: auto !important; min-width: 0; padding: 10px 8px !important; font-size: 0.85rem !important; }

    /* header-row buttons shrink to icon + short label */
    .page-header .btn, .page-actions .btn, .header-actions .btn, .table-card-actions .btn, .card-header .btn {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
        min-height: 38px !important;
    }
}
@media (max-width: 640px) {
    /* card headers: title on its own line, then search + buttons in one wrapping row */
    .card-header, .table-card-header, .section-toolbar {
        flex-wrap: wrap !important;
        align-items: center !important;
    }
    .card-header > .toolbar, .card-header > .header-actions, .card-header > .card-actions, .card-header > .action-buttons {
        flex: 1 1 100%;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 6px !important;
        width: 100%;
    }
    .toolbar > input, .toolbar > select, .card-header input[type="search"], .card-header input[type="text"] {
        flex: 1 1 100% !important;
        width: 100% !important;
    }
    .toolbar > button, .toolbar > a, .toolbar-btn, .card-header .action-buttons > * {
        flex: 1 1 auto;
        justify-content: center;
        min-height: 38px !important;
        padding: 8px 10px !important;
        font-size: 0.85rem !important;
    }
    /* narrow tables (< 4 columns) use the full card width instead of scrolling */
    .admin-content table:not(.gt-stack):not([data-no-stack]),
    main table:not(.gt-stack):not([data-no-stack]) {
        display: table;
        width: 100% !important;
        white-space: normal;
    }
}
@media (max-width: 340px) {
    .stats-grid, .summary-cards, .stats-overview, .kpi-grid, .um-stats, .stats-row, .metrics-grid { grid-template-columns: 1fr !important; }
}

/* ---------------------------------------------------------------- dialogs
 * Native <dialog class="gt-dialog"> for focused editing (coupon editor, customer
 * account). Header and footer stay visible, the body scrolls; bottom sheet on phones. */
dialog.gt-dialog {
    /* pages reset * { margin: 0 }, which would pin the dialog to the top left corner */
    margin: auto;
    inset: 0;
    border: 0;
    padding: 0;
    border-radius: 16px;
    width: min(680px, calc(100vw - 32px));
    max-height: calc(100dvh - 48px);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
    overflow: hidden;
}
dialog.gt-dialog[open] { display: flex; flex-direction: column; animation: gt-dialog-in 160ms ease-out; }
dialog.gt-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
dialog.gt-dialog > form { display: flex; flex-direction: column; min-height: 0; max-height: inherit; margin: 0; }
@keyframes gt-dialog-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.gt-dialog-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--color-border);
}
.gt-dialog-header h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.gt-dialog-close {
    width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent;
    color: var(--color-text-muted); font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.gt-dialog-close:hover { background: var(--color-bg-secondary); color: var(--color-text); }
.gt-dialog-body { padding: 16px 18px; overflow-y: auto; min-height: 0; }
.gt-dialog-footer {
    display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
    padding: 12px 18px; border-top: 1px solid var(--color-border); background: var(--color-bg-secondary);
}
.gt-dialog-error { color: var(--color-error, #dc2626); font-size: 0.85rem; margin-top: 10px; min-height: 1em; }
.gt-dialog-error:empty { display: none; }
@media (max-width: 640px) {
    dialog.gt-dialog {
        width: 100vw; max-width: 100vw;
        max-height: calc(92dvh - var(--gt-kb, 0px));
        margin: auto 0 0; border-radius: 18px 18px 0 0;
        /* --gt-kb: height of the on-screen keyboard (set by gt-core via visualViewport) */
        bottom: var(--gt-kb, 0px);
    }
    dialog.gt-dialog[open] { animation-name: gt-sheet-in; }
    .gt-dialog-footer .btn, .gt-dialog-footer button { flex: 1 1 0; justify-content: center; }
}
@keyframes gt-sheet-in { from { transform: translateY(100%); } to { transform: none; } }
.gt-reduce-motion dialog.gt-dialog[open] { animation: none; }

/* ---------------------------------------------------------------- account notices (customer pages) */
#gt-account-banner {
    position: sticky; top: 0; z-index: 1000;
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 16px; background: #b91c1c; color: #fff; font-size: 0.9rem; line-height: 1.4;
}
#gt-account-banner i { margin-top: 3px; }
#gt-toasts {
    position: fixed; z-index: 2000; left: 50%; bottom: 20px; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px));
}
.gt-toast {
    display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px;
    background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-accent); box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
    animation: gt-dialog-in 180ms ease-out; font-size: 0.9rem;
}
.gt-toast.success { border-left-color: var(--color-success, #16a34a); }
.gt-toast.warning { border-left-color: #dc2626; }
.gt-toast-body { flex: 1; min-width: 0; }
.gt-toast-body ul { margin: 4px 0 0; padding-left: 18px; }
.gt-toast-body p { margin: 4px 0 0; }
.gt-toast-close { border: 0; background: none; font-size: 1.2rem; line-height: 1; color: var(--color-text-muted); cursor: pointer; }

/* Taps: no double-tap zoom delay on controls */
button, a, .btn, [role="button"], input, select, label { touch-action: manipulation; }

/* ---------------------------------------------------------------- guided tour (GT.ui.tour) */
.gt-tour-shade { position: fixed; inset: 0; z-index: 2990; background: transparent; }
.gt-tour-shade.dim { background: rgba(15, 23, 42, 0.55); }
.gt-tour-target {
    position: relative; z-index: 2995 !important; border-radius: 16px;
    box-shadow: 0 0 0 4px var(--color-accent), 0 0 0 100vmax rgba(15, 23, 42, 0.55) !important;
    transition: box-shadow 0.25s ease;
}
.gt-tour {
    position: fixed; z-index: 3000; left: 50%; bottom: 20px; transform: translateX(-50%);
    width: min(460px, calc(100vw - 24px)); background: var(--color-surface); color: var(--color-text);
    border-radius: 18px; overflow: hidden; box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
    animation: gt-tour-in 200ms ease-out; font-size: 0.95rem;
}
@keyframes gt-tour-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.gt-tour-progress { height: 4px; background: var(--color-border); }
.gt-tour-progress span { display: block; height: 100%; background: var(--color-accent); transition: width 0.25s ease; }
.gt-tour-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px 0; }
.gt-tour-count { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-text-muted); }
.gt-tour-skip { border: 0; background: none; color: var(--color-text-muted); font: inherit; font-size: 0.85rem; cursor: pointer; padding: 4px 0; }
.gt-tour-skip:hover { color: var(--color-text); }
.gt-tour-body { padding: 10px 18px 4px; }
.gt-tour-icon {
    width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    background: var(--color-accent-light, rgba(37, 99, 235, 0.1)); color: var(--color-accent); font-size: 1.15rem; margin-bottom: 10px;
}
.gt-tour-body h3 { margin: 0 0 6px; font-size: 1.12rem; color: var(--color-text); }
.gt-tour-body p { margin: 0; line-height: 1.55; color: var(--color-text-muted); }
.gt-tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px 16px; }
.gt-tour-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.gt-tour-dots button { width: 8px; height: 8px; min-height: 0; padding: 0; border: 0; border-radius: 999px; background: var(--color-border); cursor: pointer; transition: width 0.2s ease, background 0.2s ease; }
.gt-tour-dots button.on { width: 22px; background: var(--color-accent); }
.gt-tour-nav { display: flex; gap: 8px; }
.gt-tour-btn {
    display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 10px; cursor: pointer;
    padding: 10px 16px; font: inherit; font-weight: 600; background: var(--color-accent); color: #fff; min-height: 42px;
}
.gt-tour-btn.ghost { background: var(--color-bg-secondary); color: var(--color-text); }
@media (max-width: 640px) {
    .gt-tour { bottom: 0; width: 100vw; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.gt-reduce-motion .gt-tour { animation: none; }
.gt-reduce-motion .gt-tour-progress span, .gt-reduce-motion .gt-tour-target { transition: none; }
