:root {
    color-scheme: light;
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-hover: #f6f9fd;
    --text: #172033;
    --text-strong: #0f172a;
    --muted: #64748b;
    --muted-light: #94a3b8;
    --border: #dce4ef;
    --border-strong: #cbd5e1;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;
    --folder: #d97706;
    --folder-soft: #fff7ed;
    --success: #16a34a;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 12px 34px rgba(15, 23, 42, 0.08);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.06), transparent 30rem),
        var(--bg);
    color: var(--text);
    font-family:
        Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input {
    font: inherit;
}

svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

/* Authentication */

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
}

.auth-panel {
    width: min(100%, 460px);
    padding: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(12px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand-icon,
.header-logo {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: white;
    background: linear-gradient(145deg, #2563eb, #1d4ed8);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22);
}

.brand-icon {
    width: 52px;
    height: 52px;
    padding: 12px;
    border-radius: 15px;
}

.brand-kicker,
.header-kicker {
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    color: var(--text-strong);
    font-size: 1.55rem;
    line-height: 1.2;
}

.auth-description {
    margin: 22px 0 26px;
    color: var(--muted);
}

.auth-form {
    display: grid;
    gap: 17px;
}

.field {
    display: grid;
    gap: 7px;
}

label {
    color: var(--text-strong);
    font-size: 0.9rem;
    font-weight: 700;
}

input {
    width: 100%;
    min-height: 46px;
    padding: 11px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
    background: white;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.13);
}

.alert {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 13px;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: #b91c1c;
    font-size: 0.92rem;
}

.alert-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--danger);
}

.auth-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 25px;
    color: var(--muted);
    font-size: 0.82rem;
}

/* Buttons */

.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.15s ease;
}

.button:hover {
    border-color: var(--border-strong);
    background: var(--surface-soft);
    text-decoration: none;
}

.button:active {
    transform: translateY(1px);
}

.button-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.button-primary:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.button-secondary {
    background: white;
}

.button-full {
    width: 100%;
}

.button-small {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.86rem;
}

.button-icon {
    width: 18px;
    height: 18px;
}

/* Header */

.app-header {
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(12px);
}

