:root {
    color-scheme: dark;
    --bg: #08090b;
    --bg-alt: #0d0f12;
    --surface: #12161a;
    --surface-2: #171b20;
    --surface-open: rgba(18, 22, 26, 0.78);
    --border: #343a40;
    --border-soft: rgba(167, 163, 154, 0.18);
    --text: #d7d7d2;
    --text-strong: #f1f0ea;
    --muted: #8e9499;
    --primary: #d01818;
    --primary-deep: #841414;
    --steel: #a7a39a;
    --barrel-blue: #27506a;
    --target-tan: #a87945;
    --caution: #c8a33a;
    --danger: #ff4a3d;
    --success: #7d9c68;
    --shadow: rgba(0, 0, 0, 0.48);
    --red-glow: rgba(208, 24, 24, 0.28);
    --radius: 3px;
    --radius-sm: 2px;
    --max-width: 1160px;
    --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 18% -10%, rgba(208, 24, 24, 0.13), transparent 30rem),
        radial-gradient(circle at 85% 8%, rgba(39, 80, 106, 0.22), transparent 28rem),
        radial-gradient(circle at 50% 115%, rgba(168, 121, 69, 0.13), transparent 34rem),
        linear-gradient(180deg, var(--bg-alt), var(--bg) 44%, #050607);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    letter-spacing: 0;
    text-rendering: optimizeLegibility;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        repeating-linear-gradient(100deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 9px),
        repeating-linear-gradient(6deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 38px),
        linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.025), transparent);
    background-size: 180px 180px, 100% 96px, 280px 100%;
    mix-blend-mode: screen;
    opacity: 0.22;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, transparent, black 12%, black 72%, transparent);
    opacity: 0.24;
}

::selection {
    color: var(--text-strong);
    background: rgba(208, 24, 24, 0.5);
}

a {
    position: relative;
    color: var(--text-strong);
    text-decoration: none;
    text-underline-offset: 0.2em;
    transition: color 160ms ease, text-shadow 160ms ease;
}

a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -0.14em;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), var(--steel), transparent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 180ms ease;
}

a:hover,
a:focus-visible {
    color: var(--text-strong);
    text-shadow: 0 0 16px var(--red-glow);
}

a:hover::after,
a:focus-visible::after {
    transform: scaleX(1);
}

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

main {
    width: min(var(--max-width), calc(100% - 32px));
    margin: 0 auto;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 0.6em;
    color: var(--text-strong);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: 0;
}

h1 {
    max-width: 820px;
    font-size: clamp(2.6rem, 7vw, 5.8rem);
}

h2 {
    font-size: clamp(1.6rem, 3.8vw, 2.8rem);
}

h3 {
    font-size: 1.15rem;
    text-transform: uppercase;
}

p {
    margin: 0 0 1rem;
    color: var(--muted);
}

small {
    color: var(--muted);
}

hr,
.divider {
    display: block;
    width: 100%;
    height: 1px;
    margin: 22px 0;
    border: 0;
    background: linear-gradient(90deg, var(--border), rgba(208, 24, 24, 0.42), transparent);
}

.text-muted {
    color: var(--muted) !important;
}

.accent {
    color: var(--primary) !important;
}

.danger {
    color: var(--danger) !important;
}

.steel {
    color: var(--steel) !important;
}

.site-nav,
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 72px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.site-nav {
    position: relative;
}

.nav-menu {
    position: relative;
    margin-left: auto;
}

.nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(0, 0, 0, 0.12)),
        var(--surface-2);
    color: var(--text-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 10px 24px rgba(0, 0, 0, 0.16);
    cursor: pointer;
    user-select: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.nav-toggle::-webkit-details-marker {
    display: none;
}

.nav-toggle::marker {
    content: "";
}

.nav-toggle:hover,
.nav-toggle:focus-visible,
.nav-menu[open] .nav-toggle {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(208, 24, 24, 0.2), 0 0 22px var(--red-glow);
    transform: translateY(-1px);
}

.nav-toggle-lines {
    display: grid;
    gap: 4px;
    width: 20px;
}

.nav-toggle-lines span {
    display: block;
    height: 2px;
    background: var(--steel);
    box-shadow: 0 0 10px rgba(208, 24, 24, 0.18);
    transform-origin: center;
    transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.nav-menu[open] .nav-toggle-lines span {
    background: var(--primary);
}

.nav-menu[open] .nav-toggle-lines span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.nav-menu[open] .nav-toggle-lines span:nth-child(2) {
    opacity: 0;
}

.nav-menu[open] .nav-toggle-lines span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.nav-toggle-label {
    color: var(--steel);
    font-size: 0.76rem;
    font-weight: 850;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 20;
    display: grid;
    width: min(248px, calc(100vw - 32px));
    padding: 8px;
    border: 1px solid var(--border);
    border-top: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
        rgba(13, 15, 18, 0.98);
    box-shadow: 0 22px 44px rgba(0, 0, 0, 0.5), 0 0 28px rgba(208, 24, 24, 0.12);
}

.nav-panel a {
    display: block;
    padding: 11px 12px;
    border-left: 2px solid transparent;
    color: var(--text);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.035em;
}

.nav-panel a:hover,
.nav-panel a:focus-visible {
    border-left-color: var(--primary);
    background: linear-gradient(90deg, rgba(208, 24, 24, 0.12), transparent);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    color: var(--text-strong);
    font-size: clamp(1.7rem, 5vw, 3.8rem);
    font-weight: 900;
    line-height: 0.92;
    letter-spacing: 0;
}

.brand::after {
    display: none;
}

.brand-logo {
    display: block;
    width: clamp(112px, 12vw, 170px);
    height: auto;
    max-height: 58px;
    object-fit: contain;
    filter: drop-shadow(0 0 12px rgba(208, 24, 24, 0.1));
}

.mark {
    position: relative;
    display: grid;
    flex: 0 0 auto;
    width: clamp(42px, 9vw, 68px);
    aspect-ratio: 1;
    place-items: center;
    border: 1px solid var(--steel);
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.65), 0 0 18px rgba(208, 24, 24, 0.08);
}

.mark::before,
.mark::after {
    content: "";
    position: absolute;
    background: var(--steel);
}

.mark::before {
    width: 1px;
    height: 68%;
}

.mark::after {
    width: 68%;
    height: 1px;
}

.dot {
    z-index: 1;
    width: 18%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 18px var(--red-glow);
}

.hero {
    display: grid;
    gap: 18px;
    padding: clamp(18px, 3vw, 34px) 0 clamp(30px, 6vw, 64px);
    border-bottom: 1px solid var(--border);
}

.hero h1 {
    max-width: 880px;
    font-size: clamp(2.15rem, 4.9vw, 4.35rem);
    line-height: 1.06;
}

.hero p {
    max-width: 720px;
    font-size: clamp(1rem, 2vw, 1.22rem);
}

.hero-actions,
.strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.strip span,
.badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid var(--border);
    border-left: 2px solid var(--steel);
    border-radius: var(--radius-sm);
    background: rgba(18, 22, 26, 0.55);
    color: var(--steel);
    font-size: 0.76rem;
    font-weight: 800;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge.accent,
.notice,
.status {
    border-color: rgba(208, 24, 24, 0.6);
    border-left-color: var(--primary);
    color: var(--text-strong) !important;
    background: linear-gradient(90deg, rgba(208, 24, 24, 0.2), rgba(18, 22, 26, 0.64));
}

.status.locked,
.badge.danger {
    border-color: rgba(255, 74, 61, 0.54);
    border-left-color: var(--danger);
    color: #ffd9d5;
}

.panel,
.thin-card,
section.panel,
article.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
        var(--surface-open);
    box-shadow: 0 18px 42px var(--shadow);
}

.panel {
    padding: clamp(18px, 3vw, 28px);
}

.thin-card {
    padding: 16px;
    box-shadow: none;
}

section {
    padding: 28px 0;
}

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

.preview-table-panel {
    grid-column: span 2;
}

.tile strong,
.thin-card strong {
    display: block;
    margin-bottom: 7px;
    color: var(--text-strong);
}

.action-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 14px 0;
    border-top: 1px solid var(--border-soft);
    color: var(--text);
    transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.action-row:first-child {
    border-top-color: var(--border);
}

.action-row:hover,
.action-row:focus-within {
    border-color: rgba(208, 24, 24, 0.62);
    background: linear-gradient(90deg, rgba(208, 24, 24, 0.09), transparent 62%);
    box-shadow: inset 2px 0 0 var(--primary);
    transform: translateY(-1px);
}

.action-row p {
    margin: 0;
}

