:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #63707a;
  --line: #dfe5ea;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
}

* { box-sizing: border-box; }

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

a { color: var(--brand); }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: #111827;
  color: #f9fafb;
  padding: 24px 18px;
}

.brand {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 22px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  width: 100%;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #cbd5e1;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
}

.nav button.active,
.nav button:hover {
  background: #1f2937;
  color: #ffffff;
}

.main {
  padding: 26px;
  max-width: 1280px;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

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

.grid {
  display: grid;
  gap: 16px;
}

.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.panel,
.metric,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel { padding: 18px; }
.metric { padding: 16px; }

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

form {
  display: grid;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea { min-height: 116px; resize: vertical; }

button,
.button {
  border: 0;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  padding: 10px 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

button.secondary {
  background: #e5e7eb;
  color: var(--ink);
}

button.danger { background: var(--danger); }
button:hover { filter: brightness(0.96); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  background: #f9fafb;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e6f4f1;
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 12px;
}

.badge.warn { background: #fef3c7; color: var(--warn); }
.badge.danger { background: #fee2e2; color: var(--danger); }

.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  padding: 24px;
}

.alert {
  border-radius: 7px;
  padding: 10px 12px;
  background: #eef2ff;
  color: #3730a3;
}

.alert.error {
  background: #fee2e2;
  color: var(--danger);
}

.chat {
  display: grid;
  gap: 10px;
}

.chat-log {
  min-height: 190px;
  max-height: 340px;
  overflow: auto;
  padding: 12px;
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.bubble {
  max-width: 82%;
  margin: 0 0 10px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #e5e7eb;
}

.bubble.user {
  margin-left: auto;
  background: #d1fae5;
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .main { padding: 18px; }
  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .form-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
