:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --text: #15181e;
  --muted: #687180;
  --line: #dfe4ea;
  --line-strong: #c5ccd6;
  --brand: #2357d6;
  --brand-2: #0f9f8f;
  --amber: #b7791f;
  --rose: #be3b55;
  --green: #11875d;
  --shadow: 0 18px 45px rgba(22, 30, 46, 0.09);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(246,247,249,0.92)),
    repeating-linear-gradient(90deg, rgba(21,24,30,0.035) 0 1px, transparent 1px 72px);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  background: #f7f8fb;
}
.portal-page {
  grid-template-columns: minmax(360px, .9fr) minmax(520px, 1fr);
  align-items: center;
  gap: 56px;
  padding: clamp(32px, 7vw, 112px);
  background: #f6f7f9;
}
.portal-hero { max-width: 620px; }
.portal-logo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #151a23;
  color: white;
  font-weight: 850;
  font-size: 18px;
  margin-bottom: 28px;
}
.portal-hero h1 {
  margin: 0;
  font-size: clamp(42px, 4.6vw, 64px);
  line-height: 1.1;
  letter-spacing: 0;
}
.portal-hero p {
  margin: 24px 0 0;
  max-width: 620px;
  color: #667182;
  font-size: clamp(18px, 1.8vw, 24px);
  line-height: 1.75;
  font-weight: 620;
}
.portal-hero .error { margin-top: 22px; max-width: 560px; }
.portal-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
}
.portal-card {
  min-height: 256px;
  border: 1px solid #dfe4eb;
  border-radius: 8px;
  background: white;
  box-shadow: 0 22px 55px rgba(24, 34, 52, 0.08);
  padding: 34px 34px 30px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
}
.portal-card.admin { border-top: 5px solid #2f69f0; }
.portal-card-kicker {
  color: #677182;
  font-weight: 780;
  font-size: 16px;
}
.portal-card h2 {
  margin: 30px 0 18px;
  color: #121722;
  font-size: clamp(26px, 2.5vw, 36px);
  line-height: 1.2;
  letter-spacing: 0;
}
.portal-card p {
  margin: 0 0 30px;
  color: #687180;
  font-size: 17px;
  line-height: 1.7;
  font-weight: 560;
}
.portal-card .btn { min-height: 48px; padding: 0 18px; font-size: 16px; }
.login-pane {
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,0.88);
}
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 42px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  color: white; background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 22px rgba(35,87,214,0.24);
}
.brand-text { font-weight: 750; letter-spacing: 0; }
.login-pane h1 { margin: 0 0 8px; font-size: 31px; line-height: 1.12; letter-spacing: 0; }
.login-pane p { margin: 0 0 28px; color: var(--muted); line-height: 1.7; }
.login-entries {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}
.login-entry {
  min-height: 72px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 12px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  text-align: left;
  cursor: pointer;
}
.login-entry svg { color: var(--muted); }
.login-entry span { display: grid; gap: 3px; min-width: 0; }
.login-entry b { font-size: 14px; line-height: 1.2; }
.login-entry small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.login-entry:hover { border-color: #9fb0c8; background: #f8fafc; }
.login-entry.active { border-color: var(--brand); background: #eef4ff; box-shadow: 0 0 0 3px rgba(35,87,214,0.1); }
.login-entry.active svg { color: var(--brand); }
.login-form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 13px; font-weight: 650; color: #384150; }
.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: white;
  color: var(--text);
  outline: none;
  min-height: 42px;
}
.textarea { min-height: 112px; resize: vertical; line-height: 1.55; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(35,87,214,0.12); }
.input-action { position: relative; }
.input-action .input { padding-right: 44px; }
.secret-toggle {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.secret-toggle:hover { background: #eef2f8; color: var(--text); }
.remember-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  user-select: none;
}
.remember-row input { width: 16px; height: 16px; accent-color: var(--brand); }
.login-canvas {
  position: relative;
  padding: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.product-shot {
  width: min(900px, 92%);
  aspect-ratio: 1.52;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.shot-top { height: 48px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; padding: 0 16px; }
.dot { width: 9px; height: 9px; border-radius: 99px; background: #d4d9e1; }
.shot-body { display: grid; grid-template-columns: 190px 1fr; height: calc(100% - 48px); }
.shot-nav { border-right: 1px solid var(--line); padding: 18px; background: var(--panel-2); display: grid; align-content: start; gap: 10px; }
.shot-pill { height: 32px; border-radius: 8px; background: #e8edf5; }
.shot-main { padding: 22px; display: grid; gap: 14px; grid-template-rows: 46px repeat(3, 1fr); }
.shot-line { background: #edf1f6; border-radius: 8px; }
.shot-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(14px);
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 8px 8px 18px; }
.side-brand strong { font-size: 15px; }
.side-nav { display: grid; gap: 4px; }
.side-link {
  display: flex; align-items: center; gap: 10px;
  min-height: 40px; padding: 0 10px;
  border-radius: 8px; color: #465160; font-weight: 620; font-size: 14px;
}
.side-link.active, .side-link:hover { background: #edf3ff; color: var(--brand); }
.side-footer { position: absolute; left: 14px; right: 14px; bottom: 18px; display: grid; gap: 10px; }
.user-chip { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: white; }
.user-chip b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.user-chip span { color: var(--muted); font-size: 12px; }
.main { min-width: 0; padding: 24px 28px 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.title-block h1 { margin: 0; font-size: 25px; line-height: 1.2; letter-spacing: 0; }
.title-block p { margin: 6px 0 0; color: var(--muted); }

.btn {
  border: 1px solid var(--line-strong);
  min-height: 38px;
  padding: 0 13px;
  border-radius: 8px;
  background: white;
  color: #27313f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 650;
}
.btn:hover { border-color: #9eabbc; background: #f9fafb; }
.btn.primary { border-color: var(--brand); background: var(--brand); color: white; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { border-color: rgba(190,59,85,0.24); color: var(--rose); background: #fff5f7; }
.icon-btn { width: 34px; height: 34px; padding: 0; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.grid { display: grid; gap: 16px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.metric, .panel, .agent-card, .table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.94);
  box-shadow: 0 10px 26px rgba(20, 29, 46, 0.04);
}
.metric { padding: 16px; }
.metric span { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric b { display: block; margin-top: 8px; font-size: 25px; letter-spacing: 0; }
.agent-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.agent-card { padding: 18px; min-height: 172px; display: grid; gap: 16px; align-content: space-between; }
.agent-card header { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.agent-card h2 { margin: 0; font-size: 17px; letter-spacing: 0; }
.agent-card p { margin: 10px 0 0; color: var(--muted); line-height: 1.65; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #edf3ff; color: var(--brand); white-space: nowrap; }
.badge.green { background: #e8f7f0; color: var(--green); }
.badge.amber { background: #fff7e6; color: var(--amber); }
.badge.rose { background: #fff1f3; color: var(--rose); }

.chat-layout { display: grid; grid-template-columns: 290px 1fr; gap: 16px; min-height: calc(100vh - 96px); }
.history-panel, .chat-panel { border: 1px solid var(--line); border-radius: 8px; background: white; min-height: 0; }
.history-panel { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.history-list { display: grid; gap: 6px; overflow: auto; }
.history-item {
  width: 100%; text-align: left; border: 1px solid transparent; background: transparent;
  border-radius: 8px; padding: 10px; display: grid; gap: 4px; color: #344052;
}
.history-item:hover, .history-item.active { background: #f1f5fb; border-color: #d7e0ec; }
.history-item span { color: var(--muted); font-size: 12px; }
.chat-panel { display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.chat-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.chat-head h1 { margin: 0; font-size: 18px; letter-spacing: 0; }
.chat-head p { margin: 5px 0 0; color: var(--muted); }
.messages { overflow: auto; padding: 22px; display: grid; align-content: start; gap: 14px; background: #fbfcfd; }
.empty-state { max-width: 720px; margin: 52px auto; text-align: center; color: var(--muted); line-height: 1.75; }
.empty-state h2 { color: var(--text); margin: 0 0 10px; font-size: 23px; letter-spacing: 0; }
.msg { display: grid; gap: 8px; max-width: 860px; }
.msg.user { justify-self: end; }
.msg.assistant { justify-self: start; }
.bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  line-height: 1.72;
  white-space: pre-wrap;
  background: white;
}
.msg.user .bubble { background: var(--brand); border-color: var(--brand); color: white; }
.msg-tools { display: flex; gap: 8px; justify-content: flex-end; }
.copy-btn { min-height: 34px; padding: 0 11px; font-size: 12px; }
.composer { padding: 14px; border-top: 1px solid var(--line); background: white; display: grid; gap: 10px; }
.composer-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.composer textarea { min-height: 74px; max-height: 180px; }
.hint-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

.admin-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr); gap: 16px; align-items: start; }
.panel { padding: 16px; }
.panel h2 { margin: 0 0 14px; font-size: 17px; letter-spacing: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #526070; font-size: 12px; font-weight: 750; background: #f8fafc; }
td { color: #27313f; }
tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.form-grid { display: grid; gap: 13px; }
.two { grid-template-columns: 1fr 1fr; }
.error {
  color: var(--rose); background: #fff2f5; border: 1px solid #ffd7df;
  border-radius: 8px; padding: 10px 12px; line-height: 1.5;
}
.success {
  color: var(--green); background: #ecf8f2; border: 1px solid #cdebdc;
  border-radius: 8px; padding: 10px 12px; line-height: 1.5;
}
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--green); display: inline-block; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

@media (max-width: 980px) {
  .login-page, .app-shell, .chat-layout, .admin-grid { grid-template-columns: 1fr; }
  .portal-page { gap: 32px; align-items: start; padding: 34px 22px; }
  .portal-options { grid-template-columns: 1fr; }
  .login-canvas { display: none; }
  .sidebar { position: static; height: auto; }
  .side-footer { position: static; margin-top: 18px; }
  .main { padding: 18px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .login-pane { padding: 28px 20px; }
  .portal-card { min-height: 220px; padding: 26px 22px 22px; }
  .login-entries { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
  .topbar, .chat-head, .toolbar { align-items: stretch; flex-direction: column; }
  .composer-row, .two { grid-template-columns: 1fr; }
  .messages { padding: 14px; }
  .table-wrap { overflow-x: auto; }
}
