:root {
    --bg: #0a0710;
    --bg-glow: #1a0f2e;
    --surface: #151121;
    --surface-2: #1c1529;
    --text: #ffffff;
    --muted: #a5a2b5;
    --accent: #9333ea;
    --accent-hover: #a855f7;
    --accent-soft: rgba(147, 51, 234, 0.18);
    --border: #2a2038;
    --border-strong: #3d2f52;
    --danger: #e85d5d;
    --radius: 10px;
    --sidebar-w: clamp(200px, 18vw, 240px);
    --page-pad-x: clamp(0.9rem, 2.2vw, 1.75rem);
    --page-pad-y: clamp(0.85rem, 1.8vw, 1.35rem);
    --font: "Segoe UI", system-ui, sans-serif;
    --text-sm: clamp(0.8rem, 0.75rem + 0.2vw, 0.9rem);
    --text-base: clamp(0.9rem, 0.85rem + 0.25vw, 1rem);
    --text-lg: clamp(1.15rem, 1rem + 0.5vw, 1.4rem);
}

* { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--text-base);
    background:
        radial-gradient(ellipse at top center, var(--bg-glow) 0%, transparent 55%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
}

img, svg, video {
    max-width: 100%;
    height: auto;
}

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1rem;
    background:
        radial-gradient(ellipse at top center, #2a1848 0%, transparent 50%),
        var(--bg);
}

.login-card {
    width: min(400px, 100%);
    padding: clamp(1.25rem, 3vw, 2rem);
    background: linear-gradient(180deg, #1a1426 0%, #151121 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(147, 51, 234, 0.14);
}

.login-card h1 {
    margin: 0 0 0.25rem;
    font-size: var(--text-lg);
    font-weight: 700;
}

.login-sub {
    margin: 0 0 1.25rem;
    color: var(--muted);
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.stack-form > label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: var(--text-sm);
    color: var(--muted);
}

.stack-form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.stack-form textarea,
.stack-form select {
    font: inherit;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: rgba(10, 7, 16, 0.85);
    color: var(--text);
    width: 100%;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.stack-form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):hover,
.stack-form textarea:hover,
.stack-form select:hover {
    border-color: #4a3a63;
}

.stack-form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
.stack-form textarea:focus,
.stack-form select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: #100b18;
}

.stack-form .btn-secondary {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text);
}

.field-block {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.field-label {
    font-size: var(--text-sm);
    color: var(--muted);
}

.password-option {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.15rem;
    width: fit-content;
    max-width: 100%;
    padding: 0.45rem 0.75rem;
    border-radius: 9px;
    border: 1px solid var(--border-strong);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.password-option:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: #5a4875;
}

.password-option.is-checked {
    background: var(--accent-soft);
    border-color: rgba(147, 51, 234, 0.5);
    color: #f3e8ff;
}

.password-option input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.password-option-box {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    background: var(--surface);
    display: inline-grid;
    place-items: center;
}

.password-option.is-checked .password-option-box {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(147, 51, 234, 0.35);
}

.password-option.is-checked .password-option-box::after {
    content: "";
    width: 0.25rem;
    height: 0.45rem;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translateY(-1px);
}

#member-password-block.is-no-password #member-password {
    opacity: 0.45;
    cursor: not-allowed;
}

.role-picker {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0.4rem;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    max-height: min(38vh, 280px);
    overflow: auto;
}

