:root {
  color-scheme: light;
  --ink: #17201f;
  --muted: #65716f;
  --line: #dbe4e1;
  --surface: #ffffff;
  --surface-soft: #f4f8f6;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --teal-soft: #dff3ef;
  --amber: #b7791f;
  --amber-soft: #fff2cf;
  --rose: #be123c;
  --rose-soft: #ffe4e6;
  --shadow: 0 18px 45px rgba(25, 46, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #edf3f1;
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: #10231f;
  color: #f8fbfa;
}

.brand-block {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0)),
    #18a094;
  overflow: hidden;
}

.brand-mark span {
  position: absolute;
  width: 34px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
}

.brand-mark span:nth-child(1) {
  top: 15px;
  left: 12px;
}

.brand-mark span:nth-child(2) {
  top: 25px;
  left: 8px;
  width: 28px;
}

.brand-mark span:nth-child(3) {
  top: 35px;
  left: 18px;
  width: 24px;
  background: #ffd166;
}

.eyebrow,
.panel-label {
  margin: 0 0 6px;
  color: #6b827e;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.sidebar .eyebrow,
.sidebar .panel-label {
  color: #9fc7bf;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.25;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #dfece8;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #f8fbfa;
  color: #10231f;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 800;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.tenant-panel {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar .tenant-panel:first-of-type {
  margin-top: auto;
}

.auth-panel {
  margin-top: 0;
}

.assistant-mini {
  display: flex;
  align-items: center;
  gap: 12px;
}

.assistant-mini strong,
.assistant-mini span {
  display: block;
}

.assistant-mini span {
  margin-top: 3px;
  color: #bdd4cf;
  font-size: 12px;
}

.assistant-face {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background:
    linear-gradient(145deg, #fdfdf8 0%, #c7ede5 100%);
  border: 3px solid rgba(255, 255, 255, 0.18);
  flex: 0 0 auto;
}

.face-eye {
  position: absolute;
  top: 17px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10231f;
}

.face-eye.left {
  left: 15px;
}

.face-eye.right {
  right: 15px;
}

.face-mouth {
  position: absolute;
  left: 17px;
  bottom: 13px;
  width: 14px;
  height: 6px;
  border-bottom: 2px solid #10231f;
  border-radius: 50%;
}

.slogan {
  margin: 14px 0 0;
  color: #d8e7e3;
  font-size: 13px;
  line-height: 1.6;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
}

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

.top-actions,
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #14b86a;
  box-shadow: 0 0 0 4px rgba(20, 184, 106, 0.14);
}

.view {
  display: none;
  min-height: 0;
}

.view.active {
  display: block;
}

.reception-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  min-height: calc(100vh - 116px);
}

.chat-surface,
.handoff-panel,
.deploy-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-surface {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto auto;
  min-height: 620px;
  overflow: hidden;
}

.chat-header,
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(223, 243, 239, 0.46), rgba(255, 255, 255, 0) 30%),
    var(--surface-soft);
}

.message {
  display: flex;
  gap: 10px;
  max-width: 78%;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.message.user .message-avatar {
  background: #293a37;
}

.message-bubble {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.7;
  box-shadow: 0 8px 24px rgba(25, 46, 42, 0.06);
}

.message.user .message-bubble {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.source-pill,
.soft-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
}

.source-pill.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.prompt-button,
.secondary-button,
.primary-button,
.danger-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.prompt-button,
.secondary-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.prompt-button:hover,
.secondary-button:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.primary-button {
  background: var(--teal);
  color: #fff;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.danger-button {
  border-color: rgba(190, 18, 60, 0.22);
  background: var(--rose-soft);
  color: var(--rose);
}

.danger-button:hover {
  border-color: var(--rose);
}

.primary-button.full {
  width: 100%;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 94px;
  padding: 12px;
}

select {
  min-height: 42px;
  padding: 0 10px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.auth-form,
.admin-identity {
  display: grid;
  gap: 10px;
}

.admin-identity strong,
.admin-identity span {
  display: block;
}

.admin-identity span {
  color: #bdd4cf;
  font-size: 12px;
}

.auth-panel input {
  min-height: 38px;
}

#authMessage[data-tone="warning"] {
  color: #ffd1d8;
}

#authMessage[data-tone="success"] {
  color: #bff2d6;
}

.insight-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metric-card {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric-card.wide {
  grid-column: 1 / -1;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 28px;
}

.metric-card.wide strong {
  font-size: 16px;
  line-height: 1.5;
}

.handoff-panel {
  padding: 18px;
}

.handoff-form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding-top: 16px;
}

.knowledge-grid .empty-state {
  grid-column: 1 / -1;
}

.knowledge-card,
.ticket-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(25, 46, 42, 0.07);
}

.knowledge-card {
  padding: 16px;
  min-height: 220px;
}

.knowledge-card h4,
.ticket-card h4 {
  margin: 10px 0 8px;
  font-size: 16px;
}

.knowledge-card p,
.ticket-card p,
.deploy-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.keyword-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.keyword-row span {
  padding: 4px 7px;
  border-radius: 999px;
  background: #f2f5f4;
  color: var(--muted);
  font-size: 12px;
}

.card-actions,
.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.editor-form {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(25, 46, 42, 0.06);
}

.editor-form.compact {
  margin-top: 16px;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.editor-form label {
  display: grid;
  gap: 7px;
}

.editor-form label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.editor-form[hidden],
[hidden] {
  display: none !important;
}

.ticket-list {
  display: grid;
  gap: 12px;
  padding-top: 16px;
}

.ticket-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 16px;
}

.ticket-meta {
  color: var(--muted);
  font-size: 13px;
}

.ticket-status {
  align-self: start;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
}

.ticket-controls {
  display: grid;
  grid-template-columns: 116px 96px minmax(120px, 1fr) minmax(140px, 1.2fr) 74px;
  gap: 8px;
  margin-top: 14px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px dashed #bfd0cc;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  text-align: center;
}

.gate-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
}

.gate-state p {
  margin-bottom: 0;
}

.deploy-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.deploy-card {
  padding: 20px;
}

.deploy-card.accent {
  border-color: rgba(15, 118, 110, 0.28);
  background: #f8fcfb;
}

.deploy-steps {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

code {
  display: block;
  overflow-x: auto;
  padding: 12px;
  border-radius: 8px;
  background: #12231f;
  color: #f8fbfa;
  font-size: 13px;
}

.config-list {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
}

.config-list.compact-list {
  margin-top: 14px;
}

.config-list div {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.config-list dt {
  color: var(--muted);
  font-weight: 700;
}

.config-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.security-panel {
  margin-top: 18px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .reception-grid,
  .deploy-layout {
    grid-template-columns: 1fr;
  }

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

  .ticket-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .chat-header,
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-surface {
    min-height: 620px;
  }

  .message {
    max-width: 94%;
  }

  .knowledge-grid {
    grid-template-columns: 1fr;
  }

  .ticket-card {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .ticket-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .nav-list {
    grid-template-columns: 1fr;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}
