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

:root {
	--red:       #D8232A;
	--red-dark:  #A81820;
	--red-light: #F03A40;
	--green:     #1A3A2A;
	--green2:    #2C5F3E;
	--cream:     #F5F0E8;
	--cream2:    #EDE6D6;
	--sand:      #C8B89A;
	--dark:      #111410;
	--text:      #1C1C1C;
	--muted:     #7A7060;
	--white:     #FFFFFF;
	--border:    #DDD5C5;
	--radius:    3px;
	--mono:      'DM Mono', monospace;
	--body:      'Barlow', sans-serif;
	--display:   'Barlow Condensed', sans-serif;
}

html { scroll-behavior: smooth; }

body {
	background: var(--cream);
	color: var(--text);
	font-family: var(--body);
	font-size: 14px;
	line-height: 1.5;
	min-height: 100vh;
}

/* ─ Texture overlay ──────────────────────── */
body::after {
	content:'';
	position:fixed; inset:0;
	background-image:
		repeating-linear-gradient(0deg,   transparent, transparent 39px, rgba(0,0,0,0.03) 40px),
		repeating-linear-gradient(90deg,  transparent, transparent 39px, rgba(0,0,0,0.02) 40px);
	pointer-events:none;
	z-index:999;
}

/* ─ Header ───────────────────────────────── */
header {
	background: var(--red);
	position: sticky; top: 0; z-index: 200;
	box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

.header-stripe {
	height: 4px;
	background: repeating-linear-gradient(90deg, var(--green) 0px, var(--green) 20px, var(--red-dark) 20px, var(--red-dark) 40px);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: 60px;
}

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

.fleur {
    font-size: 28px;
    color: var(--white);
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.logo-text { line-height: 1; }
.logo-title {
    font-family: var(--display);
    font-size: 22px;
    font-weight: 800;
    color: var(--white);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.logo-sub {
    font-family: var(--display);
    font-size: 11px;
    font-weight: 400;
    color: rgba(255,255,255,0.65);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

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

.dni-chip {
    font-family: var(--mono);
    font-size: 12px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: var(--white);
    padding: 4px 12px;
    border-radius: 2px;
    letter-spacing: 0.06em;
}

.btn-salir {
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
    font-family: var(--display);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.08em;
    padding: 6px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.15s;
}
.btn-salir:hover { background: rgba(0,0,0,0.35); color: var(--white); }

/* ─ Login ────────────────────────────────── */
#login-screen {
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(216,35,42,0.08) 0%, transparent 70%),
        var(--cream);
}

.login-card {
    width: 100%;
    max-width: 440px;
}

.login-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--red);
    color: var(--white);
    font-family: var(--display);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 2px;
    margin-bottom: 20px;
}

.login-heading {
    font-family: var(--display);
    font-size: clamp(52px, 12vw, 80px);
    font-weight: 800;
    line-height: 0.95;
    color: var(--dark);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 6px;
}
.login-heading .accent { color: var(--red); }

.login-desc {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 36px;
    padding-left: 14px;
    border-left: 3px solid var(--red);
    line-height: 1.6;
    }

.field { margin-bottom: 16px; }
.field label {
display: block;
font-family: var(--display);
font-size: 12px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
color: var(--muted);
margin-bottom: 6px;
}
.field input {
width: 100%;
background: var(--white);
border: 1.5px solid var(--border);
border-radius: var(--radius);
color: var(--dark);
font-family: var(--mono);
font-size: 20px;
padding: 13px 16px;
outline: none;
transition: border-color 0.15s, box-shadow 0.15s;
-webkit-appearance: none;
}
.field input:focus {
border-color: var(--red);
box-shadow: 0 0 0 3px rgba(216,35,42,0.1);
}
.field input::placeholder { color: #ccc; }
.field input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }

.btn-enter {
width: 100%;
background: var(--red);
border: none;
border-radius: var(--radius);
color: var(--white);
font-family: var(--display);
font-size: 22px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
padding: 16px;
cursor: pointer;
transition: background 0.15s, transform 0.1s;
margin-top: 4px;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}
.btn-enter:hover  { background: var(--red-dark); }
.btn-enter:active { transform: scale(0.98); }
.btn-enter:disabled { opacity: 0.4; cursor: not-allowed; }

