:root {
  --base: #0a0a0b;
  --elevated: #131316;
  --elevated-2: #17171b;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --primary: #fafafa;
  --muted: rgba(250, 250, 250, 0.46);
  --muted-2: rgba(250, 250, 250, 0.28);
  --accent: #ff3b30;
  --accent-soft: rgba(255, 59, 48, 0.12);
  --success: #34c759;
  --warn: #ffcc00;
  --info: #5ac8fa;
  --danger: #ff453a;
  --radius: 20px;
  --radius-sm: 12px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--base);
  color: var(--primary);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(255, 59, 48, 0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.09); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.boot-splash { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--base); }
.boot-splash img { animation: bootfade 1.1s ease infinite alternate; }
@keyframes bootfade { from { opacity: .4; transform: scale(.98); } to { opacity: 1; transform: scale(1); } }

.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

/* ------------------------------- sidebar ------------------------------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: #0b0b0d; padding: 18px 14px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand img { border-radius: 9px; }
.brand-name { font-weight: 600; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding-bottom: 10px; }
.nav-group-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted-2); padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 11px;
  color: rgba(250,250,250,.7); transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--primary); }
.nav-item.active { background: rgba(255,255,255,.07); color: var(--primary); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { width: 18px; text-align: center; color: var(--muted-2); font-size: 13px; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; gap: 10px; align-items: center; padding: 2px 4px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 600;
  background: linear-gradient(145deg, #26262c, #141417); border: 1px solid var(--border);
}
.user-name { font-weight: 500; font-size: 13px; }
.user-sub { font-size: 11px; color: var(--muted); }

/* ------------------------------- content ------------------------------- */
.content { min-width: 0; padding: 26px 30px 60px; max-width: 1480px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-body { display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-tight { display: flex; gap: 6px; align-items: center; }
.grow { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.split { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } .split { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .content { padding: 18px 16px 48px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* -------------------------------- panels ------------------------------- */
.panel { background: var(--elevated); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; }
.panel-head h3 { font-size: 15px; font-weight: 600; }
.panel-body { padding: 16px 18px 18px; }
.panel-body.tight { padding: 10px 0; }
.error-panel { padding: 18px; color: var(--danger); }

/* -------------------------------- stats -------------------------------- */
.stat { background: var(--elevated); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; }
.stat-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.stat-value { font-family: var(--mono); font-size: 25px; font-weight: 500; margin-top: 6px; letter-spacing: -0.02em; }
.stat-hint { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }
.stat.success .stat-value { color: var(--success); }
.stat.danger .stat-value { color: var(--danger); }
.stat.accent .stat-value { color: var(--accent); }
.stat.info .stat-value { color: var(--info); }

/* -------------------------------- table -------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
.table tbody tr:hover { background: rgba(255,255,255,.02); }
.table .align-right { text-align: right; }
.table .align-center { text-align: center; }
.table tr:last-child td { border-bottom: 0; }

/* -------------------------------- forms -------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field-label { font-size: 12px; color: var(--muted); }
.field-hint { font-size: 11px; color: var(--muted-2); }
.input {
  width: 100%; background: #0e0e11; border: 1px solid var(--border-strong); border-radius: 11px;
  padding: 9px 11px; outline: none; transition: border-color .15s, background .15s;
}
.input:focus { border-color: rgba(255,255,255,.28); background: #101014; }
.textarea { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: rgba(250,250,250,.82); }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* ------------------------------- buttons ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 11px; padding: 8px 14px; cursor: pointer; border: 1px solid var(--border-strong);
  background: rgba(255,255,255,.04); color: var(--primary); font-size: 13px; font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s; white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,.08); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #ff5147; }
.btn.danger { background: rgba(255,69,58,.14); border-color: rgba(255,69,58,.35); color: #ff8a80; }
.btn.danger:hover { background: rgba(255,69,58,.22); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px 6px; border-radius: 8px; }
.icon-btn:hover { color: var(--primary); background: rgba(255,255,255,.06); }

/* -------------------------------- misc --------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; border: 1px solid transparent; white-space: nowrap; }
.badge-success { background: rgba(52,199,89,.12); color: #6ee7a0; border-color: rgba(52,199,89,.22); }
.badge-danger { background: rgba(255,69,58,.12); color: #ff8a80; border-color: rgba(255,69,58,.24); }
.badge-warn { background: rgba(255,204,0,.1); color: #ffd75e; border-color: rgba(255,204,0,.22); }
.badge-info { background: rgba(90,200,250,.1); color: #8fd8ff; border-color: rgba(90,200,250,.22); }
.badge-accent { background: rgba(255,59,48,.12); color: #ff8f88; border-color: rgba(255,59,48,.28); }
.badge-neutral { background: rgba(255,255,255,.06); color: var(--muted); border-color: var(--border); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.04); border: 1px solid var(--border); font-size: 12px; cursor: pointer; }
.chip.active { background: rgba(255,59,48,.12); border-color: rgba(255,59,48,.34); color: #ff9d95; }
.tabs { display: flex; gap: 4px; background: rgba(255,255,255,.03); padding: 4px; border-radius: 12px; width: fit-content; }
.tab { background: transparent; border: 0; padding: 6px 12px; border-radius: 9px; cursor: pointer; color: var(--muted); font-size: 12.5px; }
.tab.active { background: rgba(255,255,255,.08); color: var(--primary); }

.progress { position: relative; height: 22px; background: rgba(255,255,255,.05); border-radius: 8px; overflow: hidden; min-width: 120px; }
.progress-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, rgba(255,59,48,.5), rgba(255,59,48,.8)); transition: width .3s; }
.progress-text { position: relative; font-size: 11px; font-family: var(--mono); display: grid; place-items: center; height: 100%; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 18px 4px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty-icon { font-size: 22px; color: var(--muted-2); }

/* ------------------------------- modals -------------------------------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 18px; z-index: 60; opacity: 0; transition: opacity .18s; }
.overlay.in { opacity: 1; }
.modal { width: min(560px, 100%); max-height: 88vh; display: flex; flex-direction: column; background: #141418; border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 30px 80px rgba(0,0,0,.5); transform: translateY(8px); transition: transform .18s; }
.overlay.in .modal { transform: none; }
.modal-wide { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-title { font-weight: 600; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); }

/* -------------------------------- toasts ------------------------------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { display: flex; align-items: center; gap: 9px; background: #1a1a1f; border: 1px solid var(--border-strong); border-radius: 12px; padding: 10px 14px; font-size: 13px; box-shadow: 0 16px 40px rgba(0,0,0,.4); opacity: 0; transform: translateY(8px); transition: all .2s; max-width: 380px; }
.toast.in { opacity: 1; transform: none; }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--info); flex: none; }
.toast-success .toast-dot { background: var(--success); }
.toast-danger .toast-dot { background: var(--danger); }
.toast-warn .toast-dot { background: var(--warn); }

/* -------------------------------- auth --------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(800px 400px at 50% -10%, rgba(255,59,48,.1), transparent 70%), var(--base); }
.auth-card { width: min(420px, 100%); background: var(--elevated); border: 1px solid var(--border); border-radius: 24px; padding: 26px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth-title { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; margin-bottom: 4px; }
.auth-sub { color: var(--muted); margin-bottom: 20px; font-size: 13px; }
.auth-foot { margin-top: 14px; text-align: center; color: var(--muted); font-size: 12.5px; }
.auth-foot a { color: var(--primary); }

/* ------------------------------ log console ---------------------------- */
.console { background: #0b0b0d; border: 1px solid var(--border); border-radius: 14px; padding: 12px; font-family: var(--mono); font-size: 12px; line-height: 1.6; max-height: 420px; overflow-y: auto; }
.console .ln { white-space: pre-wrap; word-break: break-word; }
.console .ok { color: #6ee7a0; }
.console .warn { color: #ffd75e; }
.console .error { color: #ff8a80; }
.console .info { color: rgba(250,250,250,.72); }
.console .dim { color: var(--muted-2); }

/* --------------------------- media / gallery --------------------------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden; background: #0e0e11; border: 1px solid var(--border); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .thumb-x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.65); border-radius: 8px; padding: 2px 6px; }
.dropzone { border: 1px dashed var(--border-strong); border-radius: 16px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.02); }

.list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; cursor: pointer; }
.list-item:hover { background: rgba(255,255,255,.04); }
.list-item.active { background: rgba(255,255,255,.07); }
.list-item .meta { font-size: 11.5px; color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.scroll-y { max-height: 420px; overflow-y: auto; }
.hint-box { background: rgba(90,200,250,.06); border: 1px solid rgba(90,200,250,.16); border-radius: 12px; padding: 10px 12px; font-size: 12px; color: rgba(250,250,250,.7); }
.warn-box { background: rgba(255,204,0,.06); border: 1px solid rgba(255,204,0,.18); border-radius: 12px; padding: 10px 12px; font-size: 12px; color: rgba(250,250,250,.72); }
