:root {
    --bg: #f0eee8;
    --card: #fdfcf9;
    --line: #d6cfbf;
    --ink: #1f2a24;
    --muted: #5f6a64;
    --accent: #0b9e7a;
    --accent-deep: #0b6f58;
    --danger: #b3433d;
    --shadow: 0 14px 32px rgba(43, 54, 45, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Barlow", sans-serif;
    color: var(--ink);
    background: radial-gradient(1200px 650px at 18% -10%, #dce7db 0%, transparent 60%),
        radial-gradient(1000px 500px at 95% 10%, #efe3cf 0%, transparent 60%),
        var(--bg);
}

.page-shell {
    width: min(1300px, 94vw);
    margin: 1.8rem auto 3rem;
    position: relative;
    z-index: 1;
}

.bg-shape {
    position: fixed;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(48px);
    z-index: 0;
    opacity: 0.55;
}

.shape-a {
    width: 320px;
    height: 320px;
    left: -90px;
    top: 35%;
    background: #d3e6da;
}

.shape-b {
    width: 280px;
    height: 280px;
    right: -60px;
    top: 12%;
    background: #f5dcc4;
}

.header-card {
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: 18px;
    padding: 1.1rem 1.2rem;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1.2rem;
    animation: rise 450ms ease;
}

.page-nav {
    display: flex;
    gap: 0.55rem;
    margin: 0 0 0.7rem;
}

.nav-link {
    display: inline-block;
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.38rem 0.8rem;
    background: #f7f4ed;
    color: var(--ink);
    font-weight: 600;
    font-size: 0.9rem;
}

.nav-link.active {
    background: var(--accent);
    color: #fff;
    border-color: transparent;
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-deep);
    font-weight: 700;
    font-size: 0.72rem;
}

h1 {
    margin: 0.2rem 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
}

.header-note {
    margin: 0;
    color: var(--muted);
}

.meta-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 0.7rem;
}

.meta-panel div {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.6rem 0.7rem;
    background: #f7f4ed;
    min-width: 130px;
}

.meta-panel span {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
}

.meta-panel strong {
    font-size: 1rem;
    font-family: "Space Grotesk", sans-serif;
}

#liveStatus.error {
    color: var(--danger);
}

.toolbar {
    margin-top: 1rem;
    display: flex;
    gap: 0.7rem;
    align-items: center;
}

.toolbar input {
    width: min(420px, 100%);
}

.section-jump {
    margin-top: 1rem;
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
    padding: 0.8rem 0.9rem;
    background: color-mix(in srgb, var(--card) 88%, #edf5ef 12%);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.section-jump-compact {
    display: none;
}

.section-jump-label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.72rem;
    font-weight: 700;
}

.section-jump-select {
    width: 100%;
}

.section-jump-links {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.section-picker-title {
    margin: 0 0 0.5rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.72rem;
    font-weight: 700;
}

.section-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.45rem;
}

.section-picker-btn {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.55rem 0.65rem;
    background: #f7f4ed;
    color: var(--ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    font-weight: 600;
}

.section-picker-btn strong {
    display: inline-flex;
    min-width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    align-items: center;
    justify-content: center;
    background: #e4efe8;
    color: #184838;
    font-size: 0.78rem;
}

.section-view-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.section-view-bar p {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
}

.section-jump-link {
    display: inline-flex;
    align-items: center;
    min-height: 2.3rem;
    padding: 0.38rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #f7f4ed;
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}

.section-jump-link:hover {
    background: #eef5f0;
}

.sections-grid {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
    gap: 1rem;
}

.section-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0.9rem;
    box-shadow: var(--shadow);
    animation: rise 430ms ease;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
}

