:root {
  --bg: #0b0f14;
  --panel: #121923;
  --panel-2: #17212e;
  --text: #eef3f8;
  --muted: #91a0af;
  --line: #263444;
  --accent: #26c6da;
  --accent-2: #7dd3fc;
  --danger: #fb7185;
  --ok: #34d399;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --radius: 8px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    radial-gradient(circle at top, rgba(38, 198, 218, 0.14), transparent 38%),
    var(--bg);
  background-size: 34px 34px, 34px 34px, auto, auto;
}

.auth-card {
  width: min(420px, 100%);
  background: rgba(18, 25, 35, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-mark, .brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #0f2f38;
  color: var(--accent-2);
  font-family: var(--mono);
  font-weight: 700;
}

.auth-card h1, .topbar h1, .panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.auth-card h1 {
  margin-top: 18px;
  font-size: 26px;
}

.auth-card p, .panel p {
  color: var(--muted);
  line-height: 1.55;
  margin: 8px 0 24px;
}

.auth-error {
  min-height: 20px;
  margin-top: 14px;
  color: var(--danger);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  background: #0f151d;
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title { font-weight: 800; }
.brand-subtitle, .eyebrow {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.side-menu {
  display: grid;
  gap: 8px;
}

.side-link {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 12px 14px;
}

.side-link.active,
.side-link:hover {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--line);
}

.sidebar .btn { margin-top: auto; }

.content {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 26px;
}

.topbar h1 { font-size: 28px; }

.status-pill {
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: var(--ok);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card,
.panel,
.file-card,
.folder-card,
.empty-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-card {
  padding: 18px;
}

.stat-card span,
.breakdown-grid span,
.file-body span,
.folder-card small {
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.panel {
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.panel-header,
.gallery-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.breakdown-grid div {
  background: var(--panel);
  padding: 20px;
}

.breakdown-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.field-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0d131a;
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(38, 198, 218, 0.12);
}

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-weight: 700;
}

.btn-wide { width: 100%; justify-content: center; }
.btn-primary { background: var(--accent); color: #062027; }
.btn-secondary { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.btn-danger { background: rgba(251, 113, 133, 0.13); color: var(--danger); border-color: rgba(251, 113, 133, 0.35); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.upload-panel { max-width: 860px; }
.upload-controls { padding: 20px 20px 0; }

.upload-zone {
  position: relative;
  margin: 20px;
  padding: 44px 20px;
  text-align: center;
  border: 2px dashed #365062;
  border-radius: var(--radius);
  background: #0d141c;
}

.upload-zone.drag-over,
.upload-zone:hover { border-color: var(--accent); }
.upload-zone.uploading { opacity: .65; pointer-events: none; }

.upload-zone-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  border-radius: var(--radius);
  background: #12323b;
  color: var(--accent-2);
  font-family: var(--mono);
  font-weight: 700;
}

.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.selected-files {
  margin: 0 20px 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0d131a;
  color: var(--muted);
}

.selected-files strong {
  display: block;
  color: var(--text);
  margin-bottom: 8px;
}

.selected-files ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.selected-files li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 13px;
}

.selected-files li span {
  color: var(--muted);
  white-space: nowrap;
}

.upload-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 20px 20px;
}

.upload-result {
  margin: 0 20px 20px;
  padding: 14px;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: var(--radius);
  background: rgba(52, 211, 153, 0.08);
}

.upload-result > strong {
  display: block;
  margin-bottom: 10px;
}

.url-list {
  display: grid;
  gap: 8px;
}

.url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.url-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.upload-progress {
  margin: 0 20px 20px;
}

.progress-bar-wrapper {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #0d131a;
}

.progress-bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .2s ease;
}

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

.gallery-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(440px, 100%);
}

.search-input { min-width: 240px; }
.limit-select { width: 90px; }

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.breadcrumbs button {
  border: 0;
  background: transparent;
  color: var(--accent-2);
  padding: 0;
}

.breadcrumbs span { color: var(--muted); }

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  padding: 20px 20px 0;
}

.folder-card {
  display: grid;
  gap: 8px;
  text-align: left;
  padding: 16px;
  color: var(--text);
}

.folder-card:hover,
.file-card:hover { border-color: #426074; background: var(--panel-2); }

.folder-icon {
  width: 42px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #162d35;
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 12px;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  padding: 20px;
}

.file-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.file-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.file-icon.image { background: rgba(125, 211, 252, .12); color: #7dd3fc; }
.file-icon.video { background: rgba(38, 198, 218, .12); color: #26c6da; }
.file-icon.doc { background: rgba(52, 211, 153, .12); color: #34d399; }
.file-icon.archive { background: rgba(251, 191, 36, .12); color: #fbbf24; }
.file-icon.other { background: rgba(148, 163, 184, .12); color: #cbd5e1; }

.file-body { min-width: 0; }
.file-body strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-body span {
  display: block;
  margin-top: 6px;
}

.file-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
}

.empty-card {
  grid-column: 1 / -1;
  padding: 36px;
  color: var(--muted);
  text-align: center;
}

.pagination-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 0 20px 20px;
  color: var(--muted);
}

#toast-container {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 44px));
}

.toast {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  background: #101821;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--ok); }
.toast strong,
.toast span { display: block; }
.toast span { margin-top: 3px; color: var(--muted); font-size: 13px; }
.toast button { border: 0; background: transparent; color: var(--muted); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }
  .side-menu { grid-template-columns: repeat(3, minmax(0, 1fr)); flex: 1; }
  .sidebar .btn { margin-top: 0; width: auto; }
  .stats-grid, .breakdown-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gallery-toolbar { flex-direction: column; }
  .gallery-actions { min-width: 0; width: 100%; }
}

@media (max-width: 560px) {
  .content { padding: 18px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .stats-grid, .breakdown-grid { grid-template-columns: 1fr; }
  .gallery-actions { flex-direction: column; align-items: stretch; }
  .search-input, .limit-select { width: 100%; min-width: 0; }
  .file-grid { grid-template-columns: 1fr; }
}
