:root {
    color-scheme: light;
    --background: #f8fafc;
    --foreground: #152033;
    --muted: #5c6b7a;
    --accent: #256f7e;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    color: var(--foreground);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px 24px;
    background: #ffffff;
    border-bottom: 1px solid #dde5ec;
}

.brand {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    color: var(--foreground);
    font-weight: 800;
    text-decoration: none;
}

.brand img {
    display: block;
    width: auto;
    height: 44px;
}

.auth-logo {
    display: block;
    width: min(320px, 100%);
    height: auto;
    margin: 0 0 24px;
}

nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-nav {
    display: none;
}

a {
    color: var(--accent);
}

nav a,
.link-button,
.nav-identity {
    color: var(--foreground);
    font: inherit;
    text-decoration: none;
}

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

.link-button {
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

main {
    width: min(960px, calc(100vw - 40px));
    margin: 0 auto;
    padding: 72px 0 112px;
}

.licence-footer {
    position: fixed;
    right: 18px;
    bottom: 14px;
    left: 18px;
    z-index: 20;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    pointer-events: none;
}

.licence-footer p {
    margin: 0;
    padding: 8px 10px;
    background: rgba(248, 250, 252, 0.92);
    border: 1px solid rgba(221, 229, 236, 0.9);
    border-radius: 6px;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.3;
}

.licence-footer strong {
    color: var(--foreground);
}

.hexela-mark {
    display: inline-flex;
    align-items: center;
    width: 118px;
    padding: 8px 10px;
    background: rgba(248, 250, 252, 0.92);
    border: 1px solid rgba(221, 229, 236, 0.9);
    border-radius: 6px;
    pointer-events: auto;
}

.hexela-mark img {
    display: block;
    width: 100%;
    height: auto;
}

.page-header {
    max-width: 680px;
}

.page-header.compact {
    margin-bottom: 28px;
}

.title-with-icon {
    display: flex;
    align-items: center;
    gap: 16px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(2.25rem, 7vw, 4.5rem);
    line-height: 1;
}

h2,
h3 {
    margin: 0 0 16px;
}

p {
    color: var(--muted);
    font-size: 1.125rem;
    line-height: 1.6;
}

.panel {
    box-sizing: border-box;
    width: 100%;
    padding: 28px;
    background: #ffffff;
    border: 1px solid #dde5ec;
    border-radius: 8px;
}

.panel.narrow {
    max-width: 460px;
}

.admin-layout {
    display: grid;
    gap: 18px;
}

.profile-layout {
    display: grid;
    gap: 18px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.settings-box {
    display: grid;
    align-content: start;
    gap: 18px;
    box-sizing: border-box;
    width: 100%;
    padding: 22px;
    background: #ffffff;
    border: 1px solid #dde5ec;
    border-radius: 8px;
}

.settings-box.wide,
.profile-grid .wide {
    grid-column: 1 / -1;
}

.settings-box h2,
.settings-box h3 {
    margin-bottom: 0;
}

.nested-settings {
    display: grid;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid #dde5ec;
}

.nested-settings p {
    margin: 0;
    font-size: 1rem;
}

.command-box {
    overflow-x: auto;
    padding: 12px;
    background: #f7fafc;
    border: 1px solid #dde5ec;
    border-radius: 6px;
    color: var(--foreground);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.92rem;
    line-height: 1.45;
    white-space: nowrap;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-top: 32px;
}

.stack {
    display: grid;
    gap: 18px;
}

label {
    display: grid;
    gap: 8px;
    color: var(--foreground);
    font-weight: 700;
}

fieldset {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid #c7d2dd;
    border-radius: 8px;
}

legend {
    padding: 0 6px;
    color: var(--foreground);
    font-weight: 800;
}

input,
select,
textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #c7d2dd;
    border-radius: 6px;
    color: var(--foreground);
    font: inherit;
}

input:disabled {
    background: #f1f5f8;
    color: var(--muted);
}

textarea {
    resize: vertical;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check input {
    width: auto;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    background: var(--accent);
    border: 0;
    border-radius: 6px;
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button.secondary,
.button.secondary {
    background: #e8eef2;
    color: var(--foreground);
}

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.page-actions {
    margin: 20px 0 0;
}

.section {
    margin-top: 18px;
}

.server-control {
    display: grid;
    gap: 14px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #dde5ec;
}

.split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.list {
    display: grid;
    gap: 10px;
}

.list-row {
    display: grid;
    gap: 4px;
    padding: 14px;
    border: 1px solid #e4ebf1;
    border-radius: 8px;
    color: var(--foreground);
    text-decoration: none;
}

.list-row:hover {
    border-color: var(--accent);
}

.list-row.unread {
    border-color: var(--accent);
    background: #f2fafb;
}

.attention-panel {
    border-color: #b7d7dd;
}

.attention-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.queue-row {
    align-content: start;
}

.file-row {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
}

.file-row > .actions,
.file-row > .list,
.file-row > form,
.file-row > .button {
    grid-column: 2;
}

.file-icon {
    display: block;
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex: 0 0 auto;
}

.file-icon.large {
    width: 56px;
    height: 56px;
}

.row-main {
    display: grid;
    gap: 4px;
}

.count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6em;
    min-height: 1.6em;
    padding: 0 0.5em;
    background: #e8eef2;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 800;
    vertical-align: middle;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.status-badge.complete {
    background: #e8f6ef;
    color: #146b3a;
}

.list-row small {
    color: var(--muted);
}

.empty-state {
    margin: 0;
    padding: 16px;
    background: #f7fafc;
    border: 1px dashed #cbd8e3;
    border-radius: 8px;
    color: var(--muted);
    font-size: 1rem;
}

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

.form-error {
    padding: 10px 12px;
    background: #fff1f2;
    border: 1px solid #fecdd3;
    border-radius: 6px;
    color: #9f1239;
    font-size: 1rem;
}

.form-success {
    padding: 10px 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    color: #166534;
    font-size: 1rem;
}

.restart-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(21, 32, 51, 0.42);
}

.restart-overlay[hidden] {
    display: none;
}

.restart-dialog {
    width: min(420px, 100%);
    padding: 28px;
    background: #ffffff;
    border: 1px solid #dde5ec;
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(21, 32, 51, 0.22);
}

.restart-dialog h2 {
    margin-bottom: 10px;
}

.restart-dialog p {
    margin: 0;
}

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

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

th,
td {
    padding: 12px;
    border-bottom: 1px solid #e4ebf1;
    text-align: left;
    white-space: nowrap;
}

dl {
    display: grid;
    gap: 12px;
}

dl div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

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

dd {
    margin: 0;
    font-weight: 700;
}

@media (max-width: 760px) {
    .topbar {
        gap: 12px;
        padding: 12px 16px;
    }

    .brand img {
        height: 38px;
    }

    .desktop-nav {
        display: none;
    }

    .mobile-nav {
        display: block;
    }

    .mobile-nav summary {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: #ffffff;
        border: 1px solid #dde5ec;
        border-radius: 8px;
        cursor: pointer;
        list-style: none;
    }

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

    .hamburger-lines {
        display: grid;
        gap: 5px;
        width: 22px;
    }

    .hamburger-lines span {
        display: block;
        height: 2px;
        background: var(--foreground);
        border-radius: 999px;
    }

    .mobile-nav-panel {
        position: absolute;
        top: calc(100% + 8px);
        right: 16px;
        z-index: 30;
        display: grid;
        width: min(260px, calc(100vw - 32px));
        gap: 0;
        padding: 8px;
        background: #ffffff;
        border: 1px solid #dde5ec;
        border-radius: 8px;
        box-shadow: 0 16px 42px rgba(21, 32, 51, 0.16);
    }

    .mobile-nav-panel a,
    .mobile-nav-panel .link-button {
        display: block;
        width: 100%;
        box-sizing: border-box;
        padding: 12px;
        border-radius: 6px;
        color: var(--foreground);
        text-align: left;
    }

    .mobile-nav-panel a:hover,
    .mobile-nav-panel .link-button:hover {
        background: #f2fafb;
    }

    .mobile-nav-panel form {
        margin: 0;
    }

    main {
        width: min(100% - 32px, 960px);
        padding-top: 40px;
    }

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