* {
    box-sizing: border-box;
}

:root {
    --bg: #f3f5fb;
    --panel: #ffffff;
    --panel-2: #eef2ff;
    --text: #0f172a;
    --muted: #64748b;
    --line: #dbe2f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #15803d;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 20px;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
}

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

.sidebar {
    width: 300px;
    background: linear-gradient(180deg, #0f172a 0%, #172554 100%);
    color: #f8fafc;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.16);
    font-size: 1.4rem;
    font-weight: 700;
}

.brand small,
.user-card small {
    display: block;
    color: rgba(248, 250, 252, 0.75);
    margin-top: 4px;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.sidebar-nav a {
    border-radius: 14px;
    padding: 12px 14px;
    color: #dbeafe;
    transition: 0.2s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 14px;
}

.user-card {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.18);
    font-weight: 700;
    color: #fff;
}

.content {
    flex: 1;
    padding: 26px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 20px;
}

.page-body {
    display: grid;
    gap: 20px;
}

.search-inline input,
.input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 0.98rem;
    color: var(--text);
    outline: none;
}

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

.search-inline {
    flex: 1;
}

.card {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(219, 226, 240, 0.7);
}

.card.tight {
    padding: 18px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
}

.page-header h1,
.page-header h2,
.page-header h3,
h1, h2, h3 {
    margin: 0 0 8px;
}

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

.kpis {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.kpi {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border-radius: 20px;
    padding: 22px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.kpi strong {
    display: block;
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.grid {
    display: grid;
    gap: 20px;
}

.grid.two {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid.three {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.btn {
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-light {
    background: #f8fafc;
    color: var(--text);
    border: 1px solid var(--line);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-block {
    width: 100%;
}

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

.form-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.form-grid .full {
    grid-column: 1 / -1;
}

.flash {
    padding: 14px 16px;
    border-radius: 14px;
    font-weight: 600;
}

.flash-success {
    background: #dcfce7;
    color: #166534;
}

.flash-warning {
    background: #fef3c7;
    color: #92400e;
}

.flash-danger {
    background: #fee2e2;
    color: #991b1b;
}

.list {
    display: grid;
    gap: 12px;
}

.list-item {
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fff;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.83rem;
    font-weight: 700;
    background: #e2e8f0;
    color: #334155;
}

.badge.photo {
    background: #dbeafe;
    color: #1d4ed8;
}
.badge.video {
    background: #ede9fe;
    color: #6d28d9;
}
.badge.owner {
    background: #dbeafe;
    color: #1e40af;
}
.badge.admin {
    background: #ede9fe;
    color: #6d28d9;
}
.badge.member {
    background: #ecfccb;
    color: #3f6212;
}

.media-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.media-card {
    display: block;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.media-thumb {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    overflow: hidden;
}

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

.media-meta {
    padding: 14px;
    display: grid;
    gap: 8px;
}

.hero-media {
    background: #0f172a;
    border-radius: 22px;
    overflow: hidden;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-media img,
.hero-media video {
    width: 100%;
    max-height: 72vh;
    object-fit: contain;
    background: #0f172a;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 8px 12px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 600;
    font-size: 0.88rem;
}

.comment {
    border-top: 1px solid var(--line);
    padding: 14px 0 0;
    margin-top: 14px;
}

.table-wrap {
    overflow: auto;
}

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

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

.auth-screen {
    background: radial-gradient(circle at top, #dbeafe 0%, #f3f5fb 45%, #eef2ff 100%);
}

.auth-screen .content {
    display: grid;
    place-items: center;
    width: 100%;
    padding: 24px;
}

.auth-box {
    width: min(100%, 520px);
}

.upload-dropzone {
    border: 2px dashed #93c5fd;
    background: linear-gradient(180deg, #eff6ff 0%, #f8fbff 100%);
    border-radius: 22px;
    padding: 28px;
    text-align: center;
    display: grid;
    gap: 14px;
}

.upload-dropzone.dragover {
    border-color: var(--primary);
    background: #dbeafe;
}

.preview-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.preview-card {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
}

.preview-thumb {
    aspect-ratio: 1 / 1;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

.preview-meta {
    padding: 12px;
    font-size: 0.9rem;
}

.progress {
    height: 10px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.progress > span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--primary);
    transition: width 0.15s ease;
}

.install-banner {
    display: none;
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 40;
    max-width: 320px;
}

.empty-state {
    padding: 36px;
    border: 2px dashed var(--line);
    border-radius: 20px;
    background: rgba(255,255,255,0.5);
    text-align: center;
    color: var(--muted);
}

@media (max-width: 1080px) {
    .sidebar {
        width: 250px;
        padding: 20px;
    }
}

@media (max-width: 860px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        width: auto;
        border-radius: 0 0 28px 28px;
    }

    .content {
        padding: 18px;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
    }
}
