:root {
  --sidebar-bg: #121a2c;
  --sidebar-border: #1f2940;
  --sidebar-text: #e6e9f2;
  --sidebar-muted: #aab2c8;
  --sidebar-active-bg: #1e2741;
  --primary: #5b4cf0;
  --primary-soft: #eeecff;
  --primary-text: #6c5cf7;
  --green: #3fae78;
  --bg: #f7f8fa;
  --card: #ffffff;
  --border: #e6e8ee;
  --text: #1c2230;
  --muted: #6b7280;
  --row-hover: #fafaff;
  --sidebar-w: 300px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd {
  font-family: inherit; font-size: 11px; border: 1px solid var(--border); border-radius: 6px;
  padding: 1px 6px; color: var(--muted); background: #fff;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; flex-shrink: 0; transition: width .2s ease;
  overflow: hidden;
}
.brand {
  height: 56px; display: flex; align-items: center; justify-content: center; gap: 4px;
  border-bottom: 1px solid var(--sidebar-border); flex-shrink: 0;
}
.logo { font-weight: 800; font-size: 28px; color: #8b3dff; letter-spacing: -1px; }
.logo-dots {
  width: 14px; height: 14px; margin-top: 4px;
  background:
    radial-gradient(circle, #8b3dff 2px, transparent 2.5px) 0 0 / 7px 7px;
  opacity: .85;
}
.nav { flex: 1; overflow-y: auto; padding: 24px 16px 32px; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: #2a3550; border-radius: 3px; }

.nav-group { margin-bottom: 10px; }
.nav-group-head {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 10px 8px;
  background: none; border: 0; color: var(--sidebar-text); text-align: left;
  font-size: 15.5px; font-weight: 600; border-radius: 8px;
}
.nav-group-head:hover { background: #18213a; }
.nav-group-head .label { flex: 1; line-height: 1.4; }
.nav-group-head .chev { width: 16px; height: 16px; transition: transform .2s; }
.nav-group.collapsed .chev { transform: rotate(180deg); }
.nav-group.collapsed .nav-items { display: none; }
.nav-items { padding: 6px 0 4px; }
.nav-item {
  display: flex; align-items: center; gap: 22px; padding: 12px 22px; margin: 2px 0;
  color: var(--sidebar-text); text-decoration: none; font-weight: 600; font-size: 15px;
  border-radius: 8px; line-height: 1.4;
}
.nav-item svg { color: var(--sidebar-muted); }
.nav-item:hover { background: #18213a; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--primary-text); }
.nav-item.active svg { color: var(--primary-text); }

.app.collapsed .sidebar { width: 76px; }
.app.collapsed .nav-group-head .label,
.app.collapsed .nav-group-head .chev,
.app.collapsed .nav-item span,
.app.collapsed .logo-dots { display: none; }
.app.collapsed .logo { font-size: 20px; }
.app.collapsed .nav { padding: 16px 10px; }
.app.collapsed .nav-item { padding: 12px; justify-content: center; }
.app.collapsed .nav-group-head { justify-content: center; }
.app.collapsed .collapse-btn svg { transform: rotate(180deg); }

/* ---------- topbar ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: stretch; gap: 16px; padding: 0 24px 0 0; flex-shrink: 0;
  position: relative;
}
.collapse-btn {
  position: absolute; left: -12px; top: 18px; width: 26px; height: 26px; border-radius: 6px;
  background: var(--primary); border: 0; color: #fff; display: grid; place-items: center; z-index: 5;
}
.collapse-btn svg { width: 16px; height: 16px; stroke-width: 2.4; }
.tabs { display: flex; gap: 6px; padding-left: 28px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tab {
  display: flex; align-items: center; gap: 7px; padding: 0 8px; white-space: nowrap;
  color: var(--muted); text-decoration: none; font-size: 15px; border-bottom: 2px solid transparent;
}
.tab svg { width: 18px; height: 18px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); font-weight: 700; border-bottom-color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.global-search {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 20px; background: #fff; color: var(--muted);
}
.global-search span { margin-right: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: #bdbdc4; color: #fff;
  display: grid; place-items: center; font-size: 17px;
}

/* ---------- content ---------- */
.content { flex: 1; overflow-y: auto; padding: 20px 16px 80px; }
.page-head { display: flex; align-items: center; gap: 16px; margin: 4px 0 20px; }
.page-head h1 { font-size: 26px; font-weight: 800; margin: 0; }
.icon-btn {
  background: none; border: 0; padding: 4px; color: var(--primary); display: grid; place-items: center;
  border-radius: 8px;
}
.icon-btn:hover { background: var(--primary-soft); }
.icon-btn.plus svg { width: 26px; height: 26px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; }
.filters { display: flex; align-items: center; gap: 10px; padding: 18px 16px; margin-bottom: 16px; flex-wrap: wrap; }
.chip {
  display: flex; align-items: center; gap: 7px; padding: 7px 14px; border: 1px solid #c9ccd6;
  border-radius: 22px; background: #fff; font-size: 15px; position: relative;
}
.chip svg { width: 18px; height: 18px; }
.chip:hover { border-color: var(--primary); }
.chip.on { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.chip.disabled { color: #b3b7c2; border-color: #e3e5ea; cursor: not-allowed; }
.chip input { border: 0; outline: 0; font: inherit; width: 160px; background: transparent; }
.chip .x { margin-left: 2px; opacity: .6; }
.filters .spacer { flex: 1; }
.gear { color: var(--text); }
.gear svg { width: 24px; height: 24px; }

.dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 200px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(20,25,40,.12);
  padding: 6px; z-index: 20; max-height: 280px; overflow-y: auto; color: var(--text); text-align: left;
}
.dropdown input[type="checkbox"], .dropdown input[type="radio"] { margin: 0; }
.dropdown label { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.dropdown label:hover { background: var(--bg); }
.dropdown input { accent-color: var(--primary); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-weight: 600; font-size: 15px; padding: 20px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 15px; }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }

.logo-cell { display: flex; align-items: center; gap: 6px; }
.status-bars { display: flex; flex-direction: column; gap: 3px; }
.status-bars i { display: block; width: 4px; height: 18px; border-radius: 2px; }
.rest-logo {
  width: 42px; height: 42px; border-radius: 8px; border: 1px solid var(--border); background: #f3f4f6;
  display: grid; place-items: center; color: #9aa0ab; font-weight: 800; font-size: 14px; overflow: hidden;
}
.rest-logo.has { color: #fff; border: 0; }
.name-cell { display: flex; align-items: center; gap: 10px; font-weight: 700; max-width: 220px; }
.name-cell a { color: inherit; text-decoration: none; }
.name-cell a:hover { color: var(--primary); }
.id-cell { display: flex; align-items: center; gap: 10px; max-width: 220px; }
.copy { background: none; border: 0; padding: 0; color: var(--primary); }
.copy svg { width: 22px; height: 22px; }
.pill {
  display: inline-block; padding: 7px 14px; border-radius: 20px; border: 1.5px solid; font-size: 15px; white-space: nowrap;
}
.pill.fixed { color: var(--green); border-color: #8fd3b0; }
.pill.pct { color: var(--primary); border-color: #8a7ff5; }
.actions { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.actions button { background: none; border: 0; padding: 2px; color: var(--primary); }
.actions button.more { color: var(--text); }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 13px; font-weight: 700; }
.badge.green { background: #e5f6ed; color: #24875a; }
.badge.grey { background: #eef0f3; color: #6b7280; }
.badge.amber { background: #fff4e0; color: #b26b00; }
.badge.purple { background: var(--primary-soft); color: var(--primary); }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 16px; padding: 14px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; }
.pager button { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; display: grid; place-items: center; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager select { font: inherit; border: 1px solid var(--border); border-radius: 6px; padding: 2px 4px; }

.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: #c3c7d1; }

/* row menu */
.menu {
  position: fixed; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(20,25,40,.14); padding: 6px; z-index: 50; min-width: 180px;
}
.menu button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 8px 10px; background: none; border: 0; border-radius: 6px; text-align: left; }
.menu button:hover { background: var(--bg); }
.menu button svg { width: 18px; height: 18px; color: var(--muted); }

/* fab */
.fab {
  position: fixed; right: 40px; bottom: 40px; width: 64px; height: 64px; border-radius: 50%;
  background: #fff; border: 0; box-shadow: 0 6px 20px rgba(20,25,40,.15); color: var(--primary);
  display: grid; place-items: center; z-index: 10;
}
.fab svg { width: 30px; height: 30px; stroke-width: 2; }

/* cmd-k */
.cmdk-backdrop { position: fixed; inset: 0; background: rgba(15,20,35,.35); display: flex; justify-content: center; padding-top: 12vh; z-index: 100; }
.cmdk-backdrop[hidden] { display: none; }
.cmdk { width: min(560px, 92vw); background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden; align-self: flex-start; }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.cmdk-input input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 16px; color: var(--text); }
.cmdk-list { list-style: none; margin: 0; padding: 6px; max-height: 360px; overflow-y: auto; }
.cmdk-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.cmdk-list li .kind { margin-left: auto; font-size: 12px; color: var(--muted); }
.cmdk-list li.sel, .cmdk-list li:hover { background: var(--primary-soft); color: var(--primary); }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #1c2230; color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 200;
}
.toast[hidden] { display: none; }

@media (max-width: 900px) {
  :root { --sidebar-w: 76px; }
  .sidebar .nav-group-head .label, .sidebar .nav-group-head .chev, .sidebar .nav-item span, .logo-dots { display: none; }
  .nav { padding: 16px 10px; }
  .nav-item { padding: 12px; justify-content: center; }
  .global-search span, .global-search kbd { display: none; }
}
