:root {
  color-scheme: light;
  --bg: #eef4fa;
  --panel: #ffffff;
  --line: #dfe7f1;
  --text: #172033;
  --muted: #65758b;
  --blue: #1f8fff;
  --blue-dark: #1169d8;
  --cyan: #11b8d8;
  --green: #16a34a;
  --red: #dc2626;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.chat-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 860px;
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(31, 143, 255, 0.08), rgba(238, 244, 250, 0) 220px),
    #eef4fb;
}
.chat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px;
  background: linear-gradient(135deg, #ffffff 0%, #f7fbff 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 26px rgba(19, 72, 128, 0.08);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 54px; height: 54px; border-radius: 13px;
  background: linear-gradient(145deg, var(--blue), var(--blue-dark));
  color: white; display: grid; place-items: center;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 12px 28px rgba(31, 143, 255, 0.32);
}
.brand h1 { margin: 0; font-size: 20px; line-height: 1.2; }
.brand p { margin: 5px 0 0; color: #38506b; font-size: 13px; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #405672;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid #d8e8fb;
  border-radius: 999px;
  background: #fff;
  white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.messages {
  overflow-y: auto;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.empty {
  margin: auto;
  text-align: center;
  color: #5f7188;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.5;
}
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}
.quick button {
  border: 1px solid #a9d2ff;
  background: #fff;
  color: #0b73d9;
  border-radius: 999px;
  padding: 8px 15px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(31, 143, 255, 0.08);
}
.quick button:hover {
  background: #eff7ff;
  border-color: #78b9ff;
}
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg.mine { flex-direction: row-reverse; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; flex: 0 0 auto;
  background: #dbeafe; color: #0b73d9; font-weight: 700; font-size: 12px;
}
.msg:not(.mine) .avatar { background: #dcfce7; color: #15803d; }
.bubble {
  max-width: min(640px, 72vw);
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 5px rgba(15, 23, 42, 0.08);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.mine .bubble { background: var(--blue); color: #fff; }
.time { margin-top: 4px; color: #8a99aa; font-size: 11px; }
.mine .time { text-align: right; }
.composer {
  padding: 12px 14px 10px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.composer-main {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
.composer button, .primary {
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: #fff;
  padding: 10px 16px;
  font-weight: 700;
}
.service-footer {
  margin-top: 8px;
  color: #7a8aa0;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 560px) {
  .chat-shell { max-width: none; }
  .chat-top { padding: 14px; align-items: flex-start; }
  .brand { gap: 11px; }
  .brand-mark { width: 48px; height: 48px; font-size: 14px; }
  .brand h1 { font-size: 18px; }
  .brand p { font-size: 12px; }
  .status { padding: 6px 8px; font-size: 12px; }
  .empty { font-size: 18px; }
  .composer-main { gap: 7px; }
  .composer button { padding: 10px 14px; }
}

.admin-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}
.login-box h1 { margin: 0 0 16px; font-size: 20px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { color: var(--muted); font-size: 13px; }
.field input, .note-box, .search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  outline: none;
  background: #fff;
}
.error { color: var(--red); font-size: 13px; min-height: 20px; }

.admin-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr 300px;
  background: #edf2f7;
}
.session-pane, .info-pane, .work-pane {
  min-width: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.pane-head {
  min-height: 58px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  align-items: center;
}
.session-list { height: calc(100vh - 112px); overflow-y: auto; padding: 8px; }
.session-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 10px;
}
.session-item.active, .session-item:hover { background: #eef6ff; border-color: #c7defc; }
.session-title { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.badge { background: var(--red); color: #fff; border-radius: 999px; min-width: 20px; padding: 1px 6px; font-size: 11px; text-align: center; }
.session-meta { color: var(--muted); font-size: 12px; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-pane { display: grid; grid-template-rows: auto 1fr auto; }
.info-pane { border-right: 0; border-left: 1px solid var(--line); padding: 14px; overflow-y: auto; }
.info-grid { display: grid; gap: 10px; font-size: 13px; }
.info-grid b { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.note-box { min-height: 110px; resize: vertical; margin-top: 12px; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; grid-template-rows: 240px 1fr 240px; }
  .session-list { height: 182px; }
  .info-pane { border-left: 0; border-top: 1px solid var(--line); }
}