.stack-form .role-chip {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
    padding: 0.45rem 0.55rem;
    border-radius: 8px;
    border: 1px solid transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    user-select: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.stack-form .role-chip:hover {
    background: rgba(255, 255, 255, 0.04);
}

.stack-form .role-chip.is-checked {
    background: var(--accent-soft);
    border-color: rgba(147, 51, 234, 0.45);
}

.stack-form .role-chip input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.role-chip-box {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    border: 1.5px solid var(--border-strong);
    border-radius: 4px;
    background: var(--surface);
    display: inline-grid;
    place-items: center;
}

.stack-form .role-chip.is-checked .role-chip-box {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(147, 51, 234, 0.35);
}

.stack-form .role-chip.is-checked .role-chip-box::after {
    content: "";
    width: 0.25rem;
    height: 0.45rem;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translateY(-1px);
}

.role-chip-text {
    line-height: 1.2;
}

.role-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.muted-dash {
    color: var(--muted);
}

.flash-error,
.flash-ok {
    border-radius: 12px;
    padding: 0.75rem 0.95rem;
    font-size: var(--text-sm);
    font-weight: 500;
    border: 1px solid transparent;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.flash-error {
    color: #ffc9c9;
    background: linear-gradient(180deg, rgba(232, 93, 93, 0.18), rgba(232, 93, 93, 0.08));
    border-color: rgba(232, 93, 93, 0.45);
}

.flash-ok {
    color: #c8f5d6;
    background: linear-gradient(180deg, rgba(39, 174, 96, 0.2), rgba(39, 174, 96, 0.08));
    border-color: rgba(39, 174, 96, 0.45);
    margin-bottom: 1rem;
}

.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.1rem 0.8rem;
    gap: 1.25rem;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 0.4rem;
}

.brand-logo {
    width: 2.6rem;
    height: 2.6rem;
    object-fit: contain;
    border-radius: 8px;
    flex: 0 0 auto;
    filter: drop-shadow(0 0 12px rgba(147, 51, 234, 0.35));
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    background: var(--accent);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    border-radius: 8px;
    box-shadow: 0 0 16px rgba(147, 51, 234, 0.45);
}

.brand-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.login-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 0.85rem;
}

.login-logo {
    width: min(7.5rem, 42vw);
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 8px 24px rgba(147, 51, 234, 0.35));
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
}

.nav-link {
    display: block;
    padding: 0.6rem 0.8rem;
    color: var(--muted);
    text-decoration: none;
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.nav-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.nav-link.is-active {
    color: var(--text);
    border-color: rgba(147, 51, 234, 0.55);
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.28), rgba(147, 51, 234, 0.1));
    box-shadow: 0 0 18px rgba(147, 51, 234, 0.18);
}

.nav-logout {
    color: #ffb4a8;
    background: rgba(232, 93, 93, 0.08);
    border-color: rgba(232, 93, 93, 0.28);
}

.nav-logout:hover {
    color: #ffd4ce;
    background: rgba(232, 93, 93, 0.16);
    border-color: rgba(232, 93, 93, 0.45);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    border-top: 1px solid var(--border);
    padding-top: 0.85rem;
}

.sidebar-user {
    font-size: 0.8rem;
    color: var(--muted);
    padding: 0 0.7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
}

.main-header {
    padding: var(--page-pad-y) var(--page-pad-x) 0.65rem;
    border-bottom: 1px solid var(--border);
}

.main-header h1 {
    margin: 0 auto;
    width: 100%;
    max-width: 1200px;
    font-size: var(--text-lg);
    font-weight: 700;
}

