:root {
    --bg: #eceff4;
    --panel: rgba(255, 255, 255, 0.78);
    --stroke: #d7dde6;
    --stroke2: #c5cdd8;
    --text: #1f2937;
    --muted: #5b6572;
    --muted2: #7a8593;
    --accent: #6b7280;
    --accent-blue: #3f648e;
    --accent-blue-dark: #314f72;
    --danger: #dc2626;
    --ok: #16a34a;
    --r: 10px;
    --blur: 18px;
    --shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --tool-card-size: 200px;
    --tool-grid-gap: 8px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(1200px 700px at 10% -10%, rgba(255, 255, 255, 0.75), transparent 52%),
        radial-gradient(900px 500px at 100% 100%, rgba(209, 216, 226, 0.55), transparent 56%),
        var(--bg);
}

.container {
    width: min(1120px, 92%);
    margin: 0 auto;
}

.container--full {
    width: 100%;
    margin: 0;
    padding: 0 10px;
}

.topbar {
    border-bottom: 1px solid #d1d8e2;
    background: rgba(247, 249, 252, 0.88);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    position: relative;
    z-index: 1000;
}

.topbar-inner {
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0;
}

.topbar-inner--full {
    width: 100%;
    padding: 0 10px;
}

.topbar-left {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.brand {
    color: var(--text);
    font-weight: 600;
    letter-spacing: 0;
    white-space: nowrap;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.brand-home-link {
    text-decoration: none;
    color: inherit;
    display: inline-flex;
    align-items: center;
}

.brand-home {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.brand-home img {
    display: block;
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.brand-text {
    color: var(--text);
}

.topbar-title-menu-btn {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--text);
    padding: 0 4px;
}

.topbar-title-menu-dropdown {
    min-width: 190px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-actions form {
    margin: 0;
}

.topbar-user {
    font-size: 11px;
    height: 24px;
    padding: 0 2px;
    color: #445066;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-weight: 600;
}

.topbar-menu {
    position: relative;
    z-index: 1100;
}

.topbar-menu-btn {
    height: 24px;
    padding: 0 6px;
    border-radius: 7px;
    border: 0;
    background: transparent;
    color: #2f3b4b;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}

.topbar-menu-btn:hover {
    background: rgba(225, 232, 241, 0.8);
}

.topbar-menu-btn:focus-visible,
.topbar-menu-btn[aria-expanded="true"] {
    background: rgba(225, 232, 241, 0.92);
    outline: none;
}

.topbar-menu-dropdown {
    position: absolute;
    left: 0;
    top: 100%;
    min-width: 180px;
    padding: 5px;
    margin-top: 2px;
    border: 1px solid #cfd6df;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(14px) saturate(115%);
    -webkit-backdrop-filter: blur(14px) saturate(115%);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(2px);
    transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}

.topbar-menu:hover .topbar-menu-dropdown,
.topbar-menu:focus-within .topbar-menu-dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.topbar-menu-item {
    width: 100%;
    height: 24px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #2f3b4b;
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    padding: 0 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    text-decoration: none;
}

.topbar-menu-item:hover {
    background: #eceff4;
}

.topbar-menu-divider {
    height: 1px;
    margin: 4px 6px;
    background: #d9e0e8;
}

.topbar-menu-link {
    color: #2f3b4b;
}

.topbar-menu-item--disabled {
    color: #a2acb8;
    cursor: not-allowed;
}

body.settings-overlay-open {
    overflow: hidden;
}

.settings-overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(30, 41, 59, 0.22);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 20000;
    display: grid;
    place-items: center;
    padding: 20px;
}

.settings-overlay-backdrop[hidden] {
    display: none !important;
}

.app-dialog-backdrop[hidden] {
    display: none !important;
}

.settings-overlay-modal {
    width: 80vw;
    max-height: 88vh;
    border: 1px solid #cfd6df;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.app-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(30, 41, 59, 0.22);
    z-index: 21000;
    display: grid;
    place-items: center;
    padding: 20px;
}

.app-dialog {
    width: min(420px, 92vw);
    border: 1px solid #cfd6df;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
    overflow: hidden;
}

.app-dialog--wide {
    width: min(520px, 94vw);
}

.app-dialog-head {
    height: 36px;
    border-bottom: 1px solid #dbe2ea;
    background: #f5f7fb;
    padding: 0 10px;
    display: flex;
    align-items: center;
}

.app-dialog-title {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: #2f3b4b;
}

.app-dialog-body {
    padding: 12px 12px 8px;
}

.app-dialog-message {
    margin: 0;
    color: #2f3b4b;
    font-size: 12px;
    line-height: 1.4;
}

.app-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px 12px 12px;
}

.settings-overlay-head {
    height: 36px;
    border-bottom: 1px solid #dbe2ea;
    background: #f5f7fb;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-overlay-title {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: #2f3b4b;
}

.settings-overlay-close {
    height: 24px;
    border: 1px solid #cfd6df;
    border-radius: 6px;
    background: #f4f6f9;
    color: #2f3b4b;
    font-size: 11px;
    padding: 0 8px;
    cursor: pointer;
}

.settings-overlay-close:hover {
    background: #eceff4;
}

.settings-overlay-body {
    overflow: auto;
    padding: 12px;
}

.settings-screen h3 {
    margin: 0 0 6px;
    font-size: 13px;
}

.settings-screen p {
    margin: 0 0 10px;
    color: #5b6572;
    font-size: 11px;
}

.settings-screen--full {
    height: min(74vh, 760px);
}

.settings-rights-form {
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.settings-placeholder-list {
    border: 1px solid #d8e0ea;
    border-radius: 8px;
    overflow: hidden;
}

.settings-placeholder-list--wide {
    height: min(52vh, 520px);
    overflow: auto;
}

.settings-placeholder-row {
    min-height: 30px;
    border-bottom: 1px solid #e2e8f0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    font-size: 11px;
    color: #48566b;
    background: #fff;
}

.settings-placeholder-row--users {
    min-width: 980px;
    grid-template-columns: 120px 140px 240px 130px 150px 120px 180px;
}

.settings-users-table-wrap,
.settings-projects-table-wrap {
    height: min(52vh, 520px);
    overflow: auto;
    border: 1px solid #d8e0ea;
    border-radius: 8px;
    background: #fff;
}

.settings-users-table,
.settings-projects-table {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
    table-layout: fixed;
}

.settings-users-table th,
.settings-users-table td,
.settings-projects-table th,
.settings-projects-table td {
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 10px;
    height: 30px;
    font-size: 11px;
    color: #48566b;
    white-space: nowrap;
}

.settings-users-table th,
.settings-projects-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f6f8fb;
    font-weight: 600;
    text-align: left;
}

.settings-users-table tfoot td,
.settings-projects-table tfoot td {
    background: #f8fafc;
}

.settings-users-table th:last-child,
.settings-users-table td:last-child,
.settings-projects-table th:last-child,
.settings-projects-table td:last-child {
    border-right: 0;
}

.settings-users-table th:first-child,
.settings-users-table td:first-child,
.settings-projects-table th:first-child,
.settings-projects-table td:first-child {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
    padding-left: 2px;
    padding-right: 2px;
    text-align: center;
}

.settings-users-table th:nth-child(2),
.settings-users-table td:nth-child(2) {
    width: 64px;
    min-width: 64px;
    max-width: 64px;
    padding-left: 2px;
    padding-right: 2px;
    text-align: center;
}

.settings-col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
}

.settings-delete-user-btn,
.settings-add-user-btn {
    width: 22px;
    height: 22px;
    border: 1px solid #d4dce6;
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.settings-delete-user-btn {
    width: auto;
    height: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
    color: #c62828;
    font-size: 16px;
}

.settings-delete-user-btn:hover {
    background: transparent;
    color: #a51d1d;
}

.settings-delete-placeholder {
    color: #a2acb8;
    font-size: 11px;
}

.settings-add-user-btn {
    color: #1f3f6b;
    border-color: #c2cfde;
    background: #f4f7fb;
}

.settings-add-user-btn:hover {
    background: #e9eff7;
}

.settings-inline-input,
.settings-inline-select {
    width: 100%;
    height: 24px;
    border: 1px solid #cfd6df;
    border-radius: 6px;
    background: #fff;
    color: #2f3b4b;
    font-size: 11px;
    padding: 0 6px;
}

.settings-inline-note {
    font-size: 10px;
    color: #64748b;
}

.settings-login-manage-btn {
    min-width: 64px;
    height: 22px;
    font-size: 10px;
    padding: 0 6px;
}

.settings-login-grid {
    display: grid;
    gap: 10px;
}

.settings-login-field {
    display: grid;
    gap: 4px;
}

.settings-login-label {
    font-size: 11px;
    color: #5b6572;
    font-weight: 500;
}

.settings-login-value {
    min-height: 24px;
    display: flex;
    align-items: center;
    font-size: 12px;
    color: #2f3b4b;
}

.settings-login-help {
    font-size: 10px;
    color: #6b7685;
    line-height: 1.35;
}

.settings-login-password-indicator {
    font-size: 10px;
    color: #4f5e72;
}

.settings-login-password-indicator.has-password {
    color: #b42318;
}

.settings-login-password-indicator.no-password {
    color: #4f5e72;
    font-size: 10px;
}

.settings-login-actions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.settings-planboard-checkbox {
    width: 14px;
    height: 14px;
    accent-color: #9aa6b7;
    cursor: pointer;
}

body.settings-resizing {
    cursor: col-resize;
    user-select: none;
}

.settings-placeholder-row:first-child {
    background: #f6f8fb;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.settings-placeholder-row:last-child {
    border-bottom: 0;
}

.settings-manage-form {
    margin: 0;
}

.settings-select {
    width: 100%;
    min-width: 180px;
    height: 24px;
    border: 1px solid #cfd6df;
    border-radius: 6px;
    background: #fff;
    color: #2f3b4b;
    font-size: 11px;
    padding: 0 6px;
}

.settings-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.settings-actions--left {
    justify-content: flex-start;
}

.settings-file-input {
    display: none;
}

.settings-import-status {
    min-height: 18px;
    margin: 8px 0 10px;
    font-size: 11px;
    color: #5b6572;
}

.settings-import-status.success {
    color: #166534;
}

.settings-import-status.error {
    color: #991b1b;
}

.settings-screen-status {
    min-height: 18px;
    margin: 4px 0 10px;
    font-size: 11px;
    color: #5b6572;
}

.settings-screen-status.success {
    color: #166534;
}

.settings-screen-status.error {
    color: #991b1b;
}

.settings-import-progress {
    margin: 0 0 10px;
}

.settings-import-progress-track {
    height: 8px;
    border: 1px solid #ccd5e0;
    border-radius: 999px;
    background: #f3f6fa;
    overflow: hidden;
}

.settings-import-progress-fill {
    height: 100%;
    width: 0%;
    background: #3f648e;
    transition: width 180ms linear;
}

.settings-import-progress-fill.is-busy {
    background-image: linear-gradient(90deg, #3f648e 0%, #5d7ea5 40%, #3f648e 100%);
    background-size: 160px 100%;
    animation: settingsImportBusy 0.9s linear infinite;
}

.settings-import-progress-text {
    margin-top: 4px;
    font-size: 10px;
    color: #607087;
}

@keyframes settingsImportBusy {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 160px 0;
    }
}

.settings-empty {
    font-size: 11px;
    color: #5b6572;
    padding: 8px;
    border: 1px solid #d8e0ea;
    border-radius: 8px;
    background: #f7f9fc;
}

.topbar-user-icon {
    width: 18px;
    height: 18px;
    color: #607087;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topbar-logout-form {
    margin: 0;
}

.topbar-logout-btn {
    width: 24px;
    height: 24px;
    border: 0;
    background: transparent;
    color: #445066;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topbar-logout-btn img {
    display: block;
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.topbar-logout-btn:hover {
    color: #1f2937;
}

main {
    padding: 8px 0 12px;
}

section > h1,
.panel > h1 {
    margin: 0 0 4px;
    font-size: 13px;
    line-height: 1.25;
    font-weight: 600;
}

section > p,
.panel > p,
.page-intro {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

.panel {
    border: 1px solid #d2d9e3;
    background: var(--panel);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px) saturate(115%);
    -webkit-backdrop-filter: blur(14px) saturate(115%);
    padding: 8px;
}

.page-head {
    margin-bottom: 8px;
    width: calc((var(--tool-card-size) * 3) + (var(--tool-grid-gap) * 2));
    max-width: 100%;
}

.cards {
    display: grid;
    grid-template-columns: repeat(3, var(--tool-card-size));
    gap: var(--tool-grid-gap);
    margin-top: 8px;
    width: calc((var(--tool-card-size) * 3) + (var(--tool-grid-gap) * 2));
    max-width: 100%;
}

.card {
    border: 1px solid #d2d9e3;
    background: rgba(255, 255, 255, 0.78);
    border-radius: var(--r);
    width: var(--tool-card-size);
    height: var(--tool-card-size);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
}

.card p {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

.tool-thumb {
    width: 100%;
    height: 72px;
    object-fit: contain;
    object-position: center;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.tool-thumb--projectreferenties {
    transform: scale(0.8);
    transform-origin: center;
}

.card-disabled {
    opacity: 0.6;
}

.form-grid {
    display: grid;
    gap: 6px;
    max-width: 420px;
}

label {
    font-size: 11px;
    color: var(--muted2);
    font-weight: 500;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"] {
    width: 100%;
    height: 28px;
    padding: 0 8px;
    border: 1px solid #cfd6df;
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    font-size: 11px;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

td.locked-cell {
    background: rgba(231, 236, 244, 0.7);
}

td.locked-cell input[type="checkbox"] {
    accent-color: #9aa6b7;
    cursor: not-allowed;
}

.matrix-section td {
    background: rgba(236, 241, 248, 0.95);
    color: #4d5b6e;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.btn {
    height: 26px;
    border-radius: 7px;
    border: 1px solid #cfd6df;
    background: #f4f6f9;
    padding: 0 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 11px;
    color: #2f3b4b;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    box-shadow: none;
}

.btn:hover {
    background: #eceff4;
    border-color: #bec8d4;
    color: var(--accent-blue-dark);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

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

.btn-danger {
    border-color: rgba(220, 38, 38, 0.35);
    background: rgba(220, 38, 38, 0.1);
    color: #991b1b;
}

.alert {
    margin: 8px 0;
    padding: 8px 10px;
    border-radius: 7px;
    border: 1px solid transparent;
    font-size: 11px;
}

.alert-danger {
    background: rgba(220, 38, 38, 0.09);
    border-color: rgba(220, 38, 38, 0.22);
    color: #7f1d1d;
}

.alert-success {
    background: rgba(22, 163, 74, 0.1);
    border-color: rgba(22, 163, 74, 0.24);
    color: #166534;
}

.table-wrap {
    overflow: auto;
    border: 1px solid #d2d9e3;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.78);
    margin-bottom: 8px;
}

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

th,
td {
    border-bottom: 1px solid #dee4ec;
    border-right: 1px solid #dee4ec;
    padding: 6px 8px;
    text-align: left;
    min-width: 110px;
    font-size: 11px;
}

th:last-child,
td:last-child {
    border-right: 0;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(246, 248, 251, 0.84);
    color: #5f6b79;
    font-size: 11px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
}

tbody tr:hover {
    background: rgba(233, 238, 245, 0.7);
}

.auth-panel {
    width: 300px;
    margin: 10px auto;
}

@media (max-width: 780px) {
    .page-head,
    .cards {
        width: 100%;
    }

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

    .card {
        width: 100%;
        height: auto;
    }

    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        height: auto;
        min-height: 42px;
    }

    .topbar-actions {
        flex-wrap: wrap;
    }

    .panel {
        padding: 12px;
    }

    .auth-panel {
        width: min(300px, 100%);
    }
}
