:root {
  --bg: #eef1f5;
  --panel: rgba(255, 255, 255, .94);
  --panel-2: #f7f9fc;
  --text: #0e1b2e;
  --muted: #5a6b82;
  --line: #e6e9ef;
  --line-2: #d7dce4;
  --rail: #0b1c33;
  --rail-2: #0e2748;
  --accent: #103a6a;
  --accent-2: #228a37;
  --accent-soft: #eaf1fa;
  --danger: #a83b3b;
  --success: #25745d;
  --shadow: 0 10px 30px rgba(15, 23, 42, .06);
}

[data-theme="dark"] {
  --bg: #0a1422;
  --panel: rgba(19, 31, 48, .88);
  --panel-2: #0f1a2a;
  --text: #eef2f7;
  --muted: #93a2b8;
  --line: #22324a;
  --line-2: #2d425e;
  --rail: #060f1c;
  --rail-2: #0a1728;
  --accent: #5a9be6;
  --accent-2: #46c266;
  --accent-soft: rgba(47, 109, 181, .18);
  --shadow: 0 18px 54px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    linear-gradient(135deg, #081d35 0%, #103a6a 48%, #115520 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.login-body {
  min-height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #081d35 0%, #103a6a 46%, #115520 100%);
}

.login-shell { width: min(440px, calc(100% - 32px)); }
.login-panel, .admin-card, .form-pane, .output-pane, .chat-pane {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-panel {
  padding: 36px;
  border-radius: 8px;
  backdrop-filter: blur(18px);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 800;
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: white;
  border: 1px solid rgba(255, 255, 255, .72);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .18);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 {
  font-size: clamp(30px, 3vw, 42px);
  line-height: 1.05;
  font-weight: 700;
}
h2 { font-size: 18px; }
.login-copy { color: var(--muted); line-height: 1.5; }
.page-subtitle {
  margin: 10px 0 0;
  max-width: 680px;
  color: rgba(255, 255, 255, .82);
  line-height: 1.55;
}

.login-form, .admin-card, .field-grid, .form-pane { display: grid; gap: 16px; }
.demo-login-link {
  display: block;
  margin-top: 18px;
  color: var(--accent);
  font-weight: 800;
  text-align: center;
}

.demo-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 18px;
  padding: 13px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .12);
  color: white;
  backdrop-filter: blur(14px);
}
.demo-banner span {
  color: rgba(255, 255, 255, .82);
  font-size: 13px;
}
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(20, 125, 126, .14); }

button, .link-button {
  border: 0;
  border-radius: 8px;
  padding: 12px 15px;
  cursor: pointer;
  font-weight: 800;
}

.primary, .login-form button {
  color: white;
  background: linear-gradient(135deg, #103a6a, #1f5fa6 45%, #228a37);
}
.ghost, .link-button {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin: 14px 0;
  font-weight: 700;
}
.danger { color: var(--danger); background: rgba(168, 59, 59, .1); }
.success { color: var(--success); background: rgba(37, 116, 93, .1); }

.app-shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, rgba(6, 15, 28, .98), rgba(11, 28, 51, .96));
  border-right: 1px solid rgba(255, 255, 255, .08);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand strong, .brand span { display: block; }
.brand strong { color: white; letter-spacing: .18em; font-size: 13px; }
.brand span { color: #9fb0c6; font-size: 12px; margin-top: 2px; }
.side-nav { display: grid; gap: 8px; }
.nav-item {
  text-align: left;
  color: #9fb0c6;
  background: transparent;
  border: 1px solid transparent;
}
.nav-item.active, .nav-item:hover {
  color: white;
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .13);
}
.nav-item.link { display: block; padding: 12px 15px; border-radius: 8px; font-weight: 800; }

.side-card {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .06);
}
.side-card strong { color: white; }
.side-card p { margin: 4px 0 0; color: #9fb0c6; font-size: 13px; line-height: 1.4; }
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #35b779;
  margin-top: 5px;
  flex: 0 0 auto;
}
.side-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; color: #9fb0c6; font-weight: 800; }

.workspace { padding: 26px; min-width: 0; }
.topbar, .admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h1, .admin-header h1 { color: white; }
.top-actions, .output-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(440px, 1.05fr) minmax(380px, .95fr);
  gap: 20px;
  align-items: start;
}

.form-pane, .output-pane, .chat-pane {
  border-radius: 8px;
  padding: 20px;
  backdrop-filter: blur(18px);
}
.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  padding-top: 6px;
}
.section-title span { color: var(--muted); font-size: 12px; }
.field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.compact { gap: 12px; }
.wide { grid-column: 1 / -1; }

.output-pane {
  position: sticky;
  top: 24px;
}
.output-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.record-output {
  min-height: 620px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  margin: 0;
  padding: 18px;
  border-radius: 8px;
  background: #060f1c;
  color: #e9f3ef;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.55;
}
[data-theme="light"] .record-output, :root .record-output {
  background: #060f1c;
}
.notice { min-height: 20px; color: var(--muted); font-size: 13px; }

.chat-pane {
  min-height: 710px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
}
.hidden { display: none !important; }
.messages {
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  max-height: 600px;
}
.message {
  padding: 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(247, 249, 252, .92);
}
.message.user { background: rgba(20, 125, 126, .12); }
.message p { margin: 6px 0 0; white-space: pre-wrap; line-height: 1.5; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }

.admin-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
}
.admin-card {
  border-radius: 8px;
  padding: 22px;
}
.recommendations { align-content: start; }
.rec {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.rec:last-child { border-bottom: 0; }
.rec strong, .rec span { display: block; }
.rec span { color: var(--accent); font-weight: 900; margin-top: 4px; }
.rec p { color: var(--muted); line-height: 1.45; margin: 8px 0 0; }
.rec.muted { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-top: 10px; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .side-nav { grid-template-columns: repeat(3, 1fr); }
  .content-grid, .admin-grid { grid-template-columns: 1fr; }
  .output-pane { position: static; }
}

@media (max-width: 680px) {
  .workspace { padding: 16px; }
  .topbar, .admin-header, .output-header, .section-title { align-items: stretch; flex-direction: column; }
  .field-grid { grid-template-columns: 1fr; }
  .side-nav { grid-template-columns: 1fr; }
  .composer { grid-template-columns: 1fr; }
  .record-output { min-height: 420px; max-height: none; }
}