.main-content {
    padding: var(--page-pad-y) var(--page-pad-x) clamp(1.25rem, 3vw, 2rem);
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.85rem 0.7rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table th {
    color: var(--muted);
    font-weight: 600;
    font-size: var(--text-sm);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.data-table tbody tr {
    transition: background 0.15s ease;
}

.data-table tbody tr:hover {
    background: rgba(147, 51, 234, 0.06);
}

.table-link {
    color: var(--accent-hover);
    text-decoration: none;
    font-weight: 600;
}

.table-link:hover {
    text-decoration: underline;
}

.actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    align-items: center;
}

.inline-form {
    display: inline;
}

.empty-state {
    color: var(--muted);
    padding: 0.35rem 0 1rem;
}

.panel-card {
    background: linear-gradient(180deg, rgba(28, 21, 41, 0.95), rgba(21, 17, 33, 0.98));
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: clamp(1rem, 1.8vw, 1.35rem);
    margin-bottom: 1rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}

.panel-card h2 {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
}

.panel-copy {
    margin: 0 0 0.9rem;
    color: var(--muted);
}

.page-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* —— Button system —— */
.btn,
a.btn,
button.btn,
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-soft,
.btn-danger-soft,
.stack-form button[type="submit"] {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.1;
    padding: 0.65rem 1.1rem;
    border-radius: 11px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.15s ease;
}

.btn:active,
a.btn:active,
button.btn:active,
.btn-primary:active,
.btn-secondary:active,
.btn-ghost:active,
.btn-soft:active,
.btn-danger-soft:active,
.stack-form button[type="submit"]:active {
    transform: translateY(1px);
}

.btn-primary,
.stack-form button[type="submit"],
.stack-form .btn-primary,
.modal-actions .btn-primary,
.modal-actions button.btn-primary {
    background: linear-gradient(135deg, #a855f7 0%, #7e22ce 100%);
    border-color: rgba(168, 85, 247, 0.65);
    color: #fff;
    box-shadow:
        0 8px 22px rgba(147, 51, 234, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-primary:hover,
.stack-form button[type="submit"]:hover,
.stack-form .btn-primary:hover,
.modal-actions .btn-primary:hover {
    background: linear-gradient(135deg, #b56bff 0%, #9333ea 100%);
    box-shadow:
        0 10px 28px rgba(147, 51, 234, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-secondary,
.stack-form .btn-secondary,
.modal-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-strong);
    color: var(--text);
    box-shadow: none;
}

.btn-secondary:hover,
.stack-form .btn-secondary:hover,
.modal-actions .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: #5a4875;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
    padding: 0.5rem 0.8rem;
}

.btn-ghost:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.btn-soft {
    background: rgba(147, 51, 234, 0.12);
    border-color: rgba(147, 51, 234, 0.35);
    color: #e9d5ff;
    padding: 0.45rem 0.8rem;
    font-size: 0.82rem;
}

.btn-soft:hover {
    background: rgba(147, 51, 234, 0.22);
    border-color: rgba(168, 85, 247, 0.55);
    color: #fff;
}

.btn-danger-soft {
    background: rgba(232, 93, 93, 0.1);
    border-color: rgba(232, 93, 93, 0.35);
    color: #ffb4a8;
    padding: 0.45rem 0.8rem;
    font-size: 0.82rem;
}

.btn-danger-soft:hover {
    background: rgba(232, 93, 93, 0.2);
    border-color: rgba(232, 93, 93, 0.55);
    color: #ffd4ce;
}

.btn-block {
    width: 100%;
}

.btn-link {
    color: var(--accent-hover);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    text-decoration: none;
}

.btn-danger {
    color: #ffb4a8;
}

.cal-month-label {
    font-size: 1.05rem;
    letter-spacing: 0.01em;
}

.role-tag {
    display: inline-block;
    padding: 0.22rem 0.65rem;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.28), rgba(147, 51, 234, 0.12));
    border: 1px solid rgba(147, 51, 234, 0.4);
    color: #f3e8ff;
    font-size: 0.78rem;
    font-weight: 600;
}

.cal-event {
    display: block;
    width: 100%;
    text-align: left;
    font-size: 0.7rem;
    color: #e9d5ff;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.18rem;
    padding: 0.22rem 0.35rem;
    border: 1px solid rgba(147, 51, 234, 0.28);
    border-radius: 7px;
    background: rgba(147, 51, 234, 0.14);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.cal-event:hover {
    text-decoration: none;
    background: rgba(147, 51, 234, 0.28);
    border-color: rgba(168, 85, 247, 0.55);
}

body.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    place-items: center;
    padding: clamp(0.5rem, 2vw, 1rem);
}

.modal.is-open {
    display: grid;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 4, 12, 0.78);
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: min(480px, 100%);
    max-height: min(92vh, 92dvh);
    overflow: auto;
    background: linear-gradient(180deg, #1a1426 0%, #151121 100%);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    padding: clamp(0.95rem, 1.8vw, 1.3rem) clamp(1rem, 1.8vw, 1.4rem);
    box-shadow:
        0 0 0 1px rgba(147, 51, 234, 0.08),
        0 24px 64px rgba(0, 0, 0, 0.45),
        0 0 48px rgba(147, 51, 234, 0.16);
}

.modal-close {
    width: 2rem;
    height: 2rem;
    display: inline-grid;
    place-items: center;
    font: inherit;
    font-size: 1.25rem;
    line-height: 1;
    border: 1px solid transparent;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.modal-close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-strong);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
    padding-top: 0.35rem;
}

.modal-dialog-wide {
    width: min(980px, 94vw);
    padding: clamp(1.1rem, 2vw, 1.45rem) clamp(1.15rem, 2.2vw, 1.6rem);
}

.modal-dialog-wide .convoy-form {
    gap: 0.7rem;
}

.modal-dialog-wide .convoy-form label {
    gap: 0.28rem;
    font-size: 0.84rem;
}

.modal-dialog-wide .convoy-form input,
.modal-dialog-wide .convoy-form textarea {
    padding: 0.55rem 0.7rem;
    font-size: 0.95rem;
}

.modal-dialog-wide .convoy-form textarea {
    min-height: 6.5rem;
}

.modal-dialog-wide .modal-header h2 {
    font-size: 1.2rem;
}

.form-grid-2,
.form-grid-4 {
    display: grid;
    gap: 0.55rem 0.75rem;
}

.form-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.cal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.cal-head,
.cal-cell {
    background: var(--surface);
    min-height: clamp(3.75rem, 8vh, 5.5rem);
    padding: 0.35rem;
}

.cal-head {
    min-height: 0;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    padding: 0.4rem 0.2rem;
}

.cal-cell.is-muted {
    opacity: 0.45;
}

.cal-daynum {
    display: inline-block;
    color: var(--text);
    text-decoration: none;
    font: inherit;
    font-weight: 600;
    font-size: 0.82rem;
    margin-bottom: 0.25rem;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

.cal-daynum:hover {
    color: var(--accent-hover);
}

/* Large / ultrawide */
@media (min-width: 1400px) {
    .main-header h1,
    .main-content {
        max-width: 1280px;
    }

    .modal-dialog-wide {
        width: min(1040px, 88vw);
    }
}

@media (max-width: 1100px) {
    .form-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0.85rem;
        gap: 0.85rem;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-footer {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .modal-dialog-wide {
        width: min(640px, 96vw);
    }
}

@media (max-width: 700px) {
    .form-grid-2,
    .form-grid-4 {
        grid-template-columns: 1fr;
    }

    .role-picker {
        grid-template-columns: 1fr;
        max-height: min(32vh, 220px);
    }

    .cal-head {
        font-size: 0.65rem;
    }

    .cal-cell {
        min-height: 3.4rem;
        padding: 0.25rem;
    }

    .cal-event {
        font-size: 0.62rem;
    }

    .page-toolbar {
        justify-content: stretch;
    }

    .page-toolbar .btn-primary {
        width: 100%;
    }
}

@media (max-height: 820px) {
    .modal-dialog-wide {
        max-height: 96vh;
        max-height: 96dvh;
    }

    .modal-dialog-wide .convoy-form {
        gap: 0.4rem;
    }

    .modal-dialog-wide .convoy-form textarea {
        min-height: 3.8rem;
    }

    .modal-header {
        margin-bottom: 0.45rem;
    }
}

/* —— DLC matrix —— */
body.app:has(.dlc-matrix),
body.app:has(.dlc-toolbar),
.app:has(.dlc-matrix),
.app:has(.dlc-toolbar) {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

.main:has(.dlc-matrix),
.main:has(.dlc-toolbar) {
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

.main:has(.dlc-matrix) .main-content,
.main:has(.dlc-toolbar) .main-content {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    overflow: hidden;
    padding-bottom: 0.85rem;
}

.dlc-toolbar {
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex: 0 0 auto;
}

.dlc-toolbar-main {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.dlc-meta {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--muted);
}

.dlc-meta-sep {
    opacity: 0.55;
}

.dlc-autosave-hint {
    font-size: var(--text-sm);
    color: var(--muted);
    min-height: 1.2em;
    font-weight: 500;
    white-space: nowrap;
}

.dlc-autosave-hint.is-ok {
    color: #c8f5d6;
}

.dlc-autosave-hint.is-error {
    color: #ffb4a8;
}

.dlc-matrix-wrap {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.55rem 0.55rem 0.7rem;
    overflow: auto;
    margin-bottom: 0;
}

.dlc-matrix {
    width: max-content;
    max-width: 100%;
    min-width: 0;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
}

.dlc-matrix th,
.dlc-matrix td {
    border-bottom: 1px solid rgba(42, 32, 56, 0.9);
}

.dlc-matrix thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: linear-gradient(180deg, #1d1629 0%, #171222 100%);
    vertical-align: bottom;
    padding: 0.55rem 0.18rem 0.4rem;
    border-bottom: 1px solid var(--border-strong);
}

.dlc-col-name {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #171222;
    width: 7.5rem;
    min-width: 7.5rem;
    max-width: 7.5rem;
    text-align: left;
    padding: 0.5rem 0.7rem !important;
}

.dlc-matrix thead .dlc-col-name {
    z-index: 4;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    vertical-align: bottom;
}

.dlc-matrix tbody .dlc-col-name {
    z-index: 1;
    background: #151121;
    font-weight: 600;
}

.dlc-member-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.88rem;
}

.dlc-matrix tbody tr:nth-child(even) .dlc-col-name,
.dlc-matrix tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.015);
}

.dlc-matrix tbody tr:hover .dlc-col-name,
.dlc-matrix tbody tr:hover td {
    background: rgba(147, 51, 234, 0.07);
}

.dlc-col-dlc {
    width: 3.35rem;
    min-width: 3.35rem;
    max-width: 3.35rem;
    text-align: center;
}

.dlc-col-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0.15rem;
    position: relative;
    min-height: 0;
}

.dlc-col-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
    writing-mode: horizontal-tb;
    transform: none;
    white-space: normal;
    word-break: break-word;
    hyphens: auto;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.15;
    text-transform: none;
    letter-spacing: 0;
    color: #efe7ff;
    width: 3.1rem;
    max-height: none;
    text-align: center;
}

