
:root{
  --bg:#07111f;
  --bg-soft:#0d1b2f;
  --card:rgba(15,28,48,.86);
  --card-2:rgba(20,38,64,.92);
  --text:#f7f9fc;
  --muted:#9fb0c8;
  --primary:#5b7cff;
  --primary-2:#7c4dff;
  --accent:#00d4ff;
  --success:#28d17c;
  --danger:#ff4d67;
  --warning:#ffca5c;
  --border:rgba(255,255,255,.09);
  --shadow:0 24px 60px rgba(0,0,0,.28);
}

*{
  box-sizing:border-box;
}

html{
  scroll-behavior:smooth;
}

body{
  margin:0;
  min-height:100vh;
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at 12% 18%, rgba(91,124,255,.22), transparent 28%),
    radial-gradient(circle at 88% 10%, rgba(0,212,255,.12), transparent 25%),
    radial-gradient(circle at 70% 90%, rgba(124,77,255,.15), transparent 30%),
    linear-gradient(145deg,#06101d 0%,#0a1628 45%,#08111f 100%);
  background-attachment:fixed;
}

body::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px,transparent 1px),
    linear-gradient(90deg,rgba(255,255,255,.018) 1px,transparent 1px);
  background-size:32px 32px;
  mask-image:linear-gradient(to bottom,rgba(0,0,0,.75),transparent 95%);
}

a{
  color:#b7c5ff;
  text-decoration:none;
  transition:.2s ease;
}

a:hover{
  color:#fff;
}

header{
  min-height:74px;
  padding:0 34px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  position:sticky;
  top:0;
  z-index:20;
  background:rgba(7,17,31,.78);
  border-bottom:1px solid var(--border);
  backdrop-filter:blur(18px);
  -webkit-backdrop-filter:blur(18px);
}

header strong{
  font-size:22px;
  letter-spacing:.3px;
  background:linear-gradient(90deg,#fff,#9fdfff);
  -webkit-background-clip:text;
  background-clip:text;
  color:transparent;
}

header nav{
  display:flex;
  align-items:center;
  gap:10px;
}

header nav a{
  padding:10px 14px;
  border-radius:10px;
  color:#d9e3f2;
  font-weight:700;
  font-size:14px;
}

header nav a:hover{
  background:rgba(255,255,255,.07);
}

main{
  width:min(1240px,calc(100% - 32px));
  margin:0 auto;
  padding:34px 0 50px;
  position:relative;
  z-index:1;
}

.admin-strip{
  margin-bottom:20px;
  padding:14px 16px;
  border:1px solid var(--border);
  border-radius:14px;
  background:linear-gradient(135deg,rgba(91,124,255,.15),rgba(0,212,255,.07));
  box-shadow:0 12px 30px rgba(0,0,0,.14);
}

.toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  padding:24px;
  margin-bottom:24px;
  background:linear-gradient(145deg,rgba(18,35,59,.94),rgba(11,25,43,.9));
  border:1px solid var(--border);
  border-radius:20px;
  box-shadow:var(--shadow);
}

.toolbar h1{
  margin:0 0 6px;
  font-size:30px;
  letter-spacing:-.6px;
}

.toolbar .muted{
  margin:0;
}

.actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.btn{
  appearance:none;
  border:0;
  outline:0;
  min-height:42px;
  padding:11px 16px;
  border-radius:12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  background:linear-gradient(135deg,var(--primary),var(--primary-2));
  color:#fff;
  font-weight:800;
  font-size:14px;
  cursor:pointer;
  box-shadow:0 10px 24px rgba(91,124,255,.28);
  transition:transform .18s ease,box-shadow .18s ease,filter .18s ease;
}

.btn:hover{
  transform:translateY(-2px);
  box-shadow:0 14px 30px rgba(91,124,255,.38);
  filter:brightness(1.05);
}

.btn:active{
  transform:translateY(0);
}

.btn.secondary{
  color:#eaf1ff;
  background:rgba(255,255,255,.07);
  border:1px solid var(--border);
  box-shadow:none;
}

.btn.secondary:hover{
  background:rgba(255,255,255,.11);
}

.btn.danger{
  background:linear-gradient(135deg,#ff4664,#d6284d);
  box-shadow:0 10px 22px rgba(255,70,100,.23);
}

.btn.small{
  min-height:36px;
  padding:8px 12px;
  border-radius:10px;
  font-size:12px;
}

.btn.full{
  width:100%;
}

.muted{
  color:var(--muted);
}

section{
  margin-top:26px;
}

section h2{
  margin:0 0 14px;
  font-size:18px;
  letter-spacing:.1px;
}

.folder-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(190px,1fr));
  gap:14px;
}

