@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Montserrat:wght@500;600;700;800;900&display=swap');

:root {
    --alt-red: #d71920;
    --alt-red-dark: #a90e15;
    --alt-ink: #171717;
    --alt-muted: #6c6c6c;
    --alt-paper: #f5f5f3;
    --alt-line: #e5e3df;
}

* { box-sizing: border-box; }

.password-field {
    position: relative;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--alt-muted);
    padding: 4px;
    font-size: 13px;
    font-weight: 700;
}

.password-toggle:hover {
    color: var(--alt-red);
}

html { scroll-behavior: smooth; }

body {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    background: var(--alt-paper);
    color: var(--alt-ink);
    font-family: 'DM Sans', 'Segoe UI', Tahoma, sans-serif;
    font-size: 16px;
    line-height: 1.55;
}

body::before {
    position: fixed;
    z-index: -1;
    inset: -5px;
    content: "";
    background:
        linear-gradient(rgba(12, 12, 12, 0.28), rgba(12, 12, 12, 0.28)),
        url("../assets/altf4-background.png") center / cover no-repeat;
    filter: blur(4px);
}

main[class] {
    position: relative;
    color: var(--alt-ink);
    background: rgba(255, 255, 255, 0.97) !important;
    border: 1px solid var(--alt-line) !important;
    border-radius: 8px;
    box-shadow: 0 18px 55px rgba(17, 17, 17, 0.12);
    line-height: 1.55;
    animation: app-page-enter 0.3s ease-out both;
}

main[class] a[hidden] {
    display: none !important;
}

main[class] > header {
    color: #f5f5f5 !important;
    background: #080808 !important;
    border-color: #292929 !important;
}

main[class] > header a,
main[class] > header button,
main[class] > header span {
    color: #d0d0d0;
}

main[class] > header a:hover,
main[class] > header button:hover {
    color: #fff;
}

main[class] > header .text-altRed {
    color: var(--alt-red) !important;
}

main[class] h1,
main[class] h2,
main[class] h3 {
    font-family: Montserrat, 'Segoe UI', sans-serif;
    letter-spacing: -0.025em;
}

main[class] p,
main[class] li {
    line-height: 1.6;
}

main[class] [class~="text-[9px]"] {
    font-size: 12px !important;
}

main[class] [class~="text-[10px]"] {
    font-size: 12px !important;
}

main[class] [class~="text-[11px]"] {
    font-size: 13px !important;
}

main[class] [class~="text-xs"] {
    font-size: 14px !important;
}

main[class] .text-white {
    color: var(--alt-ink) !important;
}

main[class] button.text-white,
main[class] a.text-white,
main[class] > header .text-white {
    color: #fff !important;
}

main[class] .text-zinc-200,
main[class] .text-zinc-300 {
    color: #343434 !important;
}

main[class] .text-zinc-400 {
    color: #555 !important;
}

main[class] .text-zinc-500 {
    color: #737373 !important;
}

main[class] .text-zinc-600,
main[class] .text-zinc-700 {
    color: #666 !important;
}

main[class] [class*="bg-black"],
main[class] [class*="bg-zinc-950"],
main[class] [class*="bg-zinc-900"] {
    background-color: #f8f8f6 !important;
}

main[class] [class*="bg-zinc-800"] {
    background-color: #efeeeb !important;
}

main[class] [class*="border-zinc-900"],
main[class] [class*="border-zinc-800"],
main[class] [class*="border-zinc-700"] {
    border-color: var(--alt-line) !important;
}

main[class] [class*="border-zinc-600"] {
    border-color: #d2cfca !important;
}

main[class] .bg-altRed {
    background-color: var(--alt-red) !important;
}

main[class] .bg-altRed:hover,
main[class] .hover\:bg-red-700:hover {
    background-color: var(--alt-red-dark) !important;
}

main[class] .text-altRed,
main[class] .border-altRed {
    color: var(--alt-red) !important;
    border-color: var(--alt-red) !important;
}

main[class] .bg-yellow-950\/30 {
    background-color: #fff7e6 !important;
}

main[class] .text-yellow-200 {
    color: #76520d !important;
}

main[class] .bg-red-950\/30 {
    background-color: #fff0ef !important;
}

