:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #1d2939;
    --muted: #667085;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --border: #e4e7ec;
    --danger: #dc2626;
    --success: #16a34a;
}

* {
    box-sizing: border-box;
}

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

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

.app {
    min-height: 100vh;
}

.topbar {
    height: 64px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
}

.user-menu {
    color: var(--muted);
    font-size: 14px;
}

.layout {
    display: flex;
}

.sidebar {
    width: 230px;
    min-height: calc(100vh - 64px);
    padding: 18px 12px;
    background: var(--card);
    border-right: 1px solid var(--border);
}

.nav-link {
    display: block;
    padding: 12px 14px;
    margin-bottom: 4px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 600;
}

.nav-link:hover,
.nav-link.active {
    background: #eff6ff;
    color: var(--primary);
}

.main {
    flex: 1;
    padding: 28px;
    min-width: 0;
}

.page-title {
    margin: 0 0 6px;
    font-size: 28px;
}

.page-subtitle {
    margin: 0 0 24px;
    color: var(--muted);
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
}

.card-label {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.card-value {
    font-size: 24px;
    font-weight: 800;
}

.storage-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 24px;
}

.storage-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

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

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--primary);
    border-radius: inherit;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    border-radius: 10px;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: white;
    font-weight: 700;
    cursor: pointer;
}

.button:hover {
    background: var(--primary-dark);
}

.button.secondary {
    background: white;
    color: var(--primary);
}

.section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
}

.empty {
    padding: 32px;
    text-align: center;
    color: var(--muted);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 30px;
    box-shadow: 0 15px 45px rgba(16, 24, 40, .08);
}

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

label {
    display: block;
    font-weight: 700;
    margin-bottom: 7px;
}

input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
}

.alert.error {
    background: #fef2f2;
    color: #991b1b;
}

.alert.success {
    background: #f0fdf4;
    color: #166534;
}

@media (max-width: 900px) {
    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sidebar {
        width: 190px;
    }
}

@media (max-width: 650px) {
    .topbar {
        padding: 0 16px;
    }

    .sidebar {
        display: none;
    }

    .main {
        padding: 18px;
    }

    .cards {
        grid-template-columns: 1fr;
    }
}

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

.photo-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}

.photo-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(16, 24, 40, .10);
}

.photo-card img {
    display: block;
    width: 100%;
    height: 170px;
    object-fit: cover;
    background: #eef2f6;
}

.photo-name {
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.video-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.video-card video {
    display: block;
    width: 100%;
    max-height: 250px;
    background: #000;
}

.video-name {
    padding: 12px;
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.document-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
}

.document-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.document-info {
    min-width: 0;
    flex: 1;
}

.document-name {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-meta {
    margin-top: 4px;
    font-size: 13px;
    color: #667085;
}

.document-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.document-actions a,
.document-actions button {
    border: 0;
    background: none;
    padding: 0;
    color: #2563eb;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.document-actions form {
    margin: 0;
}

.document-actions button {
    color: #dc2626;
}

@media (max-width: 650px) {
    .document-item {
        align-items: flex-start;
    }

    .document-actions {
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
    }
}


/* Mobile navigation and touch-friendly gallery */
.mobile-nav {
    display: none;
}

@media (max-width: 650px) {
    .topbar {
        height: auto;
        min-height: 60px;
        padding: 10px 14px;
        gap: 12px;
    }

    .brand {
        font-size: 17px;
        white-space: nowrap;
    }

    .user-menu {
        font-size: 12px;
        text-align: right;
    }

    .mobile-nav {
        display: flex;
        overflow-x: auto;
        gap: 6px;
        padding: 8px 10px;
        background: var(--card);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 60px;
        z-index: 9;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-nav::-webkit-scrollbar {
        display: none;
    }

    .mobile-nav-link {
        flex: 0 0 auto;
        min-width: 62px;
        min-height: 48px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 5px 8px;
        border-radius: 10px;
        color: var(--muted);
        font-size: 20px;
        touch-action: manipulation;
    }

    .mobile-nav-link span {
        font-size: 10px;
        font-weight: 700;
    }

    .mobile-nav-link.active {
        background: #eff6ff;
        color: var(--primary);
    }

    .photo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .photo-card {
        display: block;
        min-width: 0;
        min-height: 0;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .photo-card img {
        width: 100%;
        height: 150px;
        object-fit: cover;
    }

    .photo-name {
        padding: 8px;
        font-size: 12px;
    }
}

@media (max-width: 380px) {
    .photo-card img {
        height: 125px;
    }

    .mobile-nav-link {
        min-width: 58px;
    }
}
