/* ── Reset & Variables ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d0d;
  --surface:   #1a1a1a;
  --surface2:  #222222;
  --border:    #2a2a2a;
  --accent:    #2AABEE;
  --accent-dim:#2AABEE22;
  --text:      #e8e8e8;
  --text-muted:#888888;
  --danger:    #f87171;
  --success:   #4ade80;
  --warning:   #f59e0b;
  --radius:    10px;
  --sidebar-w: 56px;
}

[data-theme="light"] {
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --surface2:  #f8f8f8;
  --border:    #e0e0e0;
  --text:      #1a1a1a;
  --text-muted:#888888;
  --accent-dim:#2AABEE18;
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
body { background: var(--bg); color: var(--text); display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 4px; z-index: 100;
}

.sidebar-logo {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--accent); display: flex; align-items: center;
  justify-content: center; font-size: 18px; margin-bottom: 8px;
  flex-shrink: 0;
}

.sidebar-divider { width: 32px; height: 1px; background: var(--border); margin: 6px 0; }
.sidebar-spacer  { flex: 1; }

.nav-item {
  position: relative; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 18px; cursor: pointer;
  text-decoration: none; color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover, .nav-item.active {
  background: var(--accent-dim); color: var(--accent);
}

.nav-item .nav-tooltip {
  position: absolute; left: calc(var(--sidebar-w) - 4px);
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 7px; font-size: 12px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transform: translateX(-4px);
  transition: opacity 0.15s, transform 0.15s;
  z-index: 200;
}

.nav-item:hover .nav-tooltip { opacity: 1; transform: translateX(0); }

/* ── Main content ──────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1; min-height: 100vh;
  padding: 24px 28px;
  max-width: 1200px;
}

/* ── Page header ───────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-title  { font-size: 22px; font-weight: 700; }
.page-sub    { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }

.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Gallery ───────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; align-items: center;
}

.filter-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 14px; font-size: 13px;
  color: var(--text-muted); cursor: pointer; transition: all 0.15s;
}
.filter-btn.active, .filter-btn:hover {
  background: var(--accent-dim); border-color: var(--accent); color: var(--accent);
}

.filter-select {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px; font-size: 13px;
  color: var(--text); cursor: pointer;
}

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

.media-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: transform 0.15s, border-color 0.15s;
}
.media-card:hover { transform: translateY(-2px); border-color: var(--accent); }

.media-thumb {
  width: 100%; aspect-ratio: 2/3; object-fit: cover;
  background: var(--surface2);
}

.media-info { padding: 10px 12px; }
.media-article { font-size: 11px; color: var(--text-muted); font-family: monospace; }
.media-type { font-size: 10px; margin-top: 2px; color: var(--text-muted); }

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

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 7px; padding: 6px 12px; font-size: 12px;
  font-weight: 600; cursor: pointer; border: none;
  text-decoration: none; transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: #2a1a1a; color: var(--danger); border: 1px solid #3a2222; }
.btn-success { background: #1a2a1a; color: var(--success); border: 1px solid #223a22; }
.btn-sm { padding: 4px 8px; font-size: 11px; }

/* ── Balance page ──────────────────────────────────────────────────────────── */
.balance-display {
  font-size: 48px; font-weight: 800; color: var(--accent);
  margin: 24px 0 8px;
}
.balance-label { font-size: 14px; color: var(--text-muted); margin-bottom: 32px; }

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--surface2); padding: 10px 14px;
  text-align: left; color: var(--text-muted); font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: var(--surface2); }
td.mono { font-family: monospace; font-size: 12px; color: var(--accent); }
td.muted { color: var(--text-muted); }
td.truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Status badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-green  { background: #1a2a1a; color: var(--success); }
.badge-yellow { background: #2a2a1a; color: var(--warning); }
.badge-red    { background: #2a1a1a; color: var(--danger); }
.badge-blue   { background: var(--accent-dim); color: var(--accent); }
.badge-gray   { background: var(--surface2); color: var(--text-muted); }

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; width: 100%; display: flex; align-items: center;
  justify-content: center; background: var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 48px;
  text-align: center; width: 100%; max-width: 360px;
}
.login-logo { font-size: 40px; margin-bottom: 16px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 32px; }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted); font-size: 14px;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .main { padding: 16px 14px; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}