main[class] .text-red-400 {
    color: #a90e15 !important;
}

main[class] .bg-green-950\/30 {
    background-color: #edf8ef !important;
}

main[class] .text-green-400 {
    color: #28743a !important;
}

main[class] input:not([type="checkbox"]),
main[class] select,
main[class] textarea {
    color: #222 !important;
    background-color: #fff !important;
    border: 1px solid #d8d6d1 !important;
    border-radius: 3px;
    font-size: 16px !important;
}

main[class] input::placeholder,
main[class] textarea::placeholder {
    color: #737373;
}

main[class] input:focus,
main[class] select:focus,
main[class] textarea:focus,
main[class] button:focus-visible,
main[class] a:focus-visible {
    outline: 2px solid var(--alt-red);
    outline-offset: 2px;
}

main[class] button:not(:disabled) {
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

main[class] button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

main[class] table {
    color: #282828;
}

main[class] thead {
    background-color: #f1f0ed;
}

main[class] tbody tr:hover {
    background-color: #f8f7f5;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --alt-ink: #f0efed;
    --alt-muted: #aaa7a2;
    --alt-paper: #151515;
    --alt-line: #383633;
}

html[data-theme="dark"] body::before {
    background:
        linear-gradient(rgba(12, 12, 12, 0.76), rgba(12, 12, 12, 0.76)),
        url("../assets/altf4-background.png") center / cover no-repeat;
}

html[data-theme="dark"] main[class] {
    color: var(--alt-ink);
    background: rgba(29, 29, 29, 0.98) !important;
    border-color: #3a3936 !important;
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] main[class] .text-white {
    color: #f0efed !important;
}

html[data-theme="dark"] main[class] button.text-white,
html[data-theme="dark"] main[class] a.text-white,
html[data-theme="dark"] main[class] > header .text-white,
html[data-theme="dark"] main[class] .bg-altRed,
html[data-theme="dark"] main[class] .bg-altRed .text-white {
    color: #fff !important;
}

html[data-theme="dark"] main[class] .text-zinc-200,
html[data-theme="dark"] main[class] .text-zinc-300 {
    color: #d3d0cb !important;
}

html[data-theme="dark"] main[class] .text-zinc-400 {
    color: #b6b2ac !important;
}

html[data-theme="dark"] main[class] .text-zinc-500,
html[data-theme="dark"] main[class] .text-zinc-600,
html[data-theme="dark"] main[class] .text-zinc-700 {
    color: #a09c96 !important;
}

html[data-theme="dark"] main[class] [class*="bg-black"],
html[data-theme="dark"] main[class] [class*="bg-zinc-950"],
html[data-theme="dark"] main[class] [class*="bg-zinc-900"] {
    background-color: #242424 !important;
}

html[data-theme="dark"] main[class] [class*="bg-zinc-800"] {
    background-color: #30302e !important;
}

html[data-theme="dark"] main[class] [class*="border-zinc-900"],
html[data-theme="dark"] main[class] [class*="border-zinc-800"],
html[data-theme="dark"] main[class] [class*="border-zinc-700"],
html[data-theme="dark"] main[class] [class*="border-zinc-600"] {
    border-color: #484642 !important;
}

html[data-theme="dark"] main[class] .bg-yellow-950\/30 {
    background-color: #342b18 !important;
}

html[data-theme="dark"] main[class] .text-yellow-200 {
    color: #f1d48c !important;
}

html[data-theme="dark"] main[class] .bg-red-950\/30 {
    background-color: #381f1e !important;
}

html[data-theme="dark"] main[class] .text-red-400 {
    color: #ff918c !important;
}

html[data-theme="dark"] main[class] .bg-green-950\/30 {
    background-color: #1d3022 !important;
}

html[data-theme="dark"] main[class] .text-green-400 {
    color: #91d69d !important;
}

html[data-theme="dark"] main[class] input:not([type="checkbox"]),
html[data-theme="dark"] main[class] select,
html[data-theme="dark"] main[class] textarea {
    color: #f0efed !important;
    background-color: #242424 !important;
    border-color: #4a4844 !important;
}

html[data-theme="dark"] main[class] input::placeholder,
html[data-theme="dark"] main[class] textarea::placeholder {
    color: #aaa7a2;
}

html[data-theme="dark"] main[class] table {
    color: #e4e2de;
}

html[data-theme="dark"] main[class] thead {
    background-color: #292927;
}

html[data-theme="dark"] main[class] tbody tr:hover {
    background-color: #292927;
}

.color-mode-toggle {
    position: fixed;
    z-index: 20;
    right: 22px;
    bottom: 22px;
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border: 1px solid #d0cdc7;
    border-radius: 50%;
    background: #fff;
    color: #171717;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.color-mode-toggle:hover {
    transform: translateY(-2px);
}

html[data-theme="dark"] .color-mode-toggle {
    border-color: #55524d;
    background: #242424;
    color: #f2cf66;
}

html.auth-embedded body {
    display: block;
    min-height: 0;
    padding: 0;
    background: transparent;
}

html.auth-embedded body::before {
    display: none;
}

html.auth-embedded main[class] {
    width: 100%;
    max-width: none;
    border: 0 !important;
    border-radius: 0;
    padding: 18px;
    box-shadow: none;
}

html.auth-embedded .color-mode-toggle {
    display: none;
}

.page-loader {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(9, 9, 9, 0.94);
    color: #f5f5f5;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.page-loader.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.page-loader-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    border: 1px solid #383633;
    border-radius: 8px;
    background: #171717;
    font-size: 14px;
    font-weight: 600;
}

.page-loader-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #555;
    border-top-color: var(--alt-red);
    border-radius: 50%;
    animation: app-loader-spin 0.8s linear infinite;
}

