*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f4f6;
    color: #111827;
    line-height: 1.5;
}

/* Focus visibility for accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.topbar {
    background: #111827;
    color: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar .logo {
    display: flex;
    flex-direction: column;
}

.logo-app {
    font-weight: 600;
    font-size: 1rem;
}

.logo-sub {
    font-size: 0.75rem;
    color: #9ca3af;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-nav a {
    color: #e5e7eb;
    text-decoration: none;
    font-size: 0.9rem;
}

.topbar-logout {
    background: transparent;
    border-color: #4b5563;
    color: #e5e7eb;
}

.topbar-logout:hover {
    background: #374151;
    border-color: #6b7280;
    color: white;
}

.app-switcher select {
    border-radius: 999px;
    border: 1px solid #4b5563;
    background: #020617;
    color: #e5e7eb;
    font-size: 0.8rem;
    padding: 0.25rem 0.8rem;
}

.container {
    max-width: 1280px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

.layout {
    display: flex;
    gap: 1.25rem;
}

.sidebar {
    width: 240px;
    background: #111827;
    color: #e5e7eb;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.3);
    align-self: flex-start;
    position: sticky;
    top: 1.25rem;
}

.sidebar-main-links {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.sidebar-main-links a {
    display: block;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
    color: #e5e7eb;
    text-decoration: none;
    font-size: 0.9rem;
}

.sidebar-main-links a.active,
.sidebar-main-links a:hover {
    background: #020617;
}

.sidebar-section {
    border-radius: 0.75rem;
    overflow: hidden;
    background: #111827;
}

.sidebar-section-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.6rem;
    background: #020617;
    color: #e5e7eb;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.sidebar-section-chevron {
    font-size: 0.7rem;
}

.sidebar-section-body {
    padding-top: 0.5rem;
}

.sidebar-section.collapsed .sidebar-section-body {
    display: none;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem 0;
}

.sidebar-list li {
    margin-bottom: 0.25rem;
}

.sidebar-list a {
    display: block;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
    color: #e5e7eb;
    text-decoration: none;
    font-size: 0.9rem;
}

.sidebar-list li.active a,
.sidebar-list a:hover {
    background: #1f2937;
}

.sidebar-list .empty {
    font-size: 0.8rem;
    color: #9ca3af;
}

.sidebar-hint {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #9ca3af;
    line-height: 1.3;
}

.content {
    flex: 1;
}

.card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.1);
}

.card.narrow {
    max-width: 520px;
    margin: 0 auto;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.btn {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: white;
    color: #111827;
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
}

.btn.primary {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

.btn.small {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}

.btn.danger {
    background: #dc2626;
    border-color: #dc2626;
    color: white;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th,
.table td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.table th {
    font-weight: 600;
    color: #374151;
    background: #f9fafb;
}

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.form-group.inline {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: #4b5563;
}

input[type="text"],
textarea,
select {
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.form-actions.inline {
    justify-content: flex-start;
}

.upload-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.upload-form .form-group.full-width {
    flex-basis: 100%;
    align-items: flex-start;
}

.upload-preview {
    margin-bottom: 1rem;
}

.upload-type-hint {
    font-size: 0.8rem;
    color: #6b7280;
}

.upload-preview-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #4b5563;
    margin-bottom: 0.35rem;
}

.upload-preview-frame {
    border-radius: 0.75rem;
    border: 1px dashed #d1d5db;
    background: #f9fafb;
    padding: 0.5rem;
    max-width: 260px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.upload-preview-frame img,
.upload-preview-frame video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    content-visibility: auto;
    contain-intrinsic-size: 0 200px;
}

.media-card {
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    background: #f9fafb;
    content-visibility: auto;
}

.media-thumb {
    background: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 140px;
    overflow: hidden;
}

.media-thumb img,
.media-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-meta {
    padding: 0.5rem 0.6rem 0.7rem;
}

.media-meta .filename {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.type-tag {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: #e5e7eb;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #374151;
}

.alert {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.alert.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.filter-bar .form-group.inline {
    margin-bottom: 0;
}

.media-category-label {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #6b7280;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1.5rem;
}

.login-card {
    padding: 2rem;
}

.login-title {
    margin: 0 0 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    color: #111827;
}

.login-form .form-actions {
    margin-top: 0.5rem;
}

.login-form .btn.primary {
    width: 100%;
    padding: 0.6rem;
}

