:root {
  --bg: #0a0908;
  --bg-raised: #16130f;
  --bg-sunken: #0e0c0a;
  --bg-elevated: #1c1812;
  --ink: #f4ede0;
  --ink-soft: #c9bda6;
  --muted: #93856d;
  --accent: #113007;
  --accent-bright: #18450a;
  --accent-glow: #3f9420;
  --accent-soft: rgba(24, 69, 10, 0.20);
  --gold: #c9974c;
  --gold-soft: rgba(201, 151, 76, 0.16);
  --line: rgba(244, 237, 224, 0.10);
  --line-strong: rgba(244, 237, 224, 0.18);
  --good: #4fd4b8;
  --bad: #e2542f;
  --bad-soft: rgba(226, 84, 47, 0.14);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
::selection { background: var(--accent-glow); color: #06120a; }

h1, h2, h3 { margin: 0; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* ═══════════════════════ App shell (Dashboard) ═══════════════════════ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-raised);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.sidebar-brand img { height: 28px; width: auto; display: block; }
.sidebar-brand .txt { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-brand .txt b { font-size: 0.92rem; font-weight: 800; }
.sidebar-brand .txt span { font-size: 0.68rem; color: var(--gold); letter-spacing: 0.08em; text-transform: uppercase; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.87rem;
  font-weight: 600;
  position: relative;
  transition: color 0.18s ease, background 0.18s ease;
}
.sidebar-nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.sidebar-nav a:hover { color: var(--ink); background: var(--bg-elevated); }
.sidebar-nav a.active {
  color: var(--ink);
  background: var(--accent-soft);
}
.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: -14px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-glow);
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-footer .user {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  padding: 0 10px;
}
.sidebar-footer .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent-glow), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 800; color: #eafce0;
  flex-shrink: 0;
}
.sidebar-footer a.view-site,
.sidebar-footer a.logout {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
  transition: color 0.18s ease, background 0.18s ease;
}
.sidebar-footer a.view-site:hover { color: var(--ink); background: var(--bg-elevated); }
.sidebar-footer a.logout:hover { color: var(--bad); background: var(--bad-soft); }
.sidebar-footer svg { width: 15px; height: 15px; }

.main {
  flex: 1;
  min-width: 0;
  padding: 34px 40px 80px;
}
.main-inner { max-width: 980px; margin: 0 auto; animation: fade 0.35s var(--ease); }

.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; }
.page-head p { color: var(--muted); font-size: 0.9rem; margin-top: 5px; }

/* ═══════════════════════ Login ═══════════════════════ */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.login-bg-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(6px) brightness(0.45) saturate(0.9);
  transform: scale(1.08);
}
.login-bg-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 55% at 50% 40%, rgba(10,9,8,.45) 0%, rgba(10,9,8,.88) 100%);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 30px;
  animation: rise 0.55s var(--ease) backwards;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 18px; }
.login-logo img { height: 40px; width: auto; }
.login-card h1 { font-size: 1.25rem; text-align: center; margin-bottom: 4px; }
.login-card p.lead { color: var(--muted); font-size: 0.85rem; text-align: center; margin: 0 0 26px; }

/* ═══════════════════════ Forms ═══════════════════════ */
label {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 6px;
  margin-top: 16px;
  letter-spacing: 0.01em;
}
label:first-of-type { margin-top: 0; }

input[type="text"], input[type="password"], input[type="number"], input[type="url"], input[type="datetime-local"], input[type="file"], input[type="search"], textarea, select {
  width: 100%;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent-glow);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg-elevated);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
input[type="file"] { padding: 9px 10px; font-size: 0.84rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.87rem;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: linear-gradient(155deg, var(--accent-glow), var(--accent-bright));
  color: #eafce0;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 26px var(--accent-soft); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent-glow); color: var(--accent-glow); }
.btn-danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 0.78rem; }
.btn:focus-visible { outline: 2px solid var(--accent-glow); outline-offset: 2px; }

.error-box, .success-box {
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  font-size: 0.86rem;
  margin-bottom: 20px;
  animation: rise 0.35s var(--ease);
  display: flex;
  align-items: center;
  gap: 10px;
}
.error-box { background: var(--bad-soft); border: 1px solid var(--bad); }
.success-box { background: rgba(79, 212, 184, 0.12); border: 1px solid var(--good); }
.error-box svg, .success-box svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ═══════════════════════ Cards ═══════════════════════ */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 26px;
  animation: rise 0.45s var(--ease) backwards;
  transition: border-color 0.25s ease;
}
.card:hover { border-color: var(--line-strong); }
.main-inner .card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.card-title { font-size: 1.02rem; font-weight: 800; }
.card-desc { color: var(--muted); font-size: 0.84rem; margin-top: 4px; }

/* ═══════════════════════ Overview stat cards ═══════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  animation: pop 0.4s var(--ease) backwards;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.stat-card .top { display: flex; align-items: center; justify-content: space-between; }
.stat-card .icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-glow);
}
.stat-card .icon svg { width: 17px; height: 17px; }
.stat-card .num { font-size: 1.7rem; font-weight: 800; margin-top: 12px; font-variant-numeric: tabular-nums; }
.stat-card .label { font-size: 0.76rem; color: var(--muted); margin-top: 2px; }

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.quick-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}
.quick-link:hover { border-color: var(--accent-glow); background: var(--bg-elevated); transform: translateX(2px); }
.quick-link svg { width: 17px; height: 17px; color: var(--accent-glow); flex-shrink: 0; }

/* ═══════════════════════ Tabs (legacy support, kept minimal) ═══════════════════════ */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }
.hint { font-size: 0.76rem; color: var(--muted); margin-top: 6px; }

.article-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  background: var(--bg-sunken);
  transition: border-color 0.2s ease;
}
.article-editor:hover { border-color: var(--line-strong); }
.article-editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.article-editor-head input[type="text"] { max-width: 90px; }

.thumb-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.thumb-card {
  width: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-sunken);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.thumb-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.thumb-card img { width: 100%; height: 130px; object-fit: cover; display: block; }
.thumb-card .thumb-body { padding: 12px; }
.thumb-card input[type="text"] { font-size: 0.8rem; margin-bottom: 8px; }

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}
.user-row:last-child { border-bottom: none; }
.user-row .name { display: flex; align-items: center; gap: 10px; }

.progress-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--bg-sunken);
  transition: border-color 0.2s ease;
}
.progress-item:hover { border-color: var(--line-strong); }
.progress-item-head { display: flex; gap: 10px; margin-bottom: 8px; }
.progress-item-head select { max-width: 140px; }

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.visits { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.visits th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
table.visits td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  white-space: nowrap;
}
table.visits tbody tr { transition: background 0.15s ease; }
table.visits tbody tr:hover { background: var(--bg-sunken); }
table.visits td.mono { font-variant-numeric: tabular-nums; color: var(--ink); }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; padding: 12px; }
  .sidebar-brand { border-bottom: none; padding: 0 12px 0 0; margin-bottom: 0; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-nav a.active::before { display: none; }
  .sidebar-footer { flex-direction: row; border-top: none; margin: 0 0 0 auto; padding: 0; }
  .main { padding: 24px 18px 60px; }
}
