:root {
  --accent: #6366f1;
  --app-bg: #0a0a0f;
  --sidebar-bg: #0a0a14;
  --card-bg: #0f0f1a;
  --border: #1f1f2e;
  --text: #e4e4ef;
  --text-dim: #8b8ba3;
  --danger: #ef4444;
  --radius: 8px;
}

[data-theme="light"] {
  --app-bg: #f4f4f8;
  --sidebar-bg: #ffffff;
  --card-bg: #ffffff;
  --border: #e2e2ec;
  --text: #1a1a2e;
  --text-dim: #6b6b83;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  background: var(--app-bg);
  color: var(--text);
}

#root { display: flex; min-height: 100vh; }

/* --- Login --- */
.login-screen {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 320px;
}
.login-box h1 { font-size: 18px; margin: 0 0 20px; }

/* --- Layout --- */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 16px 0; }
.sidebar-bottom { flex-shrink: 0; border-top: 1px solid var(--border); padding: 8px 0; }

.app-brand { display: flex; align-items: center; gap: 10px; padding: 0 16px; margin: 0 0 16px; }
.app-logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.app-name { font-size: 15px; font-weight: 700; color: var(--text); }

.nav-item {
  display: block;
  padding: 8px 16px;
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.nav-item:hover { color: var(--text); background: rgba(127,127,127,0.08); }
.nav-item.active { color: var(--text); border-left-color: var(--accent); background: rgba(99,102,241,0.08); }

.theme-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; color: var(--text-dim); font-size: 13px;
}
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 999px; transition: 0.15s;
}
.switch-slider::before {
  content: ''; position: absolute; width: 14px; height: 14px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: 0.15s;
}
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(16px); }

.user-block { display: flex; align-items: center; gap: 8px; padding: 10px 16px; }
.user-block-info { flex: 1; min-width: 0; }
.user-block-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-block-username { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px;
}
.avatar-sm { width: 26px; height: 26px; font-size: 11px; }
.user-row { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 6px; padding: 4px 8px; font-size: 12px; cursor: pointer;
}
.icon-btn:hover { color: var(--text); }

.main { flex: 1; padding: 24px 32px; overflow-x: auto; }
.main h1 { font-size: 20px; margin: 0 0 4px; }
.subtitle { color: var(--text-dim); margin: 0 0 20px; }

/* --- Controls --- */
button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
button.secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }
button.danger { background: var(--danger); }
input, select, textarea {
  background: var(--app-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}
label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.field { margin-bottom: 12px; }

/* --- Table --- */
table { width: 100%; border-collapse: collapse; background: var(--card-bg); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--text-dim); font-weight: 500; }
tr:last-child td { border-bottom: none; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  color: #fff;
}

/* --- Modal --- */
dialog {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 420px;
}
dialog::backdrop { background: rgba(0,0,0,0.6); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.error { color: var(--danger); font-size: 12px; margin-top: 8px; }
.qa-section { margin-bottom: 24px; }
.qa-section h3 { font-size: 14px; margin: 0 0 8px; color: var(--text-dim); }
