:root {
    color-scheme: light;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --text: #111827;
    --muted: #667085;
    --border: #dfe3e8;
    --dark: #111827;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --shadow: 0 12px 35px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

button, input { font: inherit; }
a { color: inherit; }

.topbar {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px clamp(18px, 4vw, 54px);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    font-weight: 800;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.user-chip {
    display: inline-block;
    margin-left: 12px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 12px;
    font-weight: 700;
}

.topbar-actions, .toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar form { margin: 0; }

.browser-shell {
    width: min(1500px, calc(100% - 36px));
    margin: 34px auto 70px;
}

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

h1 { margin: 0 0 10px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.035em; }
h2, h3, p { margin-top: 0; }

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 14px;
}

.breadcrumbs a { text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; color: var(--text); }

.search-form {
    width: min(650px, 100%);
    display: flex;
    gap: 9px;
}

.search-form input {
    min-width: 0;
    flex: 1;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.search-form input:focus, .login-form input:focus {
    outline: 3px solid rgba(37, 99, 235, 0.16);
    border-color: var(--primary);
}

.button {
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 10px 14px;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    white-space: nowrap;
}

.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--primary-hover); }
.button-dark { background: var(--dark); color: #fff; }
.button-dark:hover { background: #374151; }
.button-light { background: #fff; color: var(--text); border-color: var(--border); }
.button-light:hover { background: #f8fafc; }
.button-block { width: 100%; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 27px;
}

.result-count { color: var(--muted); font-size: 14px; font-weight: 700; }
.section-title { margin: 0 0 14px; font-size: 18px; }
.file-heading-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.select-all-label { font-size: 14px; color: var(--muted); }
.select-all-label input { vertical-align: middle; }

.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 13px;
    margin-bottom: 32px;
}

.folder-card {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    text-decoration: none;
    font-weight: 700;
    box-shadow: 0 3px 9px rgba(15, 23, 42, 0.03);
}

.folder-card:hover { border-color: #b7c0cc; transform: translateY(-1px); }
.folder-icon { font-size: 28px; }

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 17px;
}

.file-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.file-select {
    position: absolute;
    z-index: 3;
    top: 11px;
    left: 11px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255,255,255,0.94);
    border: 1px solid rgba(17,24,39,0.16);
    box-shadow: 0 3px 10px rgba(15,23,42,0.12);
}

.file-select input { width: 18px; height: 18px; }

.preview-trigger {
    width: 100%;
    height: 220px;
    padding: 0;
    border: 0;
    cursor: zoom-in;
    background: #eef1f5;
    overflow: hidden;
}

.preview-trigger img { width: 100%; height: 100%; object-fit: contain; display: block; }
.preview-trigger:hover img { transform: scale(1.015); }

.pdf-preview {
    height: 100%;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 10px;
    color: #475467;
}

.pdf-badge {
    padding: 12px 10px;
    border-radius: 7px;
    background: #b42318;
    color: #fff;
    font-size: 20px;
    font-weight: 800;
}

.file-details { display: flex; flex-direction: column; flex: 1; padding: 15px; }
.file-name {
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    text-align: left;
    font-weight: 800;
    line-height: 1.35;
    overflow-wrap: anywhere;
    cursor: pointer;
}
.file-name:hover { text-decoration: underline; }
.file-path { margin-top: 7px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.file-meta { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 12px 0 15px; color: var(--muted); font-size: 12px; }
.file-details .button { margin-top: auto; }

.empty-state {
    text-align: center;
    padding: 70px 20px;
    border: 1px dashed #bdc5d0;
    border-radius: 14px;
    background: rgba(255,255,255,0.55);
    color: var(--muted);
}
.empty-state h3 { color: var(--text); margin-bottom: 8px; }
.empty-state p { max-width: 650px; margin: auto; }
.empty-icon { font-size: 42px; margin-bottom: 12px; }

.notice { padding: 13px 15px; border-radius: 9px; margin-bottom: 18px; }
.notice-error { color: var(--danger-text); background: var(--danger-bg); }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,0.76); }
.modal-panel {
    position: relative;
    width: min(1100px, 100%);
    height: min(850px, calc(100vh - 40px));
    display: grid;
    grid-template-rows: auto 1fr auto;
    border-radius: 14px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 25px 80px rgba(0,0,0,0.32);
}
.modal-header, .modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 16px; }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.modal-footer { justify-content: flex-end; border-top: 1px solid var(--border); }
.modal-close { border: 0; background: none; font-size: 30px; line-height: 1; cursor: pointer; }
.modal-content { min-height: 0; display: grid; place-items: center; background: #e9edf2; overflow: auto; }
.modal-image { max-width: 100%; max-height: 100%; object-fit: contain; }
.modal-pdf { width: 100%; height: 100%; border: 0; background: #fff; }
.modal-open { overflow: hidden; }

.login-body, .message-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}
.login-shell { width: min(430px, 100%); }
.login-card, .message-card {
    padding: 34px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.login-card h1, .message-card h1 { font-size: 30px; margin-bottom: 8px; }
.login-card p { color: var(--muted); line-height: 1.5; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: var(--dark); color: white; font-weight: 800; margin-bottom: 20px; }
.login-form { display: grid; gap: 10px; margin-top: 23px; }
.login-form label { font-weight: 700; margin-top: 5px; }
.login-form input { width: 100%; padding: 12px 13px; border: 1px solid var(--border); border-radius: 9px; }
.login-form .button { margin-top: 13px; }
.quiet-link { display: block; text-align: center; margin-top: 20px; color: var(--muted); font-size: 14px; }

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

@media (max-width: 850px) {
    .topbar, .browser-heading, .toolbar { align-items: stretch; flex-direction: column; }
    .topbar-actions, .toolbar-actions { flex-wrap: wrap; }
    .search-form { width: 100%; }
    .topbar { position: static; }
}

@media (max-width: 560px) {
    .browser-shell { width: min(100% - 22px, 1500px); margin-top: 22px; }
    .search-form { display: grid; grid-template-columns: 1fr 1fr; }
    .search-form input { grid-column: 1 / -1; }
    .toolbar-actions { display: grid; width: 100%; }
    .toolbar-actions .button { width: 100%; }
    .file-grid { grid-template-columns: 1fr; }
    .topbar-actions .button { font-size: 13px; }
    .modal { padding: 8px; }
    .modal-panel { height: calc(100vh - 16px); }
}
