/* ─── PT Serif, self-hosted ───
   Drop the four woff2 files in a fonts/ folder next to this stylesheet.
   Until they are present the browser falls back to Arial, exactly as before.
   font-display: swap keeps the text visible while the font loads. */

@font-face {
    font-family: 'PT Serif';
    src: url('fonts/pt-serif-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'PT Serif';
    src: url('fonts/pt-serif-italic.woff2') format('woff2');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'PT Serif';
    src: url('fonts/pt-serif-bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'PT Serif';
    src: url('fonts/pt-serif-bold-italic.woff2') format('woff2');
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'PT Serif', Arial, Helvetica, 'Nimbus Sans L', sans-serif;
    background: #ffffff;
    color: #454545;
    min-height: 100vh;
    line-height: 1.6;
}

body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ─── Login ─── */

.container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    padding: 50px 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
}

.logo-area {
    text-align: center;
    margin-bottom: 40px;
}

.institute-name {
    text-align: center;
    font-size: 18px;
    color: #454545;
    margin-bottom: 5px;
    font-weight: normal;
}

h1 {
    color: #454545;
    margin-bottom: 10px;
    text-align: center;
    font-size: 24px;
    font-weight: normal;
    letter-spacing: -0.5px;
}

.subtitle {
    text-align: center;
    color: #787878;
    font-size: 14px;
    margin-bottom: 40px;
}

/* The tagline under the title is gone, so the spacing it used to provide
   between the heading and the first field moves onto the heading itself */
.login-card h1 {
    margin-bottom: 40px;
}

/* ─── Forms ─── */

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #454545;
    font-size: 14px;
    font-weight: normal;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'PT Serif', Arial, Helvetica, 'Nimbus Sans L', sans-serif;
    transition: border-color 0.3s;
    background: #fafafa;
    color: #454545;
}

/* Single-line controls share one fixed height with the buttons */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="date"],
select {
    height: 42px;
    padding-top: 0;
    padding-bottom: 0;
}

/* Safari and Chrome give date fields their own intrinsic width and centre the
   value vertically on their own terms, which left them a different size from
   every neighbouring control. The appearance reset below is deliberately
   partial: killing it entirely would take the calendar picker with it. */
input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    min-width: 0;
    line-height: 40px;
}

input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
    margin: 0;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.55;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* An empty date field shows a dd/mm/yyyy placeholder that reads as content;
   dimming it keeps it visibly secondary to the fields that hold a real value */
input[type="date"]:not(:focus):invalid::-webkit-datetime-edit {
    color: #a8a8a8;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #9B0C23;
    background: #ffffff;
}

/* ─── Buttons ─── */