.dlc-col-menu-wrap {
    position: relative;
}

.dlc-icon-btn {
    appearance: none;
    width: 1.35rem;
    height: 1.35rem;
    display: inline-grid;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.dlc-icon-btn:hover,
.dlc-col-menu-wrap.is-open .dlc-icon-btn {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-strong);
}

.dlc-col-menu {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 50%;
    transform: translateX(-50%);
    min-width: 9.5rem;
    padding: 0.3rem;
    background: #1c1529;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
    z-index: 12;
}

.dlc-menu-form {
    margin: 0;
}

.dlc-menu-item {
    appearance: none;
    width: 100%;
    display: block;
    text-align: left;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    background: transparent;
    border: 0;
    border-radius: 7px;
    padding: 0.5rem 0.65rem;
    cursor: pointer;
}

.dlc-menu-item:hover {
    background: rgba(147, 51, 234, 0.16);
}

.dlc-menu-item.is-danger {
    color: #ffb4a8;
}

.dlc-menu-item.is-danger:hover {
    background: rgba(232, 93, 93, 0.14);
}

.dlc-cell {
    text-align: center;
    padding: 0.35rem 0.1rem !important;
}

.dlc-check {
    display: inline-grid;
    place-items: center;
    width: 1.7rem;
    height: 1.7rem;
    margin: 0 auto;
    cursor: pointer;
    position: relative;
}