.login-error {
margin-top: 10px;
font-family: var(--mono);
font-size: 12px;
color: var(--red);
display: none;
}
.login-error.show { display: block; }

/* ─ Dashboard layout ─────────────────────── */
#dashboard { display: none; }
#dashboard.show { display: block; }

.dash-wrap {
display: grid;
grid-template-columns: 240px 1fr;
min-height: calc(100vh - 64px);
align-items: start;
}

/* ─ Sidebar ──────────────────────────────── */
.sidebar {
background: var(--green);
min-height: calc(100vh - 64px);
position: sticky;
top: 64px;
height: calc(100vh - 64px);
overflow-y: auto;
display: flex;
flex-direction: column;
padding: 24px 0 32px;
}

.sidebar-section { margin-bottom: 8px; }

.sidebar-label {
font-family: var(--display);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.18em;
text-transform: uppercase;
color: rgba(255,255,255,0.35);
padding: 0 20px 8px;
}

.nav-item {
display: flex;
align-items: center;
gap: 10px;
padding: 11px 20px;
cursor: pointer;
border-left: 3px solid transparent;
color: rgba(255,255,255,0.55);
font-family: var(--display);
font-size: 15px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
transition: all 0.15s;
user-select: none;
}
.nav-item:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.06); }
.nav-item.active {
color: var(--white);
border-left-color: var(--red);
background: rgba(216,35,42,0.15);
}

.nav-count {
margin-left: auto;
font-family: var(--mono);
font-size: 11px;
color: rgba(255,255,255,0.4);
background: rgba(0,0,0,0.2);
padding: 2px 7px;
border-radius: 2px;
}
.nav-item.active .nav-count { color: rgba(255,255,255,0.8); }

.sidebar-divider {
height: 1px;
background: rgba(255,255,255,0.08);
margin: 16px 20px;
}

/* Upload box in sidebar */
.upload-box {
margin: 4px 16px 0;
border: 2px dashed rgba(255,255,255,0.18);
border-radius: var(--radius);
padding: 22px 12px;
text-align: center;
cursor: pointer;
transition: all 0.2s;
position: relative;
background: rgba(0,0,0,0.1);
}
.upload-box:hover, .upload-box.drag {
border-color: var(--red-light);
background: rgba(216,35,42,0.12);
}
.upload-box input {
position: absolute; inset: 0;
opacity: 0; cursor: pointer; width: 100%;
}
.ub-icon {
font-size: 28px;
margin-bottom: 6px;
color: var(--white);
opacity: 0.7;
}
.ub-title {
font-family: var(--display);
font-size: 14px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.08em;
margin-bottom: 3px;
color: var(--white);
opacity: 0.7;
}
.ub-sub {
font-family: var(--mono);
font-size: 10px;
color: rgba(255,255,255,0.35);
}

/* Progress */
.upload-progress { margin: 12px 16px 0; display: none; }
.upload-progress.show { display: block; }
.prog-label {
display: flex; justify-content: space-between;
font-family: var(--mono); font-size: 10px;
color: rgba(255,255,255,0.45);
margin-bottom: 5px;
}
.prog-bar { height: 3px; background: rgba(255,255,255,0.12); border-radius: 2px; overflow: hidden; }
.prog-fill { height: 100%; background: var(--red-light); border-radius: 2px; transition: width 0.2s; width: 0%; }

.sidebar-bottom {
margin-top: auto;
padding: 0 20px;
}
.sidebar-brand {
font-family: var(--display);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
color: rgba(255,255,255,0.2);
text-align: center;
padding-top: 20px;
border-top: 1px solid rgba(255,255,255,0.06);
}

/* ─ Main ─────────────────────────────────── */
.main {
background: var(--cream);
padding: 32px;
min-height: calc(100vh - 64px);
}

.section { display: none; }
.section.active { display: block; }

.section-head {
display: flex;
align-items: flex-end;
justify-content: space-between;
margin-bottom: 24px;
padding-bottom: 16px;
border-bottom: 2px solid var(--border);
gap: 12px;
flex-wrap: wrap;
}