.section-head-main {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.section-head-actions {
    display: flex;
    gap: 0.45rem;
    align-items: center;
}

.section-head-actions .btn {
    white-space: nowrap;
}

.build-slot {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.completed-sets-input {
    width: 3.2rem;
    flex-shrink: 0;
    text-align: center;
    padding: 0.42rem 0.25rem;
    background: #f1eee6;
    color: var(--muted);
    font-weight: 600;
}

.build-system-blocked {
    position: relative;
    display: inline-flex;
}

.build-system-btn.is-disabled,
.set-built-btn.is-disabled {
    background: #e2e0da;
    color: #8d8a82;
    cursor: not-allowed;
}

.build-system-btn.is-disabled:hover,
.set-built-btn.is-disabled:hover {
    filter: none;
}

.build-tooltip {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    z-index: 70;
    width: max-content;
    max-width: min(320px, calc(100vw - 2rem));
    padding: 0.55rem 0.65rem;
    border-radius: 10px;
    background: color-mix(in srgb, var(--ink) 92%, #ffffff 8%);
    color: #fff;
    font-size: 0.78rem;
    line-height: 1.35;
    box-shadow: 0 12px 24px rgba(25, 31, 27, 0.25);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease;
}

.build-system-blocked:hover .build-tooltip,
.build-system-blocked:focus-within .build-tooltip,
.build-system-blocked.is-open .build-tooltip {
    opacity: 1;
    visibility: visible;
}

.build-tooltip-title {
    margin: 0 0 0.3rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.72rem;
}

.build-tooltip ul {
    margin: 0;
    padding-left: 0.9rem;
    display: grid;
    gap: 0.2rem;
}

.build-tooltip li span {
    display: block;
    color: rgba(255, 255, 255, 0.75);
}

.build-modal-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.25rem;
    max-height: 40vh;
    overflow-y: auto;
}

.build-modal-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.3rem 0.45rem;
    border-radius: 8px;
    background: #f7f4ed;
    font-size: 0.85rem;
}

.section-count {
    flex-shrink: 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.section-toggle {
    min-width: 88px;
    display: none;
}

.section-head h2 {
    margin: 0;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.section-name-input {
    margin: 0;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    padding: 0.2rem 0.35rem;
    font-family: "Space Grotesk", sans-serif;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink);
}

.section-name-input:hover {
    border-color: var(--line);
    background: #f7f4ed;
}

.section-name-input:focus {
    background: #fffefa;
}

.table-wrap {
    overflow-x: hidden;
    margin-top: 0.65rem;
}

.sets-block {
    margin-top: 0.75rem;
    padding: 0.6rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f9f7f1;
}

.sets-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.sets-title {
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.sets-empty {
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.set-list {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.set-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    padding: 0.4rem 0.5rem;
}

.set-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.set-toggle {
    width: 1.7rem;
    height: 1.7rem;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 8px;
    background: #e4efe8;
    color: #184838;
    font-size: 0.75rem;
}

.set-name-input {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    padding: 0.22rem 0.35rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--ink);
}

.set-name-input:hover {
    border-color: var(--line);
    background: #f7f4ed;
}

.set-name-input:focus {
    background: #fffefa;
}

.set-count {
    flex-shrink: 0;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.set-head-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.set-built-count {
    width: 3.2rem;
    text-align: center;
    padding: 0.42rem 0.25rem;
}

.set-card.is-collapsed .set-body {
    display: none;
}

.set-body {
    display: grid;
    gap: 0.35rem;
    margin-top: 0.45rem;
    padding-top: 0.45rem;
    border-top: 1px dashed var(--line);
}

.set-item-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.set-item-select {
    flex: 1 1 auto;
    min-width: 0;
}

.set-item-qty {
    width: 5rem;
    flex-shrink: 0;
    text-align: center;
}

.set-item-qty.is-compact {
    width: 2.95rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.set-row-buttons {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}

.set-row-btn {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
}

table {
    border-collapse: collapse;
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

th,
td {
    border-bottom: 1px solid #e6dfd2;
    text-align: left;
    padding: 0.35rem;
    vertical-align: middle;
}

th {
    font-size: 0.78rem;
    color: var(--muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

th:last-child,
td:last-child {
    width: 86px;
}

th:nth-child(1),
td:nth-child(1) {
    width: 25%;
}

th:nth-child(2),
td:nth-child(2) {
    width: 26%;
}

th:nth-child(3),
td:nth-child(3) {
    width: 17%;
}

th:nth-child(4),
td:nth-child(4) {
    width: 17%;
}

th:nth-child(5),
td:nth-child(5) {
    width: 15%;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.42rem 0.5rem;
    background: #fffefa;
}

input:focus,
select:focus {
    outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
    border-color: var(--accent);
}

.btn,
button {
    border: none;
    border-radius: 9px;
    padding: 0.46rem 0.7rem;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.btn.ghost {
    background: #e4efe8;
    color: #184838;
}

button.danger {
    background: #ecd4d2;
    color: #7e2b28;
    padding: 0.42rem 0.55rem;
}

.danger-solid {
    background: var(--danger);
    color: #fff;
}

.row-actions {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
}

.icon-btn {
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0;
    background: #f4f7f2;
    color: #265646;
}

.icon-btn svg {
    width: 1.05rem;
    height: 1.05rem;
    pointer-events: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn.danger {
    background: #f2dfdd;
    color: #8c2f2d;
}

.icon-btn.danger svg {
    stroke-width: 1.6;
}

.hidden {
    display: none !important;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(22, 28, 24, 0.45);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 80;
}

.modal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, calc(100vw - 2rem));
    z-index: 90;
}

.modal-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 24px 48px rgba(25, 31, 27, 0.3);
    padding: 1rem;
}

.modal-card h2 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.15rem;
}

.modal-meta {
    margin: 0.4rem 0 0.75rem;
    color: var(--muted);
    font-size: 0.9rem;
}

#notesModalInput {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.6rem;
    resize: vertical;
    min-height: 130px;
    background: #fffefa;
}

#notesModalInput:focus {
    outline: 2px solid rgba(11, 158, 122, 0.35);
    border-color: var(--accent);
}

.modal-actions {
    margin-top: 0.75rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.55rem;
}

button:hover {
    filter: brightness(0.97);
}

.toast-host {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(360px, calc(100vw - 1.5rem));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: color-mix(in srgb, var(--ink) 90%, #ffffff 10%);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    box-shadow: 0 14px 30px rgba(18, 24, 20, 0.36);
    padding: 0.68rem 0.78rem;
    font-size: 0.88rem;
    line-height: 1.35;
    animation: toast-in 220ms ease;
}

.toast-exit {
    animation: toast-out 200ms ease forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
}

.audit-card table {
    min-width: 1180px;
    table-layout: auto;
}

.audit-card th:nth-child(1),
.audit-card td:nth-child(1) {
    width: 190px;
}

.audit-card th:nth-child(2),
.audit-card td:nth-child(2) {
    width: 170px;
}

.audit-card th:nth-child(3),
.audit-card td:nth-child(3) {
    width: 90px;
}

.audit-card th:nth-child(4),
.audit-card td:nth-child(4) {
    width: 170px;
}

.audit-card th:nth-child(5),
.audit-card td:nth-child(5) {
    width: 130px;
}

.audit-card th:nth-child(6),
.audit-card td:nth-child(6) {
    width: 210px;
}

.audit-card th:nth-child(7),
.audit-card td:nth-child(7) {
    width: auto;
}

.audit-card th:last-child,
.audit-card td:last-child {
    width: auto;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 940px) {
    .page-shell {
        width: min(100%, calc(100vw - 1rem));
        margin: 0.9rem auto 1.5rem;
    }

    .header-card {
        grid-template-columns: 1fr;
    }

    .meta-panel {
        grid-template-columns: repeat(3, minmax(95px, 1fr));
    }

    .sections-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {

    .page-nav,
    .toolbar,
    .section-head,
    .modal-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .meta-panel {
        grid-template-columns: 1fr;
    }

    .header-note,
    .meta-panel div:last-child,
    .section-jump-links,
    .section-jump-compact {
        display: none;
    }

    .section-jump {
        position: sticky;
        top: 0.55rem;
        z-index: 5;
        display: block;
        padding: 0.7rem;
    }

    .section-picker-grid {
        grid-template-columns: 1fr;
    }

    .section-view-bar {
        justify-content: space-between;
    }

    .section-view-bar .btn {
        width: auto;
    }

    .toolbar {
        gap: 0.5rem;
        margin-top: 0.7rem;
    }

    .toolbar .btn {
        width: 100%;
    }

    .sections-grid {
        gap: 0.6rem;
    }

    .sections-grid.mobile-selection-mode {
        display: none;
    }

    .section-card {
        padding: 0.75rem;
    }

    .section-head-main {
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
    }

    .section-name-input {
        padding: 0.1rem 0.2rem;
        font-size: 0.94rem;
    }

    .section-head-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .build-slot {
        grid-column: 1 / -1;
    }

    .build-slot .btn,
    .build-slot .build-system-blocked {
        width: 100%;
    }

    .build-tooltip {
        left: 0;
        right: 0;
        width: auto;
        max-width: none;
    }

    .set-head {
        flex-wrap: wrap;
    }

    .set-name-input {
        flex: 1 1 60%;
    }

    .set-head-actions {
        flex: 1 1 100%;
        justify-content: space-between;
    }

    .set-head-actions .set-build-slot,
    .set-head-actions .build-system-blocked,
    .set-head-actions .set-built-btn {
        flex: 1 1 auto;
    }

    .set-item-row {
        flex-wrap: wrap;
    }

    .set-item-select {
        flex: 1 1 100%;
    }

    .section-toggle {
        display: inline-block;
    }

    .section-card.is-collapsed .table-wrap,
    .section-card.is-collapsed .sets-block,
    .section-card.is-collapsed .section-head-actions .build-slot,
    .section-card.is-collapsed .section-head-actions .btn[data-action="add-item"] {
        display: none;
    }

    .section-card.is-collapsed .section-head-actions {
        grid-template-columns: 1fr;
    }

    .section-card.is-collapsed {
        padding-bottom: 0.65rem;
    }

    .toast-host {
        left: 0.75rem;
        right: 0.75rem;
        width: auto;
    }

    .table-wrap {
        overflow-x: visible;
    }

    table {
        min-width: 0;
        table-layout: fixed;
    }

    thead {
        display: none;
    }

    tbody {
        display: grid;
        gap: 0.8rem;
    }

    tr {
        display: grid;
        gap: 0.45rem;
        padding: 0.6rem;
        border: 1px solid #e6dfd2;
        border-radius: 14px;
        background: #fffefa;
    }

    td {
        display: grid;
        grid-template-columns: minmax(90px, 110px) minmax(0, 1fr);
        gap: 0.65rem;
        align-items: center;
        border-bottom: none;
        padding: 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.7rem;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        font-weight: 700;
    }

    td:last-child,
    td:nth-child(1),
    td:nth-child(2),
    td:nth-child(3),
    td:nth-child(4),
    td:nth-child(5) {
        width: auto;
    }

    .row-actions {
        position: relative;
        z-index: 1;
        justify-content: flex-start;
    }

    .modal {
        width: calc(100vw - 1rem);
    }
}

/* ---------------------------------------------------------------- */
/* Authentication, app bar and user management                       */
/* ---------------------------------------------------------------- */

.app-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0 0 0.9rem;
}

.app-bar .page-nav {
    margin: 0;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-chip form {
    margin: 0;
}

.user-chip-identity {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.3rem 0.75rem 0.3rem 0.3rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    text-decoration: none;
    color: var(--ink);
    box-shadow: 0 6px 16px rgba(43, 54, 45, 0.08);
}

.user-chip-identity:hover {
    border-color: var(--accent);
}

.user-chip-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.user-chip-text strong {
    font-size: 0.88rem;
}

.user-chip-text small {
    color: var(--muted);
    font-size: 0.72rem;
}

.user-avatar {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: var(--accent-deep);
    color: #fff;
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
}

.user-avatar.small {
    width: 1.8rem;
    height: 1.8rem;
    font-size: 0.85rem;
}

.btn.small {
    padding: 0.32rem 0.62rem;
    font-size: 0.82rem;
}

.btn.block {
    width: 100%;
    padding: 0.65rem 0.8rem;
    font-size: 1rem;
    margin-top: 0.4rem;
}

.btn.ghost.danger {
    background: #f2dfdd;
    color: #8c2f2d;
}

/* Auth pages */

.auth-body .page-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    margin: 0 auto;
}

.auth-shell {
    width: min(430px, 94vw);
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 1.6rem 1.5rem;
    animation: rise 450ms ease;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.9rem;
}

.auth-mark {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    flex: 0 0 auto;
    border-radius: 14px;
    background: linear-gradient(140deg, var(--accent) 0%, var(--accent-deep) 100%);
    color: #fff;
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
}

.auth-brand h1 {
    font-size: 1.28rem;
    margin: 0.1rem 0 0;
}

.auth-intro {
    margin: 0 0 1rem;
    color: var(--muted);
    font-size: 0.93rem;
    line-height: 1.5;
}

.auth-form {
    display: grid;
    gap: 0.35rem;
}

.auth-form label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.55rem;
}

.auth-form input {
    width: 100%;
    padding: 0.6rem 0.7rem;
}

.inline-form {
    max-width: 420px;
}

.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field input {
    padding-right: 4rem;
}

.reveal-btn {
    position: absolute;
    right: 0.35rem;
    background: transparent;
    color: var(--accent-deep);
    font-size: 0.8rem;
    padding: 0.3rem 0.45rem;
}

.auth-links {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.9rem;
}

.auth-links a {
    color: var(--accent-deep);
    font-weight: 600;
}

.auth-footnote {
    margin: 1rem 0 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.82rem;
}

.alert {
    border-radius: 12px;
    padding: 0.65rem 0.8rem;
    font-size: 0.9rem;
    margin-bottom: 0.9rem;
    border: 1px solid transparent;
}

.alert.error {
    background: #fbeceb;
    border-color: #e5c2bf;
    color: #7e2b28;
}

.alert.success {
    background: #e6f5ee;
    border-color: #bcdfd0;
    color: #175943;
}

.alert.warning {
    background: #fbf2e0;
    border-color: #e6d5ac;
    color: #6f5518;
}

.form-feedback {
    margin: 0.7rem 0 0;
    font-size: 0.88rem;
    color: var(--muted);
    word-break: break-word;
}

.form-feedback.error {
    color: #a63b36;
}

.form-feedback.success {
    color: var(--accent-deep);
}

.form-feedback.warning {
    color: #8a6a1d;
}

/* User manager */

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
}

.card-head h2 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.05rem;
}

.card-head input[type="search"] {
    width: min(280px, 100%);
}

.invite-form {
    display: grid;
    grid-template-columns: minmax(200px, 1.3fr) minmax(160px, 1fr) minmax(180px, 1fr) auto;
    gap: 0.6rem;
    align-items: center;
}

.users-table .user-cell {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.users-table .user-cell strong {
    display: block;
    font-size: 0.93rem;
}

.users-table .user-cell small {
    color: var(--muted);
    font-size: 0.78rem;
}

.pill {
    display: inline-block;
    padding: 0.14rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #eceade;
    color: #5b5344;
}

.pill.status-active,
.pill.role-admin {
    background: #dff0e6;
    color: #17593f;
}

.pill.status-invited,
.pill.role-staff {
    background: #e6eefb;
    color: #234a80;
}

.pill.status-disabled {
    background: #f3dedd;
    color: #8c2f2d;
}

.pill.role-viewer {
    background: #f0ece2;
    color: #5f5540;
}

.pill.secret {
    background: #f6e7cd;
    color: #6f5518;
}

.pill.unknown {
    background: #eceae5;
    color: #6b6b66;
}

.secret-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 0.8rem;
}

.secret-grid h3 {
    margin: 0 0 0.45rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.secret-list {
    list-style: none;
    margin: 0;
    padding: 0.6rem 0.7rem;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: #f7f4ed;
    font-family: "Space Grotesk", monospace;
    font-size: 0.85rem;
    display: grid;
    gap: 0.3rem;
    word-break: break-all;
}

.audit-actor {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

#mailStatus.warn {
    color: #8a6a1d;
}

@media (max-width: 820px) {
    .invite-form {
        grid-template-columns: 1fr;
    }

    .app-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .user-chip {
        justify-content: space-between;
    }
}