/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #090909;
    --bg-secondary: #0f0f0f;
    --bg-elevated: #141414;
    --bg-card: #181818;
    --bg-hover: #1f1f1f;
    --bg-input: #121212;
    --border: #262626;
    --border-light: #323232;
    --border-focus: #3d3d3d;
    --text-primary: #f4f2ef;
    --text-secondary: #a8a49e;
    --text-muted: #6e6b66;
    --accent: #c4a574;
    --accent-hover: #d4b88a;
    --accent-muted: rgba(196, 165, 116, 0.1);
    --accent-glow: rgba(196, 165, 116, 0.18);
    --danger: #c96b6b;
    --danger-muted: rgba(201, 107, 107, 0.1);
    --sidebar-width: 272px;
    --topbar-height: 64px;
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 20px rgba(0,0,0,0.35);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.45);
    --transition: 0.2s ease;
    --font-serif: 'Cormorant Garamond', Georgia, serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --fw-normal: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    font-weight: var(--fw-normal);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: var(--accent-muted);
    color: var(--text-primary);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== LOGIN ===== */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px),
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(196,165,116,0.06) 0%, transparent 60%);
    background-size: 48px 48px, 48px 48px, 100% 100%;
}

.login-wrapper {
    width: 100%;
    max-width: 460px;
    padding: 24px;
}

.login-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 44px 48px 40px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.login-brand {
    text-align: center;
    margin-bottom: 36px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    width: 42px;
    height: 42px;
    border: 1.5px solid var(--accent);
    border-radius: 50%;
    margin: 0 auto 18px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.brand-mark::after {
    content: '';
    width: 18px;
    height: 18px;
    border: 1px solid var(--accent);
    border-radius: 50%;
    opacity: 0.45;
}
.brand-mark.sm {
    width: 22px;
    height: 22px;
    margin: 0;
    flex-shrink: 0;
}
.brand-mark.sm::after { width: 8px; height: 8px; }

.login-brand h1 {
    font-family: var(--font-serif);
    font-size: 1.9rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    line-height: 1.2;
}

.brand-sub {
    font-size: 0.72rem;
    font-weight: var(--fw-semibold);
    color: var(--text-muted);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-top: 8px;
}

.login-form { display: flex; flex-direction: column; gap: 20px; }

.form-group { display: flex; flex-direction: column; gap: 7px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 4px;
}

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

@media (max-width: 480px) {
    .form-row { grid-template-columns: 1fr; }
}

.form-group label {
    font-size: 0.75rem;
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

.form-group input,
.form-input,
.filter-input,
select.filter-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 14px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: var(--fw-normal);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    width: 100%;
    appearance: none;
}
.form-group input:focus,
.form-input:focus,
.filter-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}
.form-group input::placeholder { color: var(--text-muted); }

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: var(--fw-medium);
    margin-bottom: 20px;
    line-height: 1.45;
}
.alert-error {
    background: var(--danger-muted);
    border: 1px solid rgba(201, 107, 107, 0.25);
    color: var(--danger);
}

.login-footer {
    text-align: center;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    font-size: 0.72rem;
    font-weight: var(--fw-medium);
    color: var(--text-muted);
    letter-spacing: 0.06em;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.84rem;
    font-weight: var(--fw-semibold);
    letter-spacing: 0.01em;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent);
    color: #0d0d0d;
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-outline {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}
.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-muted);
}
.btn-full { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 0.78rem; }
.btn-danger {
    background: var(--bg-elevated);
    border: 1px solid rgba(201,107,107,0.3);
    color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger-muted);
    border-color: var(--danger);
}

/* ===== DASHBOARD ===== */
.dashboard-body {
    min-height: 100vh;
    background: var(--bg-primary);
}

.dashboard-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.dashboard-topbar {
    display: flex;
    align-items: stretch;
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.topbar-left {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 20px;
    border-right: 1px solid var(--border);
    background: var(--bg-elevated);
}

.sidebar-title {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--text-primary);
    line-height: 1;
}

.topbar-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 28px;
    min-width: 0;
}

.header-left { min-width: 0; }

