*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0a0a;
  --surface:   #111111;
  --surface2:  #191919;
  --border:    #222222;
  --border2:   #2e2e2e;
  --text:      #e8e8e8;
  --text2:     #888888;
  --text3:     #444444;
  --accent:    #e2f542;
  --accent-dk: #c8db30;
  --red:       #e05252;
  --green:     #4caf82;
  --blue:      #5b8dee;
  --amber:     #e09e3e;
  --sidebar-w: 224px;
  --radius:    8px;
  --radius-lg: 12px;
  --font: 'Inter', system-ui, sans-serif;
}

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─────────────────────────────────────────
   SIDEBAR
───────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px 20px;
  position: fixed;
  top: 0; left: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.brand-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}
.brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.team-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  background: var(--surface2);
  border-radius: var(--radius);
  margin-bottom: 20px;
  border: 1px solid var(--border);
}
.team-avatars { display: flex; }
.av {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  font-weight: 600;
  border: 2px solid var(--surface);
  color: #111;
}
.av-a { background: var(--accent); margin-right: -6px; z-index: 1; }
.av-b { background: #c2c2c2; }
.team-info { display: flex; flex-direction: column; gap: 1px; }
.team-name { font-size: 12px; font-weight: 500; color: var(--text); }
.team-status { font-size: 10px; color: var(--text3); }

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

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  color: var(--text2);
  border: 1px solid transparent;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
  gap: 8px;
}
.nav-item-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: var(--accent);
  color: #111;
  font-weight: 500;
}
.nav-item.active .nav-count { background: rgba(0,0,0,0.12); color: #111; }
.nav-count {
  font-size: 10px;
  background: var(--surface2);
  color: var(--text3);
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 500;
  flex-shrink: 0;
}

.nav-new-cat {
  margin-top: 12px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  color: var(--text3);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
.nav-new-cat:hover { border-color: var(--accent); color: var(--accent); }
.plus-icon { font-size: 14px; line-height: 1; font-weight: 300; }

/* ─────────────────────────────────────────
   CONTENT
───────────────────────────────────────── */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  min-height: 100vh;
  max-width: calc(100vw - var(--sidebar-w));
}

/* ─────────────────────────────────────────
   TOPBAR
───────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.topbar h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}
.page-meta {
  display: block;
  font-size: 11px;
  color: var(--text3);
  margin-top: 3px;
  font-weight: 400;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.sync-pill {
  font-size: 11px;
  color: var(--green);
  background: rgba(76,175,130,0.08);
  border: 1px solid rgba(76,175,130,0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.sync-pill.syncing { color: var(--amber); background: rgba(224,158,62,0.08); border-color: rgba(224,158,62,0.2); }
.sync-pill.offline { color: var(--red);   background: rgba(224,82,82,0.08);  border-color: rgba(224,82,82,0.2); }

/* ─────────────────────────────────────────
   KPI
───────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  transition: border-color 0.12s;
}
.kpi-card:hover { border-color: var(--border2); }
.kpi-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
}
.kpi-sub {
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
}

/* ─────────────────────────────────────────
   CARD + TABLE
───────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 13px; font-weight: 500; color: var(--text2); }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  padding: 11px 16px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th:first-child { border-radius: 0; }

td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }

.td-actions { text-align: right; white-space: nowrap; width: 1%; }

/* ─────────────────────────────────────────
   BADGES
───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.b-green  { background: rgba(76,175,130,0.12); color: #4caf82; }
.b-blue   { background: rgba(91,141,238,0.12); color: #5b8dee; }
.b-amber  { background: rgba(224,158,62,0.12); color: #e09e3e; }
.b-red    { background: rgba(224,82,82,0.12);  color: #e05252; }
.b-gray   { background: rgba(255,255,255,0.05); color: #666; }
.b-teal   { background: rgba(45,212,191,0.1);  color: #2dd4bf; }
.b-accent { background: rgba(226,245,66,0.1);  color: var(--accent); }
.b-purple { background: rgba(167,139,250,0.1); color: #a78bfa; }

/* ─────────────────────────────────────────
   BUTTONS
───────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #111;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-dk); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  padding: 8px 16px;
  border-radius: var(--radius);
  color: var(--text2);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s;
}
.btn-ghost:hover { border-color: var(--border2); color: var(--text); background: var(--surface2); }

.btn-danger {
  background: transparent;
  border: 1px solid rgba(224,82,82,0.3);
  padding: 8px 16px;
  border-radius: var(--radius);
  color: var(--red);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s;
}
.btn-danger:hover { background: rgba(224,82,82,0.08); }

.row-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  color: var(--text3);
  transition: all 0.12s;
}
.row-btn:hover { border-color: var(--border2); color: var(--text2); }
.row-btn.del:hover { border-color: rgba(224,82,82,0.4); color: var(--red); }
.row-btn + .row-btn { margin-left: 4px; }

/* tab delete button in topbar */
.btn-del-tab {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text3);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.12s;
}
.btn-del-tab:hover { border-color: rgba(224,82,82,0.4); color: var(--red); }

/* ─────────────────────────────────────────
   EMPTY STATE
───────────────────────────────────────── */
.empty {
  padding: 60px 20px;
  text-align: center;
}
.empty-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
}
.empty-sub { font-size: 13px; color: var(--text3); }

/* ─────────────────────────────────────────
   MODAL
───────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-sm { width: 380px; }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 0;
}
.modal-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }

.close-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 10px;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.close-btn:hover { color: var(--text); border-color: var(--border2); }

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
}
.field label small {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: 10px;
  color: var(--text3);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--border2); }
.field select { cursor: pointer; }
.field select option { background: var(--surface2); }
.field textarea { resize: vertical; min-height: 70px; line-height: 1.5; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 20px;
}

.confirm-text { font-size: 13px; color: var(--text2); line-height: 1.6; }

/* ─────────────────────────────────────────
   TOAST
───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 11px 18px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.18s;
  z-index: 999;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok   { border-color: rgba(76,175,130,0.35); color: var(--green); }
.toast.err  { border-color: rgba(224,82,82,0.35);  color: var(--red); }

/* ─────────────────────────────────────────
   SCROLLBAR
───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ─────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .content { padding: 16px; max-width: 100vw; }
  .topbar { flex-direction: column; gap: 12px; align-items: flex-start; }
}
