:root {
  --bg: #f6f1e9; --card: #fffcf8; --surface: #fbf6ef;
  --border: #f0e5d7; --border-strong: #e3d4c1;
  --text: #32261c; --body: #4c3e31; --muted: #8d7c69;
  --accent: #c4622d; --accent-dark: #9c4a1e; --accent-soft: #fbeadb;
  --red: #b2443a; --red-soft: #fbedeb; --shadow: 0 8px 26px rgba(93,62,32,.08);
}
html[data-theme="light"] {
  color-scheme: light; --bg: #f5f7fb; --card: #fff; --surface: #f8fafc;
  --border: #d8e0ea; --border-strong: #b8c4d4; --text: #172033;
  --body: #3d4a5c; --muted: #5f6b7d; --accent: #1d4ed8;
  --accent-dark: #1e40af; --accent-soft: #e8eeff; --red: #b42318; --red-soft: #fdecec;
}
html[data-theme="dark"] {
  color-scheme: dark; --bg: #101827; --card: #182235; --surface: #0e1625;
  --border: #2b3a5c; --border-strong: #42506a; --text: #e8edf6;
  --body: #c9d2e1; --muted: #8fa0bc; --accent: #d67b45;
  --accent-dark: #f0a46a; --accent-soft: #304361; --red: #ee8278; --red-soft: #3b2025;
  --shadow: 0 10px 32px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; color: var(--body); background: var(--bg);
  font: 14px/1.55 "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; color: var(--text); font-size: 27px; }
h2 { margin-bottom: 2px; color: var(--text); font-size: 18px; }
small { display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 21px; }
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px; max-width: 1300px; margin: auto; padding: 22px; }
.sidebar { position: sticky; top: 22px; height: calc(100vh - 44px); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); font-size: 17px; }
.brand small { color: var(--muted); font-size: 9px; letter-spacing: 1.5px; }
.logo { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 13px; background: linear-gradient(135deg,#df8749,var(--accent)); color: white; font-weight: 800; }
nav { display: grid; gap: 5px; margin-top: 25px; }
nav a { padding: 10px 12px; border-radius: 11px; color: var(--body); text-decoration: none; font-weight: 650; }
nav a:hover { color: var(--accent-dark); background: var(--accent-soft); }
.side-bottom { margin-top: auto; }
.theme-field { margin: 12px 0; }
.field-label { display: block; margin-bottom: 6px; color: var(--text); font-size: 12.5px; font-weight: 700; }
.dropdown { position: relative; }
.dropdown-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 10px 13px; border: 1px solid var(--border-strong); border-radius: 11px;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer;
}
.dropdown-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropdown-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); }
.dropdown-caret { color: var(--muted); font-size: 13px; }
.dropdown-menu {
  position: absolute; bottom: calc(100% + 7px); left: 0; z-index: 10;
  width: 100%; padding: 5px; border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--card); box-shadow: var(--shadow);
}
.dropdown-item {
  display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--body); font: inherit; text-align: left; cursor: pointer;
}
.dropdown-item:hover, .dropdown-item:focus-visible { outline: 0; background: var(--surface); color: var(--text); }
.dropdown-item.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; }
.content { min-width: 0; }
.page-head, .section-head, .actions, .resource-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head { margin-bottom: 17px; }
.user-chip { padding: 7px 13px; border: 1px solid var(--border); border-radius: 99px; background: var(--card); color: var(--text); }
.anchor { scroll-margin-top: 18px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 16px; }
.stats article { display: grid; }
.stats strong { color: var(--text); font-size: 27px; margin: 6px 0 1px; }
.stats small { color: var(--muted); }
.content > section.card { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
label { display: block; color: var(--text); font-size: 12.5px; font-weight: 700; margin: 12px 0; }
input, textarea, select {
  width: 100%; margin-top: 6px; padding: 10px 13px; border: 1px solid var(--border-strong);
  border-radius: 11px; background: var(--surface); color: var(--text); font: inherit; outline: none;
}
textarea { resize: vertical; font: 13px/1.55 Consolas, monospace; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); }
.slug-row { display: flex; align-items: center; gap: 6px; color: var(--muted); font-family: Consolas, monospace; }
.slug-row input { margin-top: 6px; }
.btn { padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--card); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.wide { width: 100%; }
.resource-list { margin-top: 12px; }
.separated-list { margin-top: 20px; border-top: 1px solid var(--border); }
.resource-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 15px; padding: 15px 0; border-bottom: 1px solid var(--border); }
.resource-item:last-child { border-bottom: 0; }
.resource-name { color: var(--text); font-size: 15px; font-weight: 800; }
.resource-url { display: block; overflow-wrap: anywhere; color: var(--accent-dark); font: 12.5px Consolas, monospace; margin: 4px 0; }
.resource-meta { color: var(--muted); font-size: 12px; }
.replacement-target { display: block; max-width: 760px; overflow-wrap: anywhere; color: var(--muted); font: 12px/1.5 Consolas, monospace; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.chart { display: flex; align-items: flex-end; gap: 5px; height: 150px; padding: 18px 0 4px; border-bottom: 1px solid var(--border); }
.bar { flex: 1; min-width: 5px; min-height: 2px; background: linear-gradient(180deg,#df985b,var(--accent)); border-radius: 5px 5px 0 0; }
.usage-row { display: grid; grid-template-columns: minmax(120px,1fr) 3fr auto; align-items: center; gap: 12px; padding-top: 12px; }
.usage-track { height: 7px; border-radius: 9px; background: var(--surface); overflow: hidden; }
.usage-fill { height: 100%; background: var(--accent); border-radius: inherit; }
.login-wrap { min-height: 100vh; display: grid; place-items: start center; padding-top: 9vh; }
.login-card { width: min(400px, calc(100vw - 32px)); padding: 30px; }
.login-card .brand { justify-content: center; margin-bottom: 18px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; max-width: 90vw; padding: 10px 18px; border-radius: 12px; background: var(--text); color: var(--card); box-shadow: var(--shadow); }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
  .sidebar { position: static; height: auto; }
  nav { grid-template-columns: repeat(2,1fr); margin: 14px 0; }
  .stats, .form-grid { grid-template-columns: 1fr; }
  .resource-item { grid-template-columns: 1fr; }
  .resource-actions { justify-content: flex-start; }
}
