:root {
  --bg: #0b0c0f;
  --bg-elev: #14161b;
  --bg-elev-2: #1b1e25;
  --border: #272a33;
  --text: #ece9e2;
  --text-muted: #8d8f99;
  --accent: #c9a24b;
  --accent-soft: rgba(201, 162, 75, 0.14);
  --danger: #e2574c;
  --success: #4caf7d;
  --radius: 14px;
  --shadow: 0 20px 60px -20px rgba(0,0,0,0.6);
  font-family: -apple-system, "Inter", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
.muted { color: var(--text-muted); }

/* ---- Auth ---- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 0%, #1a1c22 0%, #0b0c0f 60%);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 36px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.brand-mark { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.brand-name { font-size: 15px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.auth-card h1 { margin: 0 0 6px; font-size: 24px; font-weight: 600; }
.auth-card p { margin: 0 0 24px; }

form label { display: block; margin-bottom: 16px; font-size: 13px; color: var(--text-muted); }
input, select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 11px 14px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0b0c0f; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-block { width: 100%; margin-top: 8px; }
.btn-danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.alert { padding: 10px 14px; background: rgba(226,87,76,0.12); border: 1px solid rgba(226,87,76,0.4); border-radius: 10px; color: #f0a8a2; font-size: 13px; margin-bottom: 18px; }

/* ---- Shell / nav ---- */
.shell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(11,12,15,0.85);
  backdrop-filter: blur(10px);
  z-index: 50;
}
.shell-main { padding: 32px; max-width: 1400px; margin: 0 auto; }
.crumbs { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--accent); }

.page-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }
.page-title h1 { font-size: 28px; margin: 0; font-weight: 600; }

/* ---- Cards / grid of galleries or clients ---- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.entity-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: border-color .15s ease, transform .15s ease;
}
.entity-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.entity-card h3 { margin: 0 0 6px; font-size: 17px; }
.entity-card .count { font-size: 13px; color: var(--text-muted); }

/* ---- Photo grid ---- */
.filter-bar { display: flex; gap: 8px; margin-bottom: 20px; }
.filter-bar button {
  padding: 7px 16px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--text-muted); font-size: 13px; cursor: pointer;
  transition: all .15s ease;
}
.filter-bar button:hover { border-color: var(--accent); }
.filter-bar button.active { background: var(--accent); border-color: var(--accent); color: #0b0c0f; font-weight: 600; }

.photo-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.photo-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  cursor: pointer;
}
.photo-tile img, .photo-tile .no-thumb {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.photo-tile .no-thumb { display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.photo-tile .kind-badge {
  position: absolute; top: 8px; left: 8px;
  font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 6px;
  background: rgba(0,0,0,0.55); color: #fff;
}
.thumb-open { position: absolute; inset: 0; cursor: zoom-in; }

.photo-tile .zip-toggle {
  position: absolute; top: 8px; right: 8px;
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 6px;
  border-radius: 20px;
  border: 1.5px solid rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  transition: all .15s ease;
  z-index: 2;
}
.photo-tile .zip-toggle-icon {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid currentColor;
  position: relative;
  flex-shrink: 0;
}
.photo-tile .zip-toggle-icon::before, .photo-tile .zip-toggle-icon::after {
  content: ""; position: absolute; background: currentColor;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
}
.photo-tile .zip-toggle-icon::before { width: 8px; height: 1.5px; }
.photo-tile .zip-toggle-icon::after { width: 1.5px; height: 8px; }
.photo-tile .zip-toggle:hover { border-color: var(--accent); }
.photo-tile.selected .zip-toggle {
  background: var(--accent); border-color: var(--accent); color: #0b0c0f;
}
.photo-tile.selected .zip-toggle-icon::after { display: none; }
.photo-tile .video-download { text-decoration: none; padding: 5px 10px; }

.photo-tile .kill-btn {
  position: absolute; top: 8px; left: 8px;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.45);
  color: #fff; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 3;
  transition: all .15s ease;
}
.photo-tile .kill-btn:hover { background: var(--danger); border-color: var(--danger); }
.photo-tile .kill-btn:disabled { opacity: .5; cursor: wait; }
.photo-tile .fname {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 18px 8px 6px;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.download-bar {
  position: fixed;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px));
  left: 50%;
  right: auto;
  transform: translateX(-50%) translateY(120%);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 16px;
  padding: 12px 18px;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  border-radius: 50px;
  box-shadow: var(--shadow);
  transition: transform .2s ease;
  z-index: 100;
}
.download-bar.visible { transform: translateX(-50%) translateY(0); }
@media (max-width: 480px) {
  .download-bar {
    border-radius: 20px;
    gap: 8px 10px;
    padding: 10px 14px;
  }
  .download-bar .btn { padding: 8px 12px; font-size: 13px; }
  .download-bar .sel-count { font-size: 13px; }
}
.download-bar .sel-count { font-weight: 600; }
.sel-count-btn {
  background: none; border: none; color: var(--text); cursor: pointer;
  padding: 0; font: inherit;
}
.sel-count-btn:hover .sel-count { color: var(--accent); }
.btn-empty-zip { color: var(--text-muted); font-size: 13px; padding: 9px 14px; }
.btn-empty-zip:hover { color: var(--danger); border-color: var(--danger); }

.zip-panel {
  position: fixed;
  bottom: max(96px, calc(env(safe-area-inset-bottom) + 84px));
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 24px));
  max-height: min(320px, 50vh);
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 99;
  display: none;
  padding: 8px;
}
.zip-panel.open { display: block; }
.zip-panel-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 13px;
}
.zip-panel-item:hover { background: var(--bg-elev-2); }
.zip-panel-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zip-panel-remove {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
}
.zip-panel-remove:hover { background: var(--danger); color: #fff; }
.zip-panel-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ---- Badges / misc ---- */
.badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }

.upload-drop {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  transition: border-color .15s ease;
}
.upload-drop.dragover { border-color: var(--accent); background: var(--accent-soft); }
.upload-progress-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; font-size: 13px; }
.upload-progress-row .bar { flex: 1; height: 6px; border-radius: 4px; background: var(--bg-elev-2); overflow: hidden; }
.upload-progress-row .bar-fill { height: 100%; background: var(--accent); width: 0%; transition: width .2s ease; }

/* ---- Lightbox ---- */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(6,7,9,0.92);
  backdrop-filter: blur(6px);
  display: none;
  flex-direction: column;
  z-index: 500;
}
.lightbox.open { display: flex; }
.lb-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 90px;
  min-height: 0;
}
.lb-processing {
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 420px;
  padding: 32px;
  color: var(--text-muted);
  font-size: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.lb-image, .lb-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.lb-close {
  position: absolute; top: 20px; right: 24px;
  background: none; border: none; color: #fff;
  font-size: 22px; cursor: pointer; z-index: 10;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.lb-close:hover { background: rgba(255,255,255,0.1); }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.08); border: 1px solid var(--border);
  color: #fff; width: 48px; height: 48px; border-radius: 50%;
  font-size: 26px; cursor: pointer; z-index: 10;
}
.lb-nav:hover { background: rgba(255,255,255,0.16); }
.lb-prev { left: 20px; }
.lb-next { right: 20px; }
.lb-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.lb-fname { color: var(--text-muted); font-size: 13px; }
.lb-actions { display: flex; gap: 10px; }
.lb-zip-toggle.active { background: var(--accent); border-color: var(--accent); color: #0b0c0f; font-weight: 600; }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 18px; border-radius: 10px;
  background: var(--bg-elev); border: 1px solid var(--border);
  font-size: 13px; box-shadow: var(--shadow);
  z-index: 200;
}