.btn {
    height: 42px;
    padding: 0 24px;
    background: #9B0C23;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: normal;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'PT Serif', Arial, Helvetica, 'Nimbus Sans L', sans-serif;
    letter-spacing: 0.5px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.btn:hover {
    background: #7a0a1c;
}

.btn-full {
    width: 100%;
    height: 48px;
}

.btn-secondary {
    background: transparent;
    color: #9B0C23;
    border: 1px solid #9B0C23;
}

.btn-secondary:hover {
    background: #9B0C23;
    color: white;
}

.btn-danger {
    background: #dc3545;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-small svg,
.btn svg {
    display: inline-block;
    vertical-align: -3px;
    margin-right: 4px;
}

.btn-icon svg {
    display: block;
}

.btn-icon {
    padding: 6px 10px;
    background: transparent;
    color: #787878;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: #9B0C23;
    border-color: #9B0C23;
}

/* ─── Alerts ─── */

.error {
    background: #fef2f2;
    color: #9B0C23;
    padding: 15px 20px;
    margin-bottom: 25px;
    text-align: center;
    font-size: 14px;
    border: 1px solid #fecaca;
    border-radius: 4px;
}

.success {
    background: #f0fdf4;
    color: #166534;
    padding: 15px 20px;
    margin-bottom: 25px;
    text-align: center;
    font-size: 14px;
    border: 1px solid #bbf7d0;
    border-radius: 4px;
}

/* ─── Layout ─── */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─── */

.sidebar {
    width: 450px;
    min-width: 450px;
    background: #fafafa;
    border-right: 1px solid #e8e8e8;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden;
    transition: width 0.25s ease, min-width 0.25s ease;
}

/* Collapsed sidebar: shrink to a narrow rail that still exposes the icons */
.app-wrapper.sidebar-collapsed .sidebar {
    width: 60px;
    min-width: 60px;
}

.app-wrapper.sidebar-collapsed .sidebar-header-text,
.app-wrapper.sidebar-collapsed .sidebar-nav,
.app-wrapper.sidebar-collapsed .sidebar-footer .user-info {
    display: none;
}

.app-wrapper.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 20px 0;
}

.app-wrapper.sidebar-collapsed .sidebar-footer {
    justify-content: center;
    padding: 15px 0;
}

.app-wrapper.sidebar-collapsed .sidebar-footer .footer-actions {
    flex-direction: column;
    gap: 10px;
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.sidebar-header-text {
    overflow: hidden;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #787878;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    color: #9B0C23;
    background: rgba(155, 12, 35, 0.08);
}

/* Toggle button icons: show the matching direction depending on state */
.sidebar-toggle .toggle-icon-open {
    display: none;
}

.app-wrapper.sidebar-collapsed .sidebar-toggle .toggle-icon-close {
    display: none;
}

.app-wrapper.sidebar-collapsed .sidebar-toggle .toggle-icon-open {
    display: inline-flex;
}

.sidebar-header h1 {
    font-size: 18px;
    text-align: left;
    margin-bottom: 4px;
}

.sidebar-header .subtitle {
    text-align: left;
    margin-bottom: 0;
    font-size: 13px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 15px 0;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.sidebar-footer .user-info {
    font-size: 13px;
    color: #454545;
    overflow: hidden;
}

.sidebar-footer .user-name {
    font-weight: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer .user-role {
    color: #787878;
    font-size: 12px;
    text-transform: capitalize;
}

.sidebar-footer .footer-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ─── Category Tree ─── */

.category-block {
    margin-bottom: 2px;
}

.category-header {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    transition: background 0.2s;
    user-select: none;
    gap: 8px;
    cursor: pointer;
    position: relative;
}

.category-header:hover {
    background: #f0f0f0;
}

.category-chevron {
    display: inline-flex;
    align-items: center;
    color: #9b9b9b;
    flex-shrink: 0;
}

.category-chevron svg {
    transform: rotate(90deg);
    transition: transform 0.2s ease;
}

.category-block.collapsed .category-chevron svg {
    transform: rotate(0deg);
}

.category-block.collapsed .subcategory-list {
    display: none;
}

.category-name {
    font-size: 14px;
    color: #454545;
    font-weight: 600;
    flex: 1;
}

.category-actions {
    display: none;
    gap: 4px;
    flex-shrink: 0;
    position: absolute;
    right: 14px;
    top: 0;
    bottom: 0;
    align-items: center;
    background: #f0f0f0;
    padding-left: 10px;
}

.category-header:hover .category-actions {
    display: flex;
}

.category-actions button {
    background: none;
    border: none;
    color: #787878;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 5px;
    border-radius: 3px;
    transition: all 0.2s;
}

.category-actions button:hover {
    color: #9B0C23;
    background: rgba(155, 12, 35, 0.08);
}

.subcategory-list {
    display: block;
    padding-left: 0;
}

.subcategory-item {
    display: flex;
    align-items: center;
    padding: 8px 20px 8px 44px;
    cursor: pointer;
    transition: all 0.2s;
    gap: 8px;
    position: relative;
}

.subcategory-item:hover {
    background: #f0f0f0;
}

.subcategory-item.active {
    background: #9B0C23;
    color: white;
}

.subcategory-item.active .subcategory-name {
    color: white;
}

.subcategory-item.active .subcategory-count {
    background: rgba(255,255,255,0.2);
    color: white;
}

.subcategory-item.active .subcategory-actions button {
    color: rgba(255,255,255,0.7);
}

.subcategory-item.active .subcategory-actions button:hover {
    color: white;
    background: rgba(255,255,255,0.15);
}

.subcategory-name {
    font-size: 14px;
    color: #787878;
    flex: 1;
}

.subcategory-count {
    font-size: 11px;
    background: #e8e8e8;
    color: #787878;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.subcategory-actions {
    display: none;
    gap: 4px;
    flex-shrink: 0;
    position: absolute;
    right: 14px;
    top: 0;
    bottom: 0;
    align-items: center;
    background: #f0f0f0;
    padding-left: 10px;
}

.subcategory-item:hover .subcategory-actions {
    display: flex;
}

.subcategory-item.active .subcategory-actions {
    background: #9B0C23;
}

.subcategory-actions button {
    background: none;
    border: none;
    color: #787878;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.2s;
}

.subcategory-actions button:hover {
    color: #9B0C23;
    background: rgba(155, 12, 35, 0.08);
}

.add-category-btn {
    display: block;
    width: calc(100% - 40px);
    margin: 10px 20px;
    padding: 10px;
    background: transparent;
    border: 1px dashed #d0d0d0;
    border-radius: 4px;
    color: #787878;
    font-size: 13px;
    font-family: 'PT Serif', Arial, Helvetica, 'Nimbus Sans L', sans-serif;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.add-category-btn:hover {
    border-color: #9B0C23;
    color: #9B0C23;
}

/* ─── Main Content ─── */

.main-content {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
    min-width: 0;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.content-header h2 {
    font-size: 22px;
    font-weight: normal;
    color: #454545;
}

.content-header .breadcrumb {
    font-size: 13px;
    color: #787878;
    margin-top: 4px;
}

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

/* ─── Top nav tabs ─── */

.top-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #f0f0f0;
    margin-bottom: 30px;
}

.top-tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: #787878;
    font-size: 15px;
    font-family: 'PT Serif', Arial, Helvetica, 'Nimbus Sans L', sans-serif;
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}

.top-tab:hover {
    color: #454545;
}

.top-tab.active {
    color: #9B0C23;
    border-bottom-color: #9B0C23;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ─── Files Table ─── */

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

.files-table th,
.files-table td {
    padding: 14px 15px;
    text-align: left;
    border-bottom: 1px solid #e8e8e8;
    font-size: 14px;
}

.files-table th {
    background: #fafafa;
    color: #454545;
    font-weight: normal;
    position: sticky;
    top: 0;
}

.files-table tr:hover {
    background: #fafafa;
}

.files-table .file-title {
    color: #9B0C23;
    cursor: pointer;
    transition: color 0.2s;
}

.files-table .file-title:hover {
    color: #7a0a1c;
    text-decoration: underline;
}

.files-table .col-size {
    white-space: nowrap;
    color: #787878;
}

.files-table tr.drag-row {
    cursor: grab;
}

.files-table tr.drag-row:active {
    cursor: grabbing;
}

.files-table tr.dragging-row {
    opacity: 0.4;
}

.files-table tr.insert-before td {
    box-shadow: inset 0 2px 0 #9B0C23;
}

.files-table tr.insert-after td {
    box-shadow: inset 0 -2px 0 #9B0C23;
}

.files-table .drag-cell {
    width: 30px;
    color: #d0d0d0;
    cursor: grab;
    text-align: center;
}

.files-table .drag-cell:hover {
    color: #9B0C23;
}

.file-type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: normal;
}

.file-type-pdf { background: #fef2f2; color: #9B0C23; }
.file-type-docx { background: #dbeafe; color: #1e40af; }
.file-type-xlsx { background: #dcfce7; color: #166534; }
.file-type-mp4 { background: #fef3c7; color: #92400e; }
.file-type-mov { background: #fdf2f8; color: #9d174d; }

.actions-cell {
    display: flex;
    gap: 6px;
    white-space: nowrap;
    justify-content: flex-end;
}

.files-table .th-actions,
.users-table .th-actions {
    text-align: right;
}

.sortable-th {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.sortable-th:hover {
    color: #9B0C23;
}

.sort-arrow {
    display: inline-block;
    vertical-align: -2px;
    margin-left: 4px;
    color: #9B0C23;
}

.sort-arrow-inactive {
    display: inline-block;
    vertical-align: -2px;
    margin-left: 4px;
    opacity: 0.25;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #787878;
}

.empty-state p {
    font-size: 15px;
    margin-bottom: 20px;
}

/* ─── Modal ─── */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 1px solid #e8e8e8;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: normal;
    color: #454545;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #787878;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #454545;
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e8e8e8;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ─── File Preview ─── */

/* Large preview modal: the document fills the available space */
.modal-preview {
    max-width: 95vw;
    width: 95vw;
    height: 92vh;
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-icon-btn {
    background: none;
    border: none;
    color: #787878;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-icon-btn:hover {
    color: #9B0C23;
    background: rgba(155, 12, 35, 0.08);
}

.modal-icon-btn.active {
    color: #9B0C23;
    background: rgba(155, 12, 35, 0.12);
}

.preview-body {
    flex: 1;
    min-height: 0;
    padding: 0;
    position: relative;
    overflow: hidden;
    display: flex;
}

.preview-container {
    flex: 1;
    min-height: 0;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-container iframe,
.preview-container video {
    width: 100%;
    height: 100%;
    border: none;
}

/* Details panel: hidden by default, revealed by the info pictogram */
.preview-info {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    width: min(330px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    overflow-y: auto;
    grid-template-columns: auto 1fr;
    gap: 8px 20px;
    font-size: 14px;
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
    padding: 20px 22px;
}

.preview-info.show {
    display: grid;
}

.preview-info dt {
    color: #787878;
}

.preview-info dd {
    color: #454545;
    word-break: break-word;
}

/* ─── Upload Area ─── */

.upload-drop-zone {
    border: 2px dashed #d0d0d0;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    margin-bottom: 20px;
}

.upload-drop-zone:hover,
.upload-drop-zone.dragover {
    border-color: #9B0C23;
    background: rgba(155, 12, 35, 0.03);
}

.upload-drop-zone p {
    color: #787878;
    font-size: 14px;
    margin-bottom: 5px;
}

.upload-drop-zone .formats {
    color: #aaa;
    font-size: 12px;
}

.upload-drop-zone input[type="file"] {
    display: none;
}

#selectedFileName {
    font-size: 14px;
    color: #787878;
}

#selectedFileName:not(:empty) {
    margin-bottom: 15px;
}

.selected-files-count {
    color: #454545;
    margin-bottom: 8px;
}

.selected-files-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
}

.selected-files-list li {
    padding: 8px 12px;
    font-size: 13px;
    color: #454545;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-files-list li:last-child {
    border-bottom: none;
}

.selected-files-note {
    margin-top: 8px;
    font-size: 12px;
    color: #9b9b9b;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ─── Users Panel ─── */

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

.users-table th,
.users-table td {
    padding: 14px 15px;
    text-align: left;
    border-bottom: 1px solid #e8e8e8;
    font-size: 14px;
}

.users-table th {
    background: #fafafa;
    color: #454545;
    font-weight: normal;
}

.users-table tr:hover {
    background: #fafafa;
}

.role-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
}

.role-admin { background: #fef3c7; color: #92400e; }
.role-editor { background: #dbeafe; color: #1e40af; }
.role-viewer { background: #f3f4f6; color: #374151; }

/* ─── Impersonation banner ─── */

.impersonation-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 14px 20px;
    margin-bottom: 24px;
    border: 1px solid #f0c98a;
    border-left: 4px solid #d98c1f;
    border-radius: 6px;
    background: #fdf6e8;
}

.impersonation-text {
    flex: 1;
    min-width: 240px;
    font-size: 14px;
    color: #6b4a12;
}

.impersonation-text strong {
    font-weight: 700;
}

.impersonation-form {
    margin: 0;
}

.impersonation-bar .btn {
    background: #d98c1f;
    border-color: #d98c1f;
    white-space: nowrap;
}

.impersonation-bar .btn:hover {
    background: #b8741a;
    border-color: #b8741a;
}

.app-notice {
    padding: 14px 20px;
    margin-bottom: 24px;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #9B0C23;
    border-radius: 6px;
    background: #fafafa;
    font-size: 14px;
    color: #454545;
}

/* ─── Activity log ─── */

.activity-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    padding: 18px 20px;
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    margin-bottom: 22px;
}

.activity-filters .form-group {
    margin-bottom: 0;
    min-width: 150px;
}

.activity-filters label {
    margin-bottom: 5px;
    font-size: 12px;
    color: #787878;
}

.activity-filters input,
.activity-filters select {
    height: 38px;
    padding: 0 10px;
    font-size: 13px;
}

.activity-filters input[type="date"] {
    line-height: 36px;
}

/* Both date fields hold the same eight visible characters, so they are pinned
   to one width instead of being stretched by the flex row */
.activity-filter-date {
    min-width: 0;
    width: 165px;
    flex: 0 0 auto;
}

.activity-filter-search {
    flex: 1;
    min-width: 200px;
}

.activity-filter-reset {
    min-width: 0;
    flex: 0 0 auto;
}

.activity-filter-reset .btn {
    height: 38px;
}

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

.activity-table th,
.activity-table td {
    padding: 11px 12px;
    text-align: left;
    border-bottom: 1px solid #e8e8e8;
    font-size: 13px;
    vertical-align: top;
}

.activity-table th {
    background: #fafafa;
    color: #454545;
    font-weight: normal;
    white-space: nowrap;
}

.activity-table tr:hover {
    background: #fafafa;
}

.activity-table .col-when,
.activity-table .col-ip {
    white-space: nowrap;
    color: #787878;
}

.activity-table .col-detail {
    color: #787878;
    max-width: 320px;
    overflow-wrap: anywhere;
}

.activity-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    white-space: nowrap;
    background: #f3f4f6;
    color: #374151;
}

.activity-badge-download { background: #dbeafe; color: #1e40af; }
.activity-badge-view { background: #e8f5e9; color: #1b5e20; }
.activity-badge-upload { background: #ede9fe; color: #5b21b6; }
.activity-badge-delete { background: #fee2e2; color: #991b1b; }
.activity-badge-error { background: #fee2e2; color: #991b1b; }
.activity-badge-impersonate_start,
.activity-badge-impersonate_stop { background: #fdf6e8; color: #6b4a12; }
.activity-badge-login_failed { background: #ffedd5; color: #9a3412; }
.activity-badge-login_blocked { background: #fee2e2; color: #991b1b; }
.activity-badge-login { background: #f3f4f6; color: #374151; }

.activity-row-error td,
.activity-row-login_failed td,
.activity-row-login_blocked td {
    background: #fffaf5;
}

.activity-actor {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: #6b4a12;
    background: #fdf6e8;
    border-radius: 3px;
    padding: 1px 6px;
}

.activity-pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 18px 4px 0;
}

.activity-count {
    margin-right: auto;
    font-size: 13px;
    color: #787878;
}

.activity-page-label {
    font-size: 13px;
    color: #454545;
}

/* ─── Storage integrity ─── */

.integrity-ok {
    margin: 0;
    font-size: 14px;
    color: #454545;
}

.integrity-heading {
    font-size: 15px;
    font-weight: normal;
    color: #454545;
    margin: 0 0 6px;
}

.integrity-heading + .integrity-note {
    margin-top: 0;
}

.integrity-note {
    font-size: 13px;
    color: #787878;
    margin: 0 0 12px;
}

.integrity-list {
    list-style: none;
    margin: 0 0 26px;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
}

.integrity-list li {
    padding: 9px 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.integrity-list li:last-child {
    border-bottom: none;
}

.integrity-list strong {
    font-weight: normal;
    color: #454545;
}

.integrity-path {
    display: block;
    color: #787878;
    font-size: 12px;
    margin-top: 2px;
}

/* Stands in for an icon this copy of icons.js does not know about. Visible
   enough to notice, small enough not to break a row. */
.icon-missing {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1px dashed #c0c0c0;
    border-radius: 2px;
    vertical-align: middle;
}

/* ─── Layout helpers ─── */
/* These replace the inline style attributes that the Content-Security-Policy
   no longer allows now that style-src has dropped 'unsafe-inline'. */

.u-hidden {
    display: none;
}

.modal-narrow {
    max-width: 420px;
}

.modal-confirm {
    max-width: 440px;
}

.modal-message {
    margin: 0;
}

.modal-message-multiline {
    white-space: pre-line;
}

.form-group-last {
    margin-bottom: 0;
}

.th-reorder {
    width: 30px;
}

.upload-drop-icon {
    margin-bottom: 10px;
    color: #9B0C23;
}

/* ─── Search ─── */

.search-bar {
    display: flex;
    gap: 10px;
}

.search-bar input {
    flex: 1;
    max-width: 350px;
}

/* ─── Drag sorting ─── */

.drag-handle {
    cursor: grab;
    color: #d0d0d0;
    font-size: 14px;
    padding: 0 4px;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.dragging {
    opacity: 0.4;
}

.category-header.drag-over-indicator {
    background: rgba(155, 12, 35, 0.06);
    box-shadow: inset 3px 0 0 #9B0C23;
}

.subcategory-item.drag-over-indicator {
    background: rgba(155, 12, 35, 0.06);
    box-shadow: inset 3px 0 0 #9B0C23;
}

.subcategory-item.drag-over-file-target {
    background: rgba(155, 12, 35, 0.12);
    box-shadow: inset 3px 0 0 #9B0C23;
    outline: 2px dashed #9B0C23;
    outline-offset: -2px;
}

.subcategory-item .drag-handle {
    flex-shrink: 0;
}

/* ─── Responsive ─── */

@media (max-width: 900px) {
    .app-wrapper {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        position: relative;
        max-height: 50vh;
    }

    .main-content {
        padding: 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .content-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .files-table {
        display: block;
        overflow-x: auto;
    }
}

/* ─── Logout form (POST, so the CSRF token stays out of the URL) ─── */

.logout-form {
    display: inline-flex;
    margin: 0;
}

/* ─── Destructive icon buttons ─── */

.btn-icon-danger {
    color: #dc3545;
}

.btn-icon-danger:hover {
    color: #b02a37;
}

/* ─── Small helper text under a field ─── */

.field-note {
    color: #787878;
    font-size: 13px;
    margin-top: 6px;
}

/* ─── Load failure state with a retry button ─── */

.empty-state.load-error p {
    margin-bottom: 14px;
}

.empty-state.load-error {
    padding: 30px 20px;
}

/* ─── Preview fallback for non previewable types ─── */

.preview-unavailable {
    padding: 40px;
    text-align: center;
    color: #787878;
}

.preview-unavailable-icon {
    margin-bottom: 15px;
}

.preview-unavailable-title {
    font-size: 16px;
    margin-bottom: 10px;
}

/* ─── Visible to screen readers only ─── */

.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;
}

/* ─── Keyboard focus stays visible everywhere ─── */

.file-title:focus-visible,
.btn:focus-visible,
.btn-icon:focus-visible,
.sortable-th:focus-visible,
.modal-close:focus-visible,
.modal-icon-btn:focus-visible {
    outline: 2px solid #9B0C23;
    outline-offset: 2px;
}
