/* Private Vault — dark archival vault */
:root {
  --bg: #0b0e14;
  --bg-elev: #121722;
  --bg-elev-2: #1a2130;
  --line: #2a3244;
  --line-soft: #1f2635;
  --ink: #e8e6e1;
  --ink-dim: #8b929e;
  --ink-faint: #5c6474;
  --accent: #c45c26;
  --accent-soft: rgba(196, 92, 38, 0.16);
  --accent-hover: #d96d32;
  --ok: #3d9b6e;
  --warn: #c9a227;
  --danger: #c23b3b;
  --danger-soft: rgba(194, 59, 59, 0.14);
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Cascadia Code", "SF Mono", Consolas, monospace;
  --sidebar: 220px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img, video { max-width: 100%; display: block; }

.app { min-height: 100%; }
.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--ink-dim);
}

/* ---------- Login / Bootstrap ---------- */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(196, 92, 38, 0.12), transparent 60%),
    var(--bg);
}
.gate-card {
  width: min(400px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.gate-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1.5px solid var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  color: var(--accent);
  font-size: 18px;
}
.gate h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.gate-sub {
  margin: 0 0 24px;
  color: var(--ink-dim);
  font-size: 13px;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-dim);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
}
.field textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  border: 1px solid transparent;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #0b0e14;
  width: 100%;
  margin-top: 8px;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-dim);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--ink-dim); color: var(--ink); }
.btn-danger {
  background: var(--danger-soft);
  color: #e07070;
  border-color: transparent;
}
.btn-danger:hover:not(:disabled) { background: rgba(194, 59, 59, 0.28); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

.form-error {
  margin-top: 12px;
  color: #e07070;
  font-size: 13px;
  min-height: 1.2em;
}
.form-hint {
  margin-top: 14px;
  color: var(--ink-faint);
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- Shell ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--line-soft);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 12px;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 13px;
  flex-shrink: 0;
}
.brand-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.brand-text small {
  display: block;
  font-weight: 400;
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.12em;
  margin-top: 1px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-dim);
  font-size: 13px;
  width: 100%;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg-elev-2); color: var(--ink); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item .ico { width: 18px; text-align: center; opacity: 0.9; }
.nav-spacer { flex: 1; }
.user-chip {
  padding: 12px;
  border-top: 1px solid var(--line-soft);
  margin-top: 8px;
}
.user-chip .name {
  font-size: 13px;
  font-weight: 500;
}
.user-chip .role {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.main {
  padding: 28px 32px 48px;
  max-width: 1200px;
  width: 100%;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}
.page-head .sub {
  margin: 4px 0 0;
  color: var(--ink-dim);
  font-size: 13px;
}
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Stats cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-card .label {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.stat-card .value {
  font-size: 26px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
  color: var(--ink);
}
.stat-card .value.accent { color: var(--accent); }

/* ---------- Media grid ---------- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.media-card {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}
.media-card:hover { border-color: var(--line); }
.media-thumb {
  aspect-ratio: 4/3;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.media-thumb img, .media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-thumb .placeholder {
  color: var(--ink-faint);
  font-size: 28px;
}
.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(11, 14, 20, 0.8);
  color: var(--ink-dim);
  letter-spacing: 0.04em;
  backdrop-filter: blur(4px);
}
.badge.public { color: var(--ok); }
.badge.restricted { color: var(--warn); }
.media-body { padding: 12px 14px; }
.media-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.media-actions {
  display: flex;
  gap: 6px;
  padding: 0 14px 12px;
  flex-wrap: wrap;
}

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
th {
  color: var(--ink-faint);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--bg-elev-2);
  position: sticky;
  top: 0;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }
.tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg-elev-2);
  color: var(--ink-dim);
}
.tag.ok { color: var(--ok); background: rgba(61, 155, 110, 0.12); }
.tag.ban { color: #e07070; background: var(--danger-soft); }
.tag.admin { color: var(--accent); background: var(--accent-soft); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
}
.modal {
  width: min(520px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow: auto;
}
.modal h3 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.check-list {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  cursor: pointer;
}
.check-row:last-child { border-bottom: none; }
.check-row:hover { background: var(--bg-elev-2); }
.check-row input { accent-color: var(--accent); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.92);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox img, .lightbox video {
  max-width: min(1100px, 96vw);
  max-height: 80vh;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.lightbox-bar {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-dim);
  font-size: 13px;
  flex-wrap: wrap;
  justify-content: center;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  color: var(--ink-dim);
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
}
.lightbox-close:hover { background: var(--bg-elev-2); color: var(--ink); }

/* ---------- Empty / toast ---------- */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-dim);
}
.empty .icon { font-size: 32px; opacity: 0.5; margin-bottom: 12px; }
.empty p { margin: 0; font-size: 14px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 13px;
  z-index: 300;
  box-shadow: var(--shadow);
  max-width: 90vw;
}
.toast.err { border-color: var(--danger); color: #e07070; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar input[type="search"] {
  flex: 1;
  min-width: 160px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
}
.toolbar input[type="search"]:focus { border-color: var(--accent); }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 240px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line-soft);
    background: var(--bg-elev);
    position: sticky;
    top: 0;
    z-index: 40;
  }
  .main { padding: 20px 16px 40px; }
}
@media (min-width: 761px) {
  .mobile-bar { display: none; }
  .menu-btn { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
