:root {
    --bg: #080a0c;
    --bg-elevated: #0c0f12;
    --bg-soft: #101418;
    --line: rgba(210, 225, 230, 0.14);
    --line-strong: rgba(210, 225, 230, 0.28);
    --text: #e6ecef;
    --muted: #8a969f;
    --accent: #2ec4b6;
    --accent-dim: rgba(46, 196, 182, 0.55);
    --danger: #e86a76;
    --success: #5ddea0;
    --radius: 2px;
    --font-display: "Syne", sans-serif;
    --font-body: "Instrument Sans", sans-serif;
    --grid-size: 48px;
    --grid-color: rgba(210, 225, 230, 0.045);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--text);
    background-color: var(--bg);
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);
    background-attachment: fixed;
    line-height: 1.55;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.site-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem clamp(1.2rem, 4vw, 3rem);
    border-bottom: 1px solid transparent;
}

.brand {
    display: inline-flex;
    align-items: center;
    line-height: 0;
}

.brand img {
    width: auto;
    height: 2.15rem;
}

.brand-sidebar {
    display: inline-flex;
    margin-bottom: 1.75rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--line);
    width: 100%;
}

.brand-sidebar img {
    height: 2.25rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 0.7rem 1.15rem;
    font: inherit;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.15s linear, border-color 0.15s linear, color 0.15s linear;
}

.btn-primary {
    background: var(--accent);
    color: #041210;
    border-color: var(--accent);
}

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

.btn-ghost {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--text);
}

.btn-ghost:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: transparent;
    border-color: rgba(232, 106, 118, 0.45);
    color: var(--danger);
}

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

.btn-small {
    padding: 0.4rem 0.75rem;
    font-size: 0.88rem;
}

/* —— Hero / blueprint —— */
.hero {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    align-items: end;
    padding: clamp(5rem, 12vh, 8rem) clamp(1.2rem, 4vw, 3rem) clamp(2.5rem, 6vh, 4rem);
    position: relative;
}

.hero-frame {
    position: absolute;
    inset: clamp(4.5rem, 8vh, 5.5rem) clamp(1rem, 3vw, 2rem) clamp(1rem, 3vw, 2rem);
    pointer-events: none;
    border: 1px solid var(--line);
    animation: fade-in 0.7s linear both;
}

.hero-ticks {
    position: absolute;
    inset: 0;
}

.hero-frame::before,
.hero-frame::after,
.hero-ticks span {
    position: absolute;
    width: 14px;
    height: 14px;
    border-color: var(--accent-dim);
    border-style: solid;
}

.hero-frame::before {
    content: "";
    top: -1px;
    left: -1px;
    border-width: 2px 0 0 2px;
}

.hero-frame::after {
    content: "";
    top: -1px;
    right: -1px;
    border-width: 2px 2px 0 0;
}

.hero-ticks span:nth-child(1) {
    bottom: -1px;
    left: -1px;
    border-width: 0 0 2px 2px;
}

.hero-ticks span:nth-child(2) {
    bottom: -1px;
    right: -1px;
    border-width: 0 2px 2px 0;
}

.hero-content {
    position: relative;
    max-width: 720px;
    animation: fade-in 0.55s linear 0.12s both;
}

.hero-brand {
    display: block;
    width: min(100%, 18rem);
    height: auto;
    margin: 0 0 1.1rem;
    transform: translate(var(--grid-size), calc(var(--grid-size) * -0.5));
}

.hero h1 {
    font-family: var(--font-body);
    font-size: clamp(1.35rem, 2.8vw, 1.95rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.45;
    margin: 0 0 0.75rem;
    max-width: 22ch;
}

.hero-content > p {
    margin: 0 0 1.75rem;
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 40ch;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.section {
    padding: clamp(3.5rem, 8vh, 5.5rem) clamp(1.2rem, 4vw, 3rem);
    border-top: 1px solid var(--line);
}

.section-inner {
    max-width: 1100px;
    margin: 0 auto;
}

.section-label {
    display: inline-block;
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 0.85rem;
    font-weight: 600;
}

.section h2 {
    font-family: var(--font-display);
    font-size: clamp(1.65rem, 2.8vw, 2.15rem);
    letter-spacing: -0.03em;
    margin: 0 0 0.55rem;
    font-weight: 700;
}

.section > .section-inner > p,
.lede {
    color: var(--muted);
    margin: 0 0 2rem;
    max-width: 48ch;
}

.module-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border: 1px solid var(--line);
}

.module-grid li {
    padding: 1.35rem 1.2rem;
    border-right: 1px solid var(--line);
    animation: fade-in 0.45s linear both;
}

.module-grid li:last-child {
    border-right: none;
}

.module-grid li:nth-child(2) { animation-delay: 0.08s; }
.module-grid li:nth-child(3) { animation-delay: 0.16s; }

.module-index {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    color: var(--accent-dim);
    margin-bottom: 0.65rem;
    font-family: var(--font-body);
}

.module-grid strong {
    display: block;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.4rem;
}

.module-grid span {
    color: var(--muted);
    font-size: 0.95rem;
}

.site-footer {
    padding: 1.5rem clamp(1.2rem, 4vw, 3rem) 2.5rem;
    color: var(--muted);
    font-size: 0.88rem;
    border-top: 1px solid var(--line);
    letter-spacing: 0.02em;
}

/* —— Auth —— */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: min(400px, 100%);
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.75rem;
    position: relative;
    animation: fade-in 0.4s linear both;
}