.header-left h2,
.topbar-right h2 {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    line-height: 1.2;
}
.page-subtitle {
    font-size: 0.78rem;
    font-weight: var(--fw-normal);
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.3;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header-actions { display: flex; align-items: center; }

.header-signout {
    display: inline-flex;
    align-items: center;
    font-size: 0.78rem;
    font-weight: var(--fw-semibold);
    color: var(--text-muted);
    text-decoration: none;
    letter-spacing: 0.02em;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    transition: all var(--transition);
    white-space: nowrap;
}
.header-signout:hover {
    color: var(--text-primary);
    border-color: var(--border-light);
    background: var(--bg-hover);
}

/* Body layout */
.dashboard-main {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section-label,
.sidebar-actions-label {
    font-size: 0.68rem;
    font-weight: var(--fw-bold);
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 6px 12px 8px;
}

.nav-group { margin-bottom: 4px; }

.nav-group-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.86rem;
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}
.nav-group-btn svg { opacity: 0.7; flex-shrink: 0; }
.nav-group-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.nav-group-btn.active,
.nav-group-btn.open {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.nav-group-btn .chevron {
    margin-left: auto;
    transition: transform var(--transition);
    opacity: 0.5;
}
.nav-group-btn.open .chevron { transform: rotate(180deg); }

.nav-submenu {
    display: none;
    padding: 2px 0 4px 8px;
    margin-left: 8px;
    border-left: 1px solid var(--border);
}
.nav-submenu.open { display: block; }

.nav-sub-btn {
    width: 100%;
    display: block;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: var(--fw-normal);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}
.nav-sub-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.nav-sub-btn.active {
    color: var(--accent);
    background: var(--accent-muted);
    font-weight: var(--fw-semibold);
}

.sidebar-actions {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--bg-elevated);
}

.sidebar-action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}
.sidebar-action-btn svg { opacity: 0.65; flex-shrink: 0; }
.sidebar-action-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.sidebar-action-btn:hover svg { opacity: 1; }

/* Main content */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.content-panel {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
}

/* Welcome */
.welcome-panel {
    flex: 1;
    overflow-y: auto;
    padding: 32px 28px;
}

.welcome-content {
    max-width: 820px;
    margin: 0 auto;
}

.welcome-hero {
    text-align: center;
    margin-bottom: 36px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
}

.welcome-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-muted);
    border: 1px solid rgba(196,165,116,0.15);
    border-radius: var(--radius-lg);
    color: var(--accent);
}
.welcome-icon svg { width: 26px; height: 26px; }

.welcome-hero h3 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.welcome-hero p {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.65;
    max-width: 420px;
    margin: 0 auto;
}

.welcome-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.welcome-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.welcome-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
}

.welcome-card-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--accent);
}

.welcome-card h4 {
    font-size: 0.86rem;
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin-bottom: 4px;
}

.welcome-card p {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Filters */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    padding: 18px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 22px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 140px;
}

.filter-group label {
    font-size: 0.7rem;
    font-weight: var(--fw-semibold);
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.filter-input { font-size: 0.86rem; }

/* Image grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}

.image-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.image-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.image-card-thumb-wrap {
    position: relative;
    overflow: hidden;
    background: var(--bg-elevated);
}
.image-card-thumb-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.3) 0%, transparent 50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition);
}
.image-card:hover .image-card-thumb-wrap::after { opacity: 1; }

.image-card-thumb {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}
.image-card:hover .image-card-thumb { transform: scale(1.03); }

.image-card-body { padding: 14px 16px 16px; }

.image-card-title {
    font-size: 0.88rem;
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.image-card-actions { display: flex; gap: 6px; }

.card-action-btn {
    flex: 1;
    padding: 7px 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: var(--fw-semibold);
    cursor: pointer;
    transition: all var(--transition);
}
.card-action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-muted);
}
.card-action-btn.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-muted);
}

/* PDF list */
.pdf-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pdf-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.pdf-item:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
}

.pdf-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-muted);
    border: 1px solid rgba(196,165,116,0.12);
    border-radius: var(--radius);
    color: var(--accent);
    flex-shrink: 0;
}

.pdf-info { flex: 1; min-width: 0; }
.pdf-title {
    font-size: 0.88rem;
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pdf-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.pdf-actions { display: flex; gap: 8px; flex-shrink: 0; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 64px 24px;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.6;
}
.empty-state::before {
    content: '';
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
    overflow: hidden;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}
.modal-header h3 {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}
.modal-close {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1;
}
.modal-close:hover {
    color: var(--text-primary);
    border-color: var(--border-light);
}

.modal form { padding: 22px; }
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.file-drop {
    position: relative;
    border: 1.5px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    overflow: hidden;
    background: var(--bg-input);
}
.file-drop:hover {
    border-color: var(--accent);
    background: var(--accent-muted);
}
.file-drop input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.file-drop-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: var(--fw-medium);
}
.file-preview img {
    max-width: 100%;
    max-height: 180px;
    border-radius: var(--radius);
    object-fit: contain;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: var(--fw-medium);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    transform: translateY(60px);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 3px solid var(--accent); }
.toast.error { border-left: 3px solid var(--danger); color: var(--danger); }

/* Responsive */
@media (max-width: 768px) {
    html { font-size: 15px; }
    .dashboard-topbar { height: auto; flex-direction: column; }
    .topbar-left {
        width: 100%;
        min-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 14px 18px;
    }
    .topbar-right {
        padding: 12px 18px;
        flex-wrap: wrap;
    }
    .dashboard-main { flex-direction: column; overflow: visible; }
    .sidebar { width: 100%; min-width: 100%; }
    .welcome-grid { grid-template-columns: 1fr; }
    .content-panel { padding: 18px 16px; }
    .welcome-panel { padding: 24px 16px; }
    .filter-bar { flex-direction: column; }
    .login-card { padding: 36px 28px; }
}
