* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f3f4f6;
    color: #111827;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px;
}

.card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    padding: 24px;
}

#login-view {
    max-width: 420px;
    margin: 80px auto 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid #d1d5db;
}

.tab {
    background: transparent;
    color: #6b7280;
    border-radius: 10px 10px 0 0;
    padding: 10px 16px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

    .tab:hover {
        color: #111827;
        background: #e5e7eb;
    }

    .tab.active {
        color: #2563eb;
        background: #eff6ff;
        border-bottom-color: #2563eb;
    }

.tab-panel {
    margin-top: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

    .panel-header h2 {
        margin: 0;
    }

.search-field {
    display: flex;
    align-items: center;
    gap: 16px;
}

    .search-field input[type="search"] {
        flex: 1;
    }

    .search-field .checkbox-row {
        white-space: nowrap;
    }

.row-count {
    margin: 0 0 0px;
    font-size: 0.8rem;
    text-align: right;
}

.stack {
    display: grid;
    gap: 14px;
    margin-bottom: 0;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.modal-dialog {
    position: relative;
    width: min(100%, 440px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    z-index: 1;
}

#version-modal .modal-dialog {
    width: min(100%, 800px);
}

#user-modal .modal-dialog {
    width: min(100%, 820px);
}

.user-form-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: stretch;
}

@media (max-width: 720px) {
    .user-form-columns {
        grid-template-columns: 1fr;
    }
}

.user-side-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.user-side-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #d1d5db;
}

.user-side-tab {
    background: transparent;
    color: #6b7280;
    border-radius: 10px 10px 0 0;
    padding: 8px 12px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

    .user-side-tab:hover {
        color: #111827;
        background: #e5e7eb;
    }

    .user-side-tab.active {
        color: #2563eb;
        background: #eff6ff;
        border-bottom-color: #2563eb;
    }

    .user-side-tab:disabled,
    .user-side-tab:disabled:hover {
        color: #9ca3af;
        background: transparent;
        cursor: not-allowed;
    }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

    .modal-header h2 {
        margin: 0;
    }

.modal-close {
    min-width: 36px;
    padding: 6px 10px;
    font-size: 1.25rem;
    line-height: 1;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 600;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

    .checkbox-row input {
        width: auto;
    }

.license-options {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
}

.list-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

    /* The list is taken out of flow so a long one cannot inflate the grid row
       and push the second column past the first one. */
    .list-section .list-scroll {
        position: relative;
        flex: 1;
        min-height: 180px;
    }

    .list-section .list-scroll-inner {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    /* Height follows the rows so the add row sits right below the last one,
           then shrinks and scrolls once the rows run out of room. */
    .list-section .table-wrap {
        min-height: 0;
        overflow-y: auto;
    }

    .list-section .list-add-row {
        flex-shrink: 0;
    }

    .list-section h3 {
        margin: 0;
        font-size: 1rem;
    }

.list-add-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

    .list-add-row input {
        flex: 1;
    }

.license-form-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.license-mode {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
    font: inherit;
    resize: vertical;
}

@media (max-width: 720px) {
    .license-form-columns {
        grid-template-columns: 1fr;
    }
}

input,
button {
    font: inherit;
}

input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
}

button {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
}

    button.secondary {
        background: #e5e7eb;
        color: #111827;
    }

    button.danger {
        background: #dc2626;
    }

    button.success {
        background: #16a34a;
    }

    button.warning {
        background: #fef3c7;
        color: #dd4703;
    }

    button:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

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

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

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

th,
td {
    text-align: left;
    padding: 12px 8px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}

#panel-users tbody tr:nth-child(odd) {
    background: #f3f4f6;
}

#panel-users tbody tr.auto-added {
    background: #fef3c7;
}

#panel-users tbody tr.deleted {
    background: #fee2e2;
    color: #6b7280;
}

#panel-users th,
#panel-users td,
#panel-administrators th,
#panel-administrators td,
#panel-versions th,
#panel-versions td {
    vertical-align: middle;
}

td a {
    color: #2563eb;
    text-decoration: none;
}

    td a:hover {
        text-decoration: underline;
    }

.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

td:last-child,
th:last-child {
    text-align: right;
}

.muted {
    color: #6b7280;
}

.error,
.error-banner {
    color: #b91c1c;
    background: #fee2e2;
    border-radius: 10px;
    padding: 10px 12px;
}