.section-title {
font-family: var(--display);
font-size: 42px;
font-weight: 800;
line-height: 1;
text-transform: uppercase;
letter-spacing: 0.03em;
color: var(--dark);
}
.section-title .accent { color: var(--red); }

.section-meta {
font-family: var(--mono);
font-size: 11px;
color: var(--muted);
padding: 4px 10px;
background: var(--cream2);
border: 1px solid var(--border);
border-radius: 2px;
white-space: nowrap;
}

/* ─ Grid ─────────────────────────────────── */
.media-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
gap: 3px;
}

.media-card {
position: relative;
aspect-ratio: 1;
overflow: hidden;
background: var(--cream2);
cursor: pointer;
}
.media-card img,
.media-card video {
width: 100%; height: 100%;
object-fit: cover;
display: block;
transition: transform 0.35s ease;
}
.media-card:hover img,
.media-card:hover video { transform: scale(1.06); }

.card-overlay {
position: absolute; inset: 0;
background: linear-gradient(to top, rgba(10,20,10,0.82) 0%, rgba(0,0,0,0.1) 45%, transparent 70%);
opacity: 0;
transition: opacity 0.2s;
display: flex;
flex-direction: column;
justify-content: flex-end;
padding: 12px;
gap: 6px;
}
.media-card:hover .card-overlay { opacity: 1; }

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

.card-size {
font-family: var(--mono);
font-size: 10px;
color: rgba(255,255,255,0.7);
}

.btn-del {
width: 30px; height: 30px;
background: rgba(216,35,42,0.2);
border: 1px solid rgba(216,35,42,0.5);
border-radius: 2px;
color: #ff8080;
font-size: 14px;
display: flex; align-items: center; justify-content: center;
cursor: pointer;
flex-shrink: 0;
transition: all 0.15s;
}
.btn-del:hover { background: var(--red); color: #fff; border-color: var(--red); }

.card-dni {
position: absolute;
top: 8px; left: 8px;
font-family: var(--mono);
font-size: 10px;
background: rgba(26,58,42,0.75);
border: 1px solid rgba(255,255,255,0.12);
color: rgba(255,255,255,0.8);
padding: 2px 7px;
border-radius: 2px;
backdrop-filter: blur(4px);
}
.card-dni.mine {
background: rgba(168,24,32,0.8);
border-color: rgba(255,255,255,0.2);
color: #fff;
}

.card-video-badge {
position: absolute;
top: 8px; right: 8px;
background: rgba(0,0,0,0.6);
color: #fff;
font-size: 10px;
padding: 2px 6px;
border-radius: 2px;
font-family: var(--mono);
}

/* ─ Empty & skeleton ─────────────────────── */
.empty-state {
grid-column: 1/-1;
text-align: center;
padding: 80px 20px;
color: var(--muted);
}
.empty-icon { font-size: 44px; margin-bottom: 12px; opacity: 0.3; }
.empty-text { font-family: var(--display); font-size: 22px; font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }
.empty-sub  { font-family: var(--mono); font-size: 12px; opacity: 0.7; }

.skeleton-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
gap: 3px;
}
.skel {
aspect-ratio: 1;
background: linear-gradient(90deg, var(--cream2) 0%, var(--border) 50%, var(--cream2) 100%);
background-size: 200% 100%;
animation: shimmer 1.6s infinite;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ─ Load more ────────────────────────────── */
.loadmore-row {
margin-top: 28px;
display: flex; justify-content: center;
}
.btn-more {
background: none;
border: 2px solid var(--border);
color: var(--muted);
font-family: var(--display);
font-size: 14px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
padding: 10px 28px;
border-radius: var(--radius);
cursor: pointer;
transition: all 0.15s;
}
.btn-more:hover { border-color: var(--red); color: var(--red); }
.btn-more:disabled { opacity: 0.35; cursor: not-allowed; }

/* ─ Modal API Key ────────────────────────── */
#modal-bg {
position: fixed; inset: 0;
background: rgba(0,0,0,0.6);
backdrop-filter: blur(6px);
z-index: 500;
display: none;
align-items: center;
justify-content: center;
padding: 20px;
}
#modal-bg.show { display: flex; }

