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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2a2a2a;
  --accent: #c8a96e;
  --accent-dim: #a08050;
  --text: #e8e8e8;
  --muted: #888;
  --danger: #e05555;
  --radius: 8px;
  --font: 'Inter', system-ui, sans-serif;
}

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

/* ── Login ── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--accent);
  margin-bottom: 8px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.3px;
  flex: 1;
}

.brand-logo {
  height: 32px;
  width: auto;
  filter: invert(1) sepia(1) saturate(2) hue-rotate(5deg) brightness(0.85);
}

.login-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 36px;
}

.field { margin-bottom: 20px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

input[type=text], input[type=password] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  padding: 12px 14px;
  transition: border-color 0.15s;
  outline: none;
}

input:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: var(--radius);
  padding: 13px 20px;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}

.btn:hover { background: var(--accent-dim); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--border); color: var(--text); }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 16px;
  display: none;
}

.error-msg.show { display: block; }

/* ── Portal layout ── */
.portal {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.header {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}


.header-user {
  font-size: 13px;
  color: var(--muted);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
  width: auto;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
}

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

.sidebar-client {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 20px 4px;
}

.sidebar-folder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.1s;
  color: var(--text);
  user-select: none;
}

.sidebar-folder:hover { background: var(--border); }
.sidebar-folder.active { background: rgba(200,169,110,0.12); color: var(--accent); }

.folder-icon { font-size: 16px; flex-shrink: 0; }

/* Main content */
.main {
  overflow-y: auto;
  padding: 32px;
}

.main-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
}

.main-path {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}

/* File grid */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.file-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
}

.file-thumb {
  width: 100%;
  aspect-ratio: 16/10;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  overflow: hidden;
}

.file-thumb img, .file-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-info {
  padding: 10px 12px;
}

.file-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.file-meta {
  font-size: 11px;
  color: var(--muted);
}

.file-actions {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
}

.btn-file {
  flex: 1;
  padding: 6px;
  font-size: 12px;
  border-radius: 5px;
}

/* Folder card */
.folder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.folder-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
}

.folder-card .folder-icon { font-size: 36px; }
.folder-card .file-name { font-size: 13px; }

/* Lightbox / preview */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox.hidden { display: none; }

.lightbox-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
}

.lightbox-title { font-size: 15px; font-weight: 500; }

.lightbox-actions { display: flex; gap: 10px; }

.lightbox-body {
  max-width: min(90vw, 1100px);
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-body img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius);
}

.lightbox-body video {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius);
  outline: none;
}

.lightbox-body iframe {
  width: min(90vw, 900px);
  height: 75vh;
  border: none;
  border-radius: var(--radius);
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.breadcrumb-item {
  cursor: pointer;
  color: var(--muted);
  transition: color 0.1s;
}

.breadcrumb-item:hover { color: var(--accent); }
.breadcrumb-item.current { color: var(--text); cursor: default; }
.breadcrumb-sep { color: var(--border); }

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px;
  color: var(--muted);
  font-size: 14px;
  gap: 12px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  color: var(--muted);
  font-size: 14px;
  padding: 60px;
  text-align: center;
}

/* Responsive */
@media (max-width: 700px) {
  .portal {
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto 1fr;
  }

  .sidebar {
    display: none;
    position: fixed;
    inset: 56px 0 0 0;
    z-index: 50;
    border-right: none;
  }

  .sidebar.open { display: block; }

  .main { padding: 20px 16px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