.dlc-check input {
    position: absolute;
    opacity: 0;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
    z-index: 1;
}

.dlc-check-mark {
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 8px;
    border: 1.5px solid #4a3c63;
    background: rgba(10, 7, 16, 0.55);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition:
        background 0.16s ease,
        border-color 0.16s ease,
        box-shadow 0.16s ease,
        transform 0.12s ease;
}

.dlc-check:hover .dlc-check-mark {
    border-color: rgba(168, 85, 247, 0.65);
    transform: translateY(-1px);
}

.dlc-check.is-on .dlc-check-mark,
.dlc-check input:checked + .dlc-check-mark {
    background: linear-gradient(145deg, #b56bff 0%, #7e22ce 100%);
    border-color: rgba(196, 140, 255, 0.85);
    box-shadow:
        0 0 14px rgba(147, 51, 234, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.dlc-check.is-on .dlc-check-mark::after,
.dlc-check input:checked + .dlc-check-mark::after {
    content: "";
    display: block;
    width: 0.28rem;
    height: 0.55rem;
    margin: 0.22rem auto 0;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.dlc-check input:disabled + .dlc-check-mark {
    opacity: 0.5;
}

@media (max-width: 900px) {
    .dlc-col-name {
        width: 6.5rem;
        min-width: 6.5rem;
        max-width: 6.5rem;
        padding-left: 0.5rem !important;
        padding-right: 0.4rem !important;
    }

    .dlc-col-dlc {
        width: 3.1rem;
        min-width: 3.1rem;
        max-width: 3.1rem;
    }

    .dlc-col-title {
        width: 2.9rem;
        font-size: 0.64rem;
    }

    .dlc-check {
        width: 1.55rem;
        height: 1.55rem;
    }

    .dlc-check-mark {
        width: 1.2rem;
        height: 1.2rem;
    }
}

@media (max-width: 720px) {
    body.app:has(.dlc-matrix),
    body.app:has(.dlc-toolbar) {
        overflow: auto;
        height: auto;
    }

    .main:has(.dlc-matrix),
    .main:has(.dlc-toolbar) {
        max-height: none;
        overflow: auto;
    }

    .main:has(.dlc-matrix) .main-content,
    .main:has(.dlc-toolbar) .main-content {
        overflow: visible;
    }

    .dlc-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .dlc-toolbar-main .btn-primary {
        width: 100%;
    }

    .dlc-matrix-wrap {
        overflow: auto;
    }
}