.modal {
background: var(--white);
border-radius: 4px;
width: 100%; max-width: 380px;
overflow: hidden;
box-shadow: 0 32px 80px rgba(0,0,0,0.4);
animation: pop-in 0.2s ease;
}
@keyframes pop-in { from { transform: scale(0.94) translateY(8px); opacity:0; } }

.modal-header {
background: var(--red);
padding: 18px 24px;
}
.modal-header .fleur { font-size: 20px; color: rgba(255,255,255,0.6); margin-bottom: 4px; }
.modal-header h3 {
font-family: var(--display);
font-size: 26px;
font-weight: 800;
color: var(--white);
text-transform: uppercase;
letter-spacing: 0.05em;
}
.modal-header p {
font-size: 12px;
color: rgba(255,255,255,0.65);
margin-top: 2px;
font-family: var(--mono);
}

.modal-body { padding: 20px 24px 24px; }
.modal-body .field { margin-bottom: 0; }

.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.btn-ok {
flex: 1;
background: var(--red);
border: none;
border-radius: var(--radius);
color: var(--white);
font-family: var(--display);
font-size: 18px;
font-weight: 800;
text-transform: uppercase;
letter-spacing: 0.08em;
padding: 12px;
cursor: pointer;
transition: background 0.15s;
}
.btn-ok:hover { background: var(--red-dark); }

.btn-cancel-modal {
background: none;
border: 1.5px solid var(--border);
border-radius: var(--radius);
color: var(--muted);
font-family: var(--display);
font-size: 14px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.06em;
padding: 12px 16px;
cursor: pointer;
transition: all 0.15s;
}
.btn-cancel-modal:hover { border-color: var(--red); color: var(--red); }

/* ─ Lightbox ─────────────────────────────── */
#lightbox {
position: fixed; inset: 0;
background: rgba(5,12,5,0.94);
z-index: 700;
display: none;
align-items: center;
justify-content: center;
}
#lightbox.show { display: flex; }
#lightbox img, #lightbox video {
max-width: 92vw; max-height: 92vh;
object-fit: contain;
border-radius: 2px;
box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
#lb-close {
position: absolute; top: 18px; right: 22px;
font-size: 30px; color: rgba(255,255,255,0.5);
cursor: pointer; background: none; border: none;
transition: color 0.15s;
}
#lb-close:hover { color: var(--white); }

/* ─ Toasts ───────────────────────────────── */
#toasts {
position: fixed;
bottom: 20px; right: 20px;
display: flex; flex-direction: column; gap: 8px;
z-index: 800;
}
.toast {
font-family: var(--mono);
font-size: 12px;
padding: 11px 16px 11px 14px;
border-radius: var(--radius);
border-left: 4px solid;
background: var(--dark);
color: var(--white);
max-width: 300px;
box-shadow: 0 4px 20px rgba(0,0,0,0.35);
animation: slide-in 0.2s ease;
}
.toast.ok  { border-color: #3cb96a; }
.toast.err { border-color: var(--red); }
.toast.inf { border-color: var(--sand); }
@keyframes slide-in { from{transform:translateX(16px);opacity:0} to{transform:translateX(0);opacity:1} }

/* ─ Responsive ───────────────────────────── */
@media (max-width: 768px) {
	.dash-wrap { grid-template-columns: 1fr; }
	.sidebar {
		min-height: auto; height: auto;
		position: static;
		flex-direction: row; flex-wrap: wrap;
		padding: 8px 12px; gap: 0;
		border-bottom: 1px solid rgba(255,255,255,0.08);
	}

	.sidebar-label, .sidebar-divider, .sidebar-bottom { display: none; }

	.nav-item {
		padding: 10px 14px;
		border-left: none;
		border-bottom: 3px solid transparent;
		font-size: 13px;
	}

	.nav-item.active { border-bottom-color: var(--red); background: none; }
	.main { padding: 20px 14px; }
	.header-inner { padding: 0 16px; }
	.media-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
	.section-title { font-size: 30px; }

	.sidebar-section {
		display: flex;
	}

	/* .upload-progress */
	.upload-box {
		padding: 12px;
		display: flex;
		gap: 12px;
		align-items: center;
	}
	.upload-box > .ub-sub {
		display: none;
	}
	.upload-box > .ub-icon {
		font-size: 16px;
		margin: 0;
		opacity: 1;
	}

}