.legal-copy {
    max-width: 72ch;
    margin-inline: auto;
    text-align: justify;
    text-justify: inter-word;
}

.app-page-footer {
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--alt-line);
    text-align: center;
    font-size: 13px;
}

.app-page-footer a {
    color: var(--alt-red);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

@media (max-width: 767px) {
    main[class] {
        border-radius: 5px;
    }

    main[class] > header {
        gap: 12px;
    }

    .legal-copy {
        text-align: left;
    }
}

@media (max-width: 640px) {
    body.min-h-screen {
        align-items: flex-start;
        padding: 8px;
    }

    main[class] {
        width: 100%;
        max-width: 100%;
    }

    main[class] > header {
        align-items: flex-start;
        flex-direction: column;
    }

    main[class] > header > span:last-child {
        display: flex;
        width: 100%;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px 16px;
    }

    main[class] > header > span:last-child > * {
        display: inline-flex;
        min-height: 32px;
        align-items: center;
    }

    .mobile-date-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .mobile-date-controls input[type="date"] {
        min-width: 0;
        flex: 1 1 140px;
    }

    .mobile-report-filters {
        width: 100%;
    }

    .mobile-report-filters > div {
        min-width: 0;
        flex: 1 1 130px;
    }

    .mobile-report-filters input,
    .mobile-report-filters select {
        width: 100%;
        max-width: 100%;
    }

    .mobile-report-actions {
        width: 100%;
    }

    .mobile-report-actions button {
        min-height: 42px;
        flex: 1 1 120px;
    }

    .mobile-report-presets {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .mobile-notices-panel {
        min-height: 0;
    }

    #analytics-chart {
        gap: 4px;
    }

    main[class] .overflow-x-auto {
        max-width: 100%;
    }

    .color-mode-toggle {
        right: 12px;
        bottom: 12px;
        width: 42px;
        height: 42px;
    }

    .page-loader-card {
        max-width: 100%;
        padding: 14px 16px;
        font-size: 13px;
    }
}

@media (max-width: 380px) {
    body.min-h-screen {
        padding: 6px;
    }

    main[class] > header {
        padding-right: 12px;
        padding-left: 12px;
    }

    .mobile-date-controls {
        gap: 6px;
    }

    .mobile-date-controls button {
        padding-right: 8px;
        padding-left: 8px;
    }
}

@keyframes app-page-enter {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    main[class],
    .page-loader,
    .page-loader-spinner {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}

@media (min-width: 1200px) {
    html { font-size: 112.5%; }

    [class~="text-[9px]"] { font-size: .6875rem; }
    [class~="text-[10px]"] { font-size: .75rem; }
    [class~="text-[11px]"] { font-size: .8125rem; }
}
