:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #17211f;
  --muted: #64706d;
  --line: #dfe7e4;
  --accent: #0f8f6a;
  --accent-2: #1f6feb;
  --warn: #a15c00;
}

* { 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;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #111b18;
}

.login-screen.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.login-box {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid #294139;
  border-radius: 8px;
  background: #f8fbfa;
}

.login-box h1 {
  font-size: 24px;
}

.login-box small {
  min-height: 18px;
  color: #b42318;
}

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #111b18;
  color: #eef8f4;
  padding: 20px 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 52px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand small {
  display: block;
  color: #b8c8c3;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 6px;
}

button, input, select {
  font: inherit;
}

.nav {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  text-align: left;
  color: #dce7e3;
  background: transparent;
  cursor: pointer;
}

.nav.active, .nav:hover {
  background: #1d2b27;
  color: #ffffff;
}

main {
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

h1, h2, p { margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 16px; margin-bottom: 14px; }
p { color: var(--muted); margin-top: 4px; }

.primary {
  border: 0;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.ghost {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.ghost.compact {
  padding: 6px 8px;
  font-size: 12px;
}

.link-button {
  display: block;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-2);
  font-weight: 700;
  cursor: pointer;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

tr.selected {
  background: #edf8f4;
}

.view { display: none; }
.view.active { display: block; }

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 24px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.stack-gap {
  margin-top: 16px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.list {
  display: grid;
  gap: 8px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdfc;
}

.list-item.danger {
  border-color: #f3c8bf;
  background: #fff7f5;
}

.selectable .list-item {
  cursor: pointer;
}

.selectable .list-item:hover {
  border-color: var(--accent);
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 16px;
}

.chat-panel {
  min-height: 580px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.chat-log, .message-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 460px;
  padding-right: 4px;
}

.bubble {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef4f2;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: #dff5ee;
}

.bubble.bot {
  align-self: flex-start;
}

.chat-form {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 8px;
  margin-top: 14px;
}

input, select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 0;
  background: white;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

label span {
  line-height: 1.2;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-grid .primary,
.form-grid .checkline {
  grid-column: span 2;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.checkline input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.bar-label strong {
  color: var(--ink);
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8efec;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.hint {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

pre {
  background: #111b18;
  color: #e8fff7;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .grid.two, .chat-layout { grid-template-columns: 1fr; }
  .chat-form { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .primary,
  .form-grid .checkline { grid-column: auto; }
}