.header-inner {
    width: min(1440px, calc(100% - 48px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 auto;
    padding: 18px 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 42px;
    height: 42px;
    padding: 10px;
    border-radius: 12px;
}

/* Main layout */

.content {
    width: min(1440px, calc(100% - 48px));
    margin: 30px auto 50px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.page-heading h2 {
    margin-bottom: 5px;
    color: var(--text-strong);
    font-size: 1.65rem;
    line-height: 1.25;
}

.page-subtitle {
    margin-bottom: 0;
    color: var(--muted);
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 0.87rem;
}

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

.breadcrumbs strong {
    color: var(--text);
}

.breadcrumb-separator {
    color: var(--muted-light);
}

.item-count {
    min-width: 88px;
    padding: 13px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.item-count strong {
    display: block;
    color: var(--text-strong);
    font-size: 1.3rem;
}

.item-count span {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.toolbar {
    display: flex;
    min-height: 42px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
}

.toolbar-note {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.84rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

/* File table */

.file-panel {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

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

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

.file-table th,
.file-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

.file-table th {
    background: var(--surface-soft);
    color: #536176;
    font-size: 0.73rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.file-table tbody tr {
    transition: background-color 0.15s ease;
}

.file-table tbody tr:hover {
    background: var(--surface-hover);
}

.file-table tbody tr:last-child td {
    border-bottom: 0;
}

.file-name {
    display: flex;
    min-width: 310px;
    align-items: center;
    gap: 12px;
}

.entry-icon {
    width: 38px;
    height: 38px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    padding: 9px;
    border-radius: 11px;
}

.folder-icon {
    background: var(--folder-soft);
    color: var(--folder);
}

.document-icon {
    background: var(--primary-soft);
    color: var(--primary);
}

.file-label {
    display: grid;
    gap: 2px;
}

.file-label a,
.file-label strong {
    overflow: hidden;
    max-width: 520px;
    color: var(--text-strong);
    font-weight: 750;
    text-overflow: ellipsis;
}

.file-label span {
    color: var(--muted);
    font-size: 0.8rem;
}

.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 750;
}

.type-folder {
    background: var(--folder-soft);
    color: #b45309;
}

.type-file {
    background: var(--primary-soft);
    color: var(--primary);
}

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

.action-column {
    width: 1%;
    text-align: right !important;
}

.empty-state {
    display: grid;
    place-items: center;
    gap: 8px;
    padding: 64px 24px;
    color: var(--muted);
    text-align: center;
}

.empty-state strong {
    color: var(--text-strong);
    font-size: 1rem;
}

.empty-icon {
    width: 54px;
    height: 54px;
    margin-bottom: 5px;
    padding: 13px;
    border-radius: 15px;
    background: var(--surface-soft);
    color: var(--muted-light);
}

/* Error */

.error-panel {
    text-align: center;
}

.error-badge {
    display: inline-grid;
    min-width: 76px;
    min-height: 76px;
    place-items: center;
    margin-bottom: 18px;
    border-radius: 20px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.8rem;
    font-weight: 850;
}

/* Dark mode */

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #0b1220;
        --surface: #111a2b;
        --surface-soft: #172135;
        --surface-hover: #162238;
        --text: #dbe7f5;
        --text-strong: #f8fafc;
        --muted: #94a3b8;
        --muted-light: #64748b;
        --border: #26344a;
        --border-strong: #354760;
        --primary: #60a5fa;
        --primary-hover: #3b82f6;
        --primary-soft: rgba(59, 130, 246, 0.14);
        --folder: #f59e0b;
        --folder-soft: rgba(245, 158, 11, 0.14);
        --danger-soft: rgba(220, 38, 38, 0.12);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
        --shadow-md: 0 14px 40px rgba(0, 0, 0, 0.25);
    }

    body {
        background:
            radial-gradient(circle at top left, rgba(37, 99, 235, 0.11), transparent 30rem),
            var(--bg);
    }

    .auth-panel,
    .app-header {
        background: rgba(17, 26, 43, 0.94);
    }

    input,
    .button-secondary {
        background: #0f1728;
        color: var(--text);
    }

    .alert {
        border-color: rgba(248, 113, 113, 0.35);
        color: #fca5a5;
    }
}

/* Responsive */

@media (max-width: 760px) {
    .header-inner,
    .content {
        width: min(100% - 24px, 1440px);
    }

    .header-inner {
        padding: 14px 0;
    }

    .header-kicker {
        display: none;
    }

    .header-logo {
        width: 38px;
        height: 38px;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 15px;
    }

    .item-count {
        min-width: 100%;
        display: flex;
        align-items: baseline;
        justify-content: center;
        gap: 7px;
        text-align: left;
    }

    .item-count strong {
        display: inline;
    }

    .toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .auth-page {
        padding: 16px;
    }

    .auth-panel {
        padding: 28px 22px;
    }

    .file-table th:nth-child(2),
    .file-table td:nth-child(2),
    .file-table th:nth-child(3),
    .file-table td:nth-child(3) {
        display: none;
    }

    .file-name {
        min-width: 230px;
    }

    .file-label a,
    .file-label strong {
        max-width: 240px;
    }
}


/* Step 2: user administration */

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

.user-chip {
    max-width: 260px;
    overflow: hidden;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    background: var(--surface-soft);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notice {
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.notice-success {
    border-color: rgba(22, 163, 74, 0.3);
    color: var(--success);
    background: rgba(22, 163, 74, 0.08);
}

.status-badge {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 750;
}

.status-active {
    color: #15803d;
    background: rgba(22, 163, 74, 0.12);
}

.status-inactive {
    color: #b91c1c;
    background: var(--danger-soft);
}

.folder-list {
    min-width: 220px;
    max-width: 420px;
    white-space: normal !important;
}

.narrow-content {
    max-width: 900px;
}

.form-card {
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.admin-form {
    display: grid;
    gap: 22px;
}

.field-help,
.folder-option small,
.toggle-row small {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

legend {
    margin-bottom: 10px;
    color: var(--text-strong);
    font-weight: 750;
}

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

.folder-option,
.toggle-row {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    cursor: pointer;
}

.folder-option input,
.toggle-row input {
    width: 18px;
    min-height: 18px;
    margin-top: 2px;
    flex: 0 0 auto;
}

.folder-option strong,
.toggle-row strong {
    display: block;
    margin-bottom: 2px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 6px;
}

@media (max-width: 760px) {
    .header-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .user-chip {
        display: none;
    }

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

    .form-card {
        padding: 20px;
    }

    .admin-table th:nth-child(2),
    .admin-table td:nth-child(2),
    .admin-table th:nth-child(5),
    .admin-table td:nth-child(5) {
        display: none;
    }
}


/* Step 3: invitations and email verification */

.resend-form {
    margin-top: 10px;
}

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

.row-actions form {
    margin: 0;
}

.notice-error {
    border-color: rgba(220, 38, 38, 0.3);
    color: var(--danger);
    background: var(--danger-soft);
}

input[name="code"] {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.35em;
}

/* Datalab Systems branding */

.brand-stacked {
    display: block;
    text-align: center;
}

.login-logo {
    display: block;
    width: min(100%, 340px);
    height: auto;
    margin: 0 auto 22px;
    border-radius: 10px;
    object-fit: contain;
}

.brand-text {
    text-align: center;
}

.brand-stacked .brand-kicker {
    margin-bottom: 6px;
    text-align: center;
}

.brand-stacked h1 {
    text-align: center;
}

.auth-panel .auth-description {
    text-align: center;
}

.error-logo {
    margin-bottom: 24px;
}

@media (prefers-color-scheme: dark) {
    .login-logo {
        background: #ffffff;
        padding: 8px;
    }
}

@media (max-width: 520px) {
    .login-logo {
        width: min(100%, 285px);
        margin-bottom: 18px;
    }
}
