:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222535;
  --border: #2e3347;
  --accent: #4f6ef7;
  --accent-hover: #6b85ff;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --text: #e8eaf0;
  --text2: #8b90a7;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

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

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  padding: 8px 12px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .brand img {
  height: 22px;
  width: auto;
}

.sidebar .brand .product {
  color: var(--accent);
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
}

.sidebar nav a:hover {
  background: var(--surface2);
}

.sidebar nav a.active {
  background: var(--surface2);
  color: var(--accent);
}

.sidebar .badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  background: var(--surface);
}

.topbar .title {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
}

.topbar .user {
  font-size: 0.85rem;
  color: var(--text2);
  display: flex;
  gap: 12px;
  align-items: center;
}

.topbar .user .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
}

.content {
  padding: 24px;
  flex: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card h2,
.card h3 {
  margin-top: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
}

.btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

.btn-success {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.8rem;
  color: var(--text2);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
textarea,
select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  font-family: ui-monospace, "Cascadia Mono", "JetBrains Mono", monospace;
  min-height: 180px;
}

.form-row {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.form-row.two {
  grid-template-columns: 1fr 1fr;
}

.form-row.three {
  grid-template-columns: 1fr 1fr 1fr;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text2);
  background: var(--surface2);
}

tr:hover td {
  background: rgba(79, 110, 247, 0.06);
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface2);
}

.pill.ok {
  background: rgba(34, 197, 94, 0.18);
  color: var(--green);
}

.pill.warn {
  background: rgba(245, 158, 11, 0.18);
  color: var(--yellow);
}

.pill.crit {
  background: rgba(239, 68, 68, 0.18);
  color: var(--red);
}

.pill.muted {
  color: var(--text2);
}

.banner-impersonation {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid var(--yellow);
  color: var(--yellow);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 880px;
  width: 100%;
}

@media (max-width: 720px) {
  .login-grid {
    grid-template-columns: 1fr;
  }
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
}

.chat-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  max-width: 880px;
  margin: 0 auto;
  padding: 24px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  max-width: 80%;
}

.msg-bubble.user {
  align-self: flex-end;
  background: rgba(79, 110, 247, 0.18);
  border-color: var(--accent);
}

.msg-bubble.tool {
  border-color: var(--yellow);
  background: rgba(245, 158, 11, 0.12);
}

.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.chat-input textarea {
  flex: 1;
  min-height: 40px;
  max-height: 200px;
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow);
}

.flex {
  display: flex;
}

.flex-1 {
  flex: 1;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 12px;
}

.mt-4 {
  margin-top: 16px;
}

.muted {
  color: var(--text2);
}

.text-right {
  text-align: right;
}

.success {
  color: var(--green);
}

.error {
  color: var(--red);
}

.warning {
  color: var(--yellow);
}