.auth-card::before,
.auth-card::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    border-color: var(--accent-dim);
    border-style: solid;
}

.auth-card::before {
    top: -1px;
    left: -1px;
    border-width: 2px 0 0 2px;
}

.auth-card::after {
    bottom: -1px;
    right: -1px;
    border-width: 0 2px 2px 0;
}

.auth-card .brand {
    display: inline-flex;
    margin-bottom: 0.35rem;
}

.auth-card .brand img {
    height: 2.1rem;
}

.auth-card h1 {
    font-family: var(--font-display);
    margin: 1rem 0 0.3rem;
    font-size: 1.55rem;
    letter-spacing: -0.03em;
    font-weight: 700;
}

.auth-card .muted {
    color: var(--muted);
    margin: 0 0 1.35rem;
    font-size: 0.95rem;
}

.form-stack {
    display: grid;
    gap: 1rem;
}

label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.88rem;
    color: var(--muted);
    letter-spacing: 0.02em;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    padding: 0.7rem 0.8rem;
    font: inherit;
    outline: none;
    transition: border-color 0.15s linear;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
}

.alert {
    border-radius: var(--radius);
    padding: 0.7rem 0.85rem;
    margin-bottom: 1rem;
    font-size: 0.92rem;
    border: 1px solid var(--line);
}

.alert-error {
    border-color: rgba(232, 106, 118, 0.45);
    color: #ffb3bb;
    background: transparent;
}

.alert-success {
    border-color: rgba(93, 222, 160, 0.4);
    color: #b8f0d2;
    background: transparent;
}

/* —— App shell —— */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 240px 1fr;
}

.sidebar {
    background: var(--bg-elevated);
    border-right: 1px solid var(--line);
    padding: 1.35rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.side-nav {
    display: grid;
    gap: 0.15rem;
    flex: 1;
}

.side-nav a {
    padding: 0.6rem 0.7rem;
    border-radius: var(--radius);
    color: var(--muted);
    border-left: 2px solid transparent;
    transition: color 0.15s linear, border-color 0.15s linear, background 0.15s linear;
}

.side-nav a:hover {
    color: var(--text);
    background: transparent;
}

.side-nav a.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: transparent;
}

.sidebar-foot {
    display: grid;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.user-chip {
    display: grid;
    gap: 0.1rem;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.user-role {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.app-main {
    padding: clamp(1.35rem, 2.5vw, 2.25rem);
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.page-header h1 {
    font-family: var(--font-display);
    margin: 0;
    font-size: clamp(1.55rem, 2.8vw, 2rem);
    letter-spacing: -0.03em;
    font-weight: 700;
}

.page-header p {
    margin: 0.3rem 0 0;
    color: var(--muted);
}

.panel {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.15rem;
}

.panel-title {
    font-family: var(--font-display);
    margin: 0 0 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
}

.checkbox-row input {
    width: auto;
}

.inline-form {
    display: inline;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0;
    border: 1px solid var(--line);
}

.app-item {
    background: var(--bg-elevated);
    border: none;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    padding: 1.25rem;
    display: grid;
    gap: 0.7rem;
    transition: background 0.15s linear;
    animation: fade-in 0.4s linear both;
}

.app-item:hover {
    background: var(--bg-soft);
}

.app-item h2 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    margin: 0;
    letter-spacing: -0.02em;
    font-weight: 700;
}

.app-item p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.table-wrap {
    overflow-x: auto;
}

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

table.data th,
table.data td {
    text-align: left;
    padding: 0.8rem 0.65rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

table.data th {
    color: var(--muted);
    font-weight: 500;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius);
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid var(--line);
    color: var(--muted);
}

.badge-admin {
    color: var(--accent);
    border-color: var(--accent-dim);
}

.badge-inactive {
    color: var(--danger);
    border-color: rgba(232, 106, 118, 0.45);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.form-grid {
    display: grid;
    gap: 1rem;
    max-width: 480px;
}

.split-forms {
    display: grid;
    gap: 0;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    border: 1px solid var(--line);
}

.split-forms .panel {
    border: none;
    border-radius: 0;
    border-right: 1px solid var(--line);
}

.split-forms .panel:last-child {
    border-right: none;
}

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

.back-link {
    color: var(--muted);
    font-size: 0.9rem;
}

.back-link:hover {
    color: var(--accent);
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 860px) {
    .site-header .btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.88rem;
    }

    body.page-home {
        min-height: 100svh;
        display: flex;
        flex-direction: column;
    }

    body.page-home .hero {
        flex: 1 1 auto;
        min-height: 0;
        padding: 4.75rem 2rem 2rem;
    }

    body.page-home .site-footer {
        flex-shrink: 0;
        padding: 0.85rem 1.2rem 1.1rem;
    }

    .hero-frame {
        inset: 4.25rem 0.85rem 0.85rem;
    }

    .hero-brand {
        width: min(100%, 14rem);
        margin-bottom: 0.9rem;
    }

    .hero h1 {
        font-size: 1.25rem;
        margin-bottom: 0.55rem;
    }

    .hero-content > p {
        margin-bottom: 1.15rem;
        font-size: 0.98rem;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .side-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-bottom: 1rem;
    }

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

    .module-grid li {
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .module-grid li:last-child {
        border-bottom: none;
    }

    .app-item {
        border-right: none;
    }

    .split-forms .panel {
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .split-forms .panel:last-child {
        border-bottom: none;
    }
}

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