.folder-card{
  min-height:92px;
  padding:18px;
  display:flex;
  align-items:center;
  gap:12px;
  color:var(--text);
  font-weight:800;
  font-size:15px;
  border-radius:16px;
  background:linear-gradient(145deg,rgba(20,38,64,.95),rgba(13,27,47,.92));
  border:1px solid var(--border);
  box-shadow:0 12px 30px rgba(0,0,0,.16);
  transition:.2s ease;
}

.folder-card:hover{
  transform:translateY(-3px);
  border-color:rgba(91,124,255,.5);
  box-shadow:0 18px 36px rgba(0,0,0,.22);
}

.image-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(250px,1fr));
  gap:18px;
}

.image-card{
  overflow:hidden;
  border-radius:18px;
  background:linear-gradient(145deg,var(--card-2),var(--card));
  border:1px solid var(--border);
  box-shadow:0 16px 38px rgba(0,0,0,.2);
  transition:transform .2s ease,border-color .2s ease,box-shadow .2s ease;
}

.image-card:hover{
  transform:translateY(-4px);
  border-color:rgba(91,124,255,.45);
  box-shadow:0 22px 44px rgba(0,0,0,.28);
}

.image-card img{
  width:100%;
  aspect-ratio:16/10;
  object-fit:cover;
  display:block;
  background:
    linear-gradient(135deg,rgba(91,124,255,.15),rgba(0,212,255,.08)),
    #0b1728;
  border-bottom:1px solid var(--border);
}

.image-meta{
  padding:14px 15px 10px;
  display:flex;
  flex-direction:column;
  gap:5px;
}

.image-meta strong{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-size:14px;
}

.image-meta small{
  color:var(--muted);
}

.card-actions{
  padding:0 15px 15px;
  display:flex;
  gap:9px;
}

.card-actions form{
  margin:0;
}

.auth-body{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
}

.auth-card{
  width:min(470px,100%);
  padding:30px;
  border-radius:24px;
  background:linear-gradient(145deg,rgba(18,35,59,.96),rgba(10,23,40,.94));
  border:1px solid var(--border);
  box-shadow:var(--shadow);
  backdrop-filter:blur(16px);
}

.auth-card h1{
  margin:0 0 8px;
  font-size:30px;
}

.auth-card p{
  color:var(--muted);
  margin-top:0;
}

label{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-bottom:15px;
  color:#e8edf7;
  font-weight:800;
  font-size:13px;
}

input{
  width:100%;
  min-height:46px;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.055);
  color:#fff;
  font:inherit;
  outline:none;
  transition:.2s ease;
}

input::placeholder{
  color:#6f819a;
}

input:focus{
  border-color:rgba(91,124,255,.8);
  box-shadow:0 0 0 4px rgba(91,124,255,.12);
  background:rgba(255,255,255,.075);
}

hr{
  border:0;
  border-top:1px solid var(--border);
  margin:22px 0;
}

.alert{
  padding:13px 14px;
  border-radius:12px;
  margin:15px 0;
  border:1px solid transparent;
}

.alert.error{
  background:rgba(255,77,103,.12);
  color:#ffafbc;
  border-color:rgba(255,77,103,.25);
}

.alert.success{
  background:rgba(40,209,124,.12);
  color:#93efbd;
  border-color:rgba(40,209,124,.25);
}

dialog{
  width:min(440px,92vw);
  border:1px solid var(--border);
  border-radius:20px;
  padding:24px;
  color:var(--text);
  background:linear-gradient(145deg,#132743,#0c1a2d);
  box-shadow:var(--shadow);
}

dialog::backdrop{
  background:rgba(2,8,15,.72);
  backdrop-filter:blur(4px);
}

.dialog-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:6px;
}

.panel{
  padding:20px;
  margin-bottom:22px;
  border-radius:18px;
  background:linear-gradient(145deg,var(--card-2),var(--card));
  border:1px solid var(--border);
  box-shadow:0 16px 38px rgba(0,0,0,.18);
}

.inline-form{
  display:grid;
  grid-template-columns:1fr 1fr auto;
  gap:14px;
  align-items:end;
}

.inline-form label{
  margin:0;
}

.admin-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(250px,1fr));
  gap:16px;
}

.admin-card{
  padding:20px;
  border-radius:18px;
  background:linear-gradient(145deg,var(--card-2),var(--card));
  border:1px solid var(--border);
  box-shadow:0 16px 38px rgba(0,0,0,.18);
}