button,
.button,
.btn,
input[type="button"],
input[type="submit"],
input[type="reset"] {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(0, 0, 0, 0.1)),
        var(--surface-2);
    color: var(--text-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 10px 24px rgba(0, 0, 0, 0.16);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 850;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: border-color 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 160ms ease, background 160ms ease;
}

button:hover,
.button:hover,
.btn:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
input[type="reset"]:hover,
button:focus-visible,
.button:focus-visible,
.btn:focus-visible,
input[type="button"]:focus-visible,
input[type="submit"]:focus-visible,
input[type="reset"]:focus-visible {
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(208, 24, 24, 0.22), 0 0 22px var(--red-glow);
    transform: translateY(-1px);
}

.btn-primary {
    border-color: rgba(208, 24, 24, 0.82);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.18)),
        linear-gradient(90deg, var(--primary-deep), var(--primary));
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--steel);
    box-shadow: none;
}

button:disabled,
.btn:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: 0.54;
    transform: none;
}

form {
    display: grid;
    gap: 14px;
    margin: 0;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--steel);
    font-size: 0.78rem;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    background: rgba(8, 9, 11, 0.78);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: rgba(142, 148, 153, 0.72);
}

input:hover,
select:hover,
textarea:hover {
    border-color: rgba(167, 163, 154, 0.62);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    background: rgba(8, 9, 11, 0.94);
    box-shadow: 0 0 0 3px rgba(208, 24, 24, 0.14), 0 0 22px rgba(208, 24, 24, 0.12);
}

.helptext {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.88rem;
}

ul.errorlist {
    margin: 0;
    padding-left: 18px;
    color: #ff8a80;
}

.alert {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-left: 2px solid var(--caution);
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, rgba(200, 163, 58, 0.14), rgba(18, 22, 26, 0.7));
    color: var(--text);
}

.alert-danger {
    border-left-color: var(--danger);
    background: linear-gradient(90deg, rgba(208, 24, 24, 0.18), rgba(18, 22, 26, 0.7));
}

table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text);
    font-size: 0.94rem;
}

caption {
    padding: 0 0 12px;
    color: var(--steel);
    text-align: left;
    font-weight: 800;
    text-transform: uppercase;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--steel);
    font-size: 0.74rem;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody tr {
    transition: background 160ms ease, box-shadow 160ms ease;
}

tbody tr:hover {
    background: linear-gradient(90deg, rgba(208, 24, 24, 0.09), rgba(39, 80, 106, 0.08), transparent);
    box-shadow: inset 2px 0 0 var(--primary);
}

.table-wrap {
    overflow-x: auto;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.caution-stripe {
    height: 6px;
    background: repeating-linear-gradient(
        135deg,
        var(--caution) 0 12px,
        #17120a 12px 24px
    );
}

.site-home {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 28px 0;
}

.site-home main {
    display: grid;
    gap: 26px;
}

.site-home .brand {
    font-size: clamp(2.4rem, 8vw, 5rem);
}

.site-home .brand-logo {
    width: clamp(128px, 18vw, 190px);
    max-height: 66px;
}

.notice {
    display: inline-flex;
    width: fit-content;
    max-width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-shell main,
.preview-shell main {
    padding-bottom: 56px;
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 28px 16px;
}

.auth-shell main {
    display: grid;
    width: min(440px, 100%);
    gap: 16px;
}

.auth-shell .brand {
    justify-content: center;
    text-align: center;
}

.auth-shell .brand-logo {
    width: clamp(130px, 34vw, 180px);
    max-height: 62px;
}

.auth-shell .panel {
    display: grid;
    gap: 14px;
}

@media (max-width: 760px) {
    main {
        width: min(100% - 24px, var(--max-width));
    }

    .site-nav {
        align-items: center;
        flex-direction: row;
    }

    header:not(.site-nav) {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav-toggle-label {
        display: none;
    }

    .nav-toggle {
        min-width: 44px;
        padding: 10px;
    }

    .hero {
        padding-top: 18px;
    }

    .range-grid,
    .grid {
        grid-template-columns: 1fr;
    }

    .preview-table-panel {
        grid-column: auto;
    }

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

    th,
    td {
        padding: 10px 8px;
        white-space: nowrap;
    }

    button,
    .button,
    .btn,
    input[type="submit"] {
        width: 100%;
    }

    .hero-actions .btn,
    .hero-actions button,
    .hero-actions .button {
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
    }

    a::after {
        transition: none;
    }

    button:hover,
    .button:hover,
    .btn:hover,
    .action-row:hover {
        transform: none;
    }
}
