:root {
    color-scheme: light;
    --bg: oklch(97.5% 0.006 235);
    --surface: oklch(99% 0.004 235);
    --surface-2: oklch(94.5% 0.009 235);
    --surface-3: oklch(91% 0.012 235);
    --ink: oklch(24% 0.018 250);
    --muted: oklch(51% 0.028 250);
    --line: oklch(87% 0.012 235);
    --accent: oklch(52% 0.15 255);
    --accent-hover: oklch(46% 0.15 255);
    --accent-soft: oklch(93% 0.04 255);
    --danger: oklch(55% 0.18 28);
    --danger-soft: oklch(94% 0.045 28);
    --success: oklch(53% 0.13 148);
    --success-soft: oklch(93% 0.05 148);
    --warning-soft: oklch(94% 0.06 80);
    --radius: 8px;
    --shadow: 0 18px 50px oklch(35% 0.03 250 / 0.12);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.45;
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
}

.auth-body {
    display: grid;
    place-items: center;
    padding: 28px;
}

.auth-page {
    width: min(100%, 440px);
}

.auth-panel {
    display: grid;
    gap: 24px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.brand-mark {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 12px;
    background: var(--ink);
    color: var(--surface);
    font-weight: 800;
    letter-spacing: 0;
}

.brand-mark.small {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 28px;
    line-height: 1.15;
}

h2 {
    font-size: 18px;
    line-height: 1.25;
}

p {
    margin: 0;
    color: var(--muted);
}

.auth-copy {
    max-width: 65ch;
}

.stacked-form,
.user-form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 650;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input[type="text"]:hover,
input[type="password"]:hover {
    border-color: var(--surface-3);
}

input[type="text"]:focus,
input[type="password"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px oklch(52% 0.15 255 / 0.16);
}

.button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    background: var(--surface);
    font-size: 13px;
    font-weight: 750;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.button:hover {
    background: var(--surface-2);
    border-color: var(--surface-3);
}

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

.button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

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

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

.button.quiet {
    background: transparent;
}

.button.danger {
    border-color: transparent;
    background: var(--danger-soft);
    color: var(--danger);
}

.button.danger:hover {
    border-color: oklch(78% 0.08 28);
    background: oklch(91% 0.06 28);
}

.button.small {
    min-height: 32px;
    padding: 7px 10px;
    font-size: 12px;
}

.button.full {
    width: 100%;
}

.notice {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--ink);
    font-size: 13px;
    font-weight: 650;
}

.notice.success {
    border-color: oklch(80% 0.08 148);
    background: var(--success-soft);
    color: oklch(36% 0.11 148);
}

.notice.error {
    border-color: oklch(78% 0.08 28);
    background: var(--danger-soft);
    color: var(--danger);
}

.shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    height: 100vh;
    flex-direction: column;
    gap: 24px;
    padding: 22px;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

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

.sidebar-brand strong,
.sidebar-brand span {
    display: block;
}

.sidebar-brand span {
    color: var(--muted);
    font-size: 12px;
}

.nav-list {
    display: grid;
    gap: 6px;
}

.nav-list a {
    display: flex;
    min-height: 42px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 14px;
    font-weight: 750;
    text-decoration: none;
}

.nav-list a:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.nav-list a.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.nav-list b {
    min-width: 24px;
    padding: 3px 7px;
    border-radius: 999px;
    background: oklch(100% 0.002 235 / 0.76);
    color: inherit;
    font-size: 12px;
    text-align: center;
}

.logout-form {
    margin-top: auto;
}

.main {
    display: grid;
    align-content: start;
    gap: 18px;
    padding: 26px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 8px;
}

.user-chip {
    display: flex;
    min-width: 132px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.user-chip span {
    min-width: 0;
    overflow: hidden;
    font-size: 13px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    text-transform: uppercase;
}

.upload-panel,
.management-panel,
.table-section {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.upload-panel,
.management-panel {
    padding: 18px;
}

.section-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-heading.compact {
    margin: 0;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--line);
}

.section-heading p {
    margin-top: 4px;
    max-width: 72ch;
    font-size: 13px;
}

.upload-form {
    display: grid;
    grid-template-columns: auto minmax(180px, 260px) minmax(260px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.segmented {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    min-height: 42px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.segmented label {
    display: grid;
    min-width: 92px;
    place-items: center;
    gap: 0;
    color: var(--muted);
    cursor: pointer;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented span {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 750;
    text-align: center;
}

.segmented input:checked + span {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 4px oklch(35% 0.03 250 / 0.1);
}

.title-field {
    min-width: 0;
}

.file-drop {
    position: relative;
    display: grid;
    min-height: 58px;
    align-content: center;
    gap: 2px;
    padding: 10px 14px;
    border: 1px dashed oklch(73% 0.035 245);
    border-radius: var(--radius);
    background: var(--surface-2);
    cursor: pointer;
}

.file-drop:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.file-drop.is-dragging {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px oklch(52% 0.15 255 / 0.14);
}

.file-drop input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-drop input:disabled {
    cursor: default;
}

.drop-title {
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
}

.drop-copy {
    color: var(--muted);
    font-size: 12px;
    font-weight: 550;
}

.user-form {
    grid-template-columns: minmax(180px, 260px) minmax(180px, 260px) auto;
    align-items: end;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    background: var(--surface-2);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

tbody tr:hover {
    background: oklch(96% 0.011 235);
}

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

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

.name-cell img {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    object-fit: cover;
    background: var(--surface-2);
}

.name-cell strong,
.name-cell span {
    display: block;
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.name-cell strong {
    font-size: 14px;
}

.name-cell span {
    color: var(--muted);
    font-size: 12px;
}

.file-marker {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 10px;
    font-weight: 850;
}

.file-marker.folder {
    border-color: oklch(81% 0.08 80);
    background: var(--warning-soft);
    color: oklch(45% 0.1 80);
}

.file-marker.document {
    border-color: oklch(80% 0.07 255);
    background: var(--accent-soft);
    color: var(--accent);
}

.status-pill {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    padding: 4px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

.share-line {
    display: flex;
    min-width: 360px;
    align-items: center;
    gap: 7px;
}

.share-line input {
    min-width: 180px;
    height: 32px;
    padding: 6px 8px;
    color: var(--muted);
    font-size: 12px;
}

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

.row-actions form {
    margin: 0;
}

.empty-state {
    display: grid;
    gap: 4px;
    padding: 34px 18px;
    color: var(--muted);
    text-align: center;
}

.empty-state strong {
    color: var(--ink);
    font-size: 16px;
}

*:focus-visible {
    outline: 3px solid oklch(52% 0.15 255 / 0.32);
    outline-offset: 2px;
}

@media (max-width: 980px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        gap: 16px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .nav-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .upload-form,
    .user-form {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .auth-body {
        padding: 16px;
    }

    .auth-panel,
    .main {
        padding: 18px;
    }

    .sidebar {
        padding: 16px;
    }

    .nav-list {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: grid;
    }

    h1 {
        font-size: 24px;
    }

    .share-line {
        min-width: 300px;
    }
}
