:root{
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-2:#1d4ed8;
  --danger:#dc2626;
  --chip:#eef2ff;
  --shadow: 0 6px 24px rgba(17,24,39,.08);
}

html[data-theme="dark"]{
  --bg: #0b1220;
  --panel:#0f172a;
  --text:#e5e7eb;
  --muted:#94a3b8;
  --border:#1f2a44;
  --primary:#60a5fa;
  --primary-2:#3b82f6;
  --danger:#fb7185;
  --chip:#111c33;
  --shadow: 0 10px 32px rgba(0,0,0,.35);
}

*{ box-sizing:border-box; }
body{ margin:0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial; background:var(--bg); color:var(--text); }

.app{ display:flex; min-height:100vh; }

.sidebar{
  width:280px;
  background:var(--panel);
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
}

.brand{ display:flex; gap:12px; padding:18px 16px; border-bottom:1px solid var(--border); }
.logo{ width:40px; height:40px; border-radius:12px; display:flex; align-items:center; justify-content:center; background:var(--chip); font-weight:800; }
.brand-title{ font-weight:800; }
.brand-sub{ font-size:12px; color:var(--muted); margin-top:2px; }

.nav{ padding:10px 10px 14px 10px; overflow:auto; flex:1; }
.nav-item{
  width:100%;
  text-align:left;
  border:1px solid transparent;
  background:transparent;
  color:var(--text);
  padding:10px 12px;
  border-radius:10px;
  cursor:pointer;
}
.nav-item:hover{ background:rgba(99,102,241,.08); }
.nav-item.active{ background:rgba(37,99,235,.12); border-color:rgba(37,99,235,.22); }
.nav-divider{ height:1px; background:var(--border); margin:10px 0; }
.nav-section-title{ font-size:12px; color:var(--muted); padding:6px 8px; }
.tree{ padding:0 4px 10px; }
.tree .node{ display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 10px; border-radius:10px; cursor:pointer; }
.tree .node:hover{ background:rgba(99,102,241,.08); }
.tree .node.active{ background:rgba(37,99,235,.12); }
.tree .node small{ color:var(--muted); }

.sidebar-footer{ display:flex; align-items:center; gap:10px; padding:12px 12px; border-top:1px solid var(--border); }
.badge{ font-size:12px; padding:6px 10px; border-radius:999px; background:var(--chip); color:var(--text); }

.main{ flex:1; display:flex; flex-direction:column; }
.topbar{ display:flex; align-items:flex-start; justify-content:space-between; padding:18px 20px; }
.topbar h1{ margin:0; font-size:20px; }
.hint{ font-size:12px; color:var(--muted); margin-top:6px; }

.panel{ padding:0 20px 20px; }
.hidden{ display:none !important; }

.card{ background:var(--panel); border:1px solid var(--border); border-radius:16px; box-shadow:var(--shadow); padding:16px; }
.card-h{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px; }
.card h2{ margin:0 0 12px 0; }
.card h3{ margin:0; font-size:14px; }

.grid2{ display:grid; grid-template-columns: 1fr 1fr; gap:14px; }
@media (max-width: 1100px){ .sidebar{width:250px;} }
@media (max-width: 960px){ .grid2{grid-template-columns:1fr;} .sidebar{display:none;} }

.row{ display:flex; align-items:center; gap:10px; }
.form-row{ display:flex; gap:10px; flex-wrap:wrap; }

.input, input{ 
  background:transparent;
  border:1px solid var(--border);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  outline:none;
  min-width: 220px;
}
input::placeholder{ color: color-mix(in srgb, var(--muted) 85%, transparent); }

.btn{
  border:1px solid var(--border);
  background:transparent;
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
}
.btn:hover{ border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }
.btn.primary{ background:var(--primary); border-color:var(--primary); color:white; }
.btn.primary:hover{ background:var(--primary-2); border-color:var(--primary-2); }
.btn.ghost{ background:transparent; }

.msg{ margin-top:10px; font-size:12px; color: #ef4444; }

.list{ max-height: 62vh; overflow:auto; border-top:1px solid var(--border); padding-top:10px; }
.list .item{ display:flex; justify-content:space-between; gap:10px; padding:10px 10px; border-radius:12px; border:1px solid var(--border); margin-bottom:10px; }
.list .item:hover{ border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }
.item .meta{ display:flex; flex-direction:column; gap:4px; }
.item .title{ font-weight:700; }
.item .sub{ font-size:12px; color:var(--muted); }
.item .ops{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

.chip{ font-size:12px; background:var(--chip); padding:6px 10px; border-radius:999px; }

.table{ overflow:auto; }
.table table{ width:100%; border-collapse:collapse; }
.table th, .table td{ border-bottom:1px solid var(--border); padding:10px 8px; text-align:left; font-size:13px; }
.table th{ color:var(--muted); font-weight:700; }

.pad{ padding:10px 2px; }

.toast{ background:var(--panel); border:1px solid var(--border); padding:10px 12px; border-radius:12px; box-shadow:var(--shadow); font-size:13px; }
.toast.ok{ border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }
.toast.err{ border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }

.modal{ position:fixed; inset:0; background:rgba(0,0,0,.45); display:flex; align-items:center; justify-content:center; padding:20px; }
.modal-card{ width:min(720px, 96vw); background:var(--panel); border:1px solid var(--border); border-radius:16px; box-shadow:var(--shadow); }
.modal-h{ display:flex; align-items:center; justify-content:space-between; padding:12px 14px; border-bottom:1px solid var(--border); }
.modal-b{ padding:14px; }
.modal-f{ display:flex; justify-content:flex-end; gap:10px; padding:12px 14px; border-top:1px solid var(--border); }

.field{ display:flex; flex-direction:column; gap:6px; margin-bottom:12px; }
.field label{ font-size:12px; color:var(--muted); }
.field textarea{ min-height:90px; resize:vertical; }

a{ color:inherit; }
.nav-link{
  display:block;
  padding:10px 12px;
  border-radius:10px;
  text-decoration:none;
  border:1px solid transparent;
  color:var(--text);
}
.nav-link:hover{ background:rgba(99,102,241,.08); border-color:rgba(37,99,235,.22); }