.admin-card h3{
  margin:0 0 4px;
  font-size:20px;
}

.admin-stats{
  display:flex;
  gap:9px;
  margin:16px 0;
  flex-wrap:wrap;
}

.admin-stats span{
  padding:7px 10px;
  border-radius:999px;
  color:#dfe7f7;
  background:rgba(255,255,255,.065);
  border:1px solid var(--border);
  font-size:12px;
  font-weight:700;
}

@media(max-width:760px){
  header{
    min-height:68px;
    padding:0 16px;
  }

  header nav{
    gap:4px;
  }

  header nav a{
    padding:8px 9px;
    font-size:12px;
  }

  main{
    width:min(100% - 20px,1240px);
    padding:20px 0 38px;
  }

  .toolbar{
    padding:18px;
    align-items:flex-start;
    flex-direction:column;
  }

  .toolbar h1{
    font-size:25px;
  }

  .actions{
    width:100%;
  }

  .actions .btn{
    flex:1;
  }

  .inline-form{
    grid-template-columns:1fr;
  }

  .image-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:11px;
  }

  .image-card{
    border-radius:14px;
  }

  .card-actions{
    flex-direction:column;
  }

  .card-actions .btn,
  .card-actions form,
  .card-actions form .btn{
    width:100%;
  }
}

@media(max-width:470px){
  .image-grid{
    grid-template-columns:1fr;
  }
}

/* Preview upload */
.preview-modal{
  width:min(980px,94vw);
  max-height:88vh;
  padding:0;
  overflow:hidden;
}

.preview-header,
.preview-footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:20px 22px;
  background:rgba(255,255,255,.025);
}

.preview-header{
  border-bottom:1px solid var(--border);
}

.preview-footer{
  border-top:1px solid var(--border);
  justify-content:flex-end;
}

.preview-header h3{
  margin:0 0 5px;
  font-size:21px;
}

.preview-header p{
  margin:0;
}

.preview-close{
  width:38px;
  height:38px;
  border:1px solid var(--border);
  border-radius:11px;
  background:rgba(255,255,255,.06);
  color:#fff;
  font-size:25px;
  line-height:1;
  cursor:pointer;
}

.preview-grid{
  max-height:58vh;
  overflow:auto;
  padding:20px;
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(190px,1fr));
  gap:14px;
}

.preview-card{
  overflow:hidden;
  border-radius:15px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.04);
}

.preview-card img{
  width:100%;
  aspect-ratio:16/10;
  object-fit:cover;
  display:block;
  background:#0b1728;
}

.preview-info{
  padding:11px;
  display:grid;
  gap:5px;
}

.preview-info strong{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-size:13px;
}

.preview-info small{
  color:var(--muted);
}

.remove-preview{
  margin-top:4px;
  padding:7px 9px;
  border:1px solid rgba(255,77,103,.25);
  border-radius:9px;
  background:rgba(255,77,103,.12);
  color:#ff9aab;
  font-weight:800;
  cursor:pointer;
}

#confirmUpload:disabled{
  opacity:.65;
  cursor:not-allowed;
  transform:none;
}

@media(max-width:600px){
  .preview-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
    padding:14px;
  }

  .preview-header,
  .preview-footer{
    padding:15px;
  }

  .preview-footer .btn{
    flex:1;
  }
}

.upload-preview-area {
  margin-top: 20px;
  padding: 20px;
  border-radius: 18px;
  background: linear-gradient(
    145deg,
    rgba(20, 38, 64, 0.95),
    rgba(13, 27, 47, 0.92)
  );
  border: 1px solid var(--border);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.18);
}

.upload-preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.upload-preview-top strong {
  font-size: 18px;
}

.upload-preview-top p {
  margin: 5px 0 0;
  color: var(--muted);
}

.upload-preview-actions {
  display: flex;
  gap: 10px;
}

.upload-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.upload-preview-card {
  overflow: hidden;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
}

.upload-preview-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
  background: #0b1728;
}

.upload-preview-info {
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.upload-preview-info strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.upload-preview-info small {
  color: var(--muted);
}

.upload-preview-remove {
  margin-top: 5px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 77, 103, 0.25);
  border-radius: 9px;
  background: rgba(255, 77, 103, 0.12);
  color: #ff9aab;
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 650px) {
  .upload-preview-top {
    flex-direction: column;
    align-items: stretch;
  }

  .upload-preview-actions {
    width: 100%;
  }

  .upload-preview-actions .btn {
    flex: 1;
  }

  .upload-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
