:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fbfb;
  --ink: #122027;
  --muted: #64747d;
  --line: #dbe4e7;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --accent: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow: 0 16px 38px rgba(15, 35, 45, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button, .button {
  min-height: 38px;
  border: 1px solid var(--brand);
  border-radius: 7px;
  padding: 0 13px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

button.secondary, .button.secondary {
  background: #e7f4f2;
  color: var(--brand-strong);
}

button.ghost {
  background: transparent;
  color: var(--brand-strong);
  border-color: var(--line);
}

input, select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 11px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  border-right: 1px solid var(--line);
  background: #fbfdfd;
  padding: 18px 14px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 5px 18px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 850;
}

.brand strong, .brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 5px;
}

.nav button {
  justify-content: flex-start;
  width: 100%;
  min-height: 36px;
  border-color: transparent;
  background: transparent;
  color: #263942;
  font-weight: 650;
}

.nav button.active {
  background: #dff3ef;
  color: var(--brand-strong);
  border-color: #b8ded8;
}

.app-shell {
  margin-left: 250px;
  min-height: 100vh;
  padding: 22px 24px 42px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1, h2, h3, p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 28px;
}

h2 {
  margin: 0;
  font-size: 18px;
}

h3 {
  margin: 0 0 7px;
  font-size: 15px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-actions input {
  width: 210px;
}

.guide-panel {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: #fff8eb;
  border: 1px solid #f3d49a;
  border-radius: 8px;
  padding: 13px 15px;
  margin-bottom: 16px;
}

.guide-panel p {
  margin: 5px 0 0;
  color: #6b5a36;
  line-height: 1.55;
}

.guide-panel.hidden {
  display: none;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  box-shadow: var(--shadow);
}

.metric small {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.two-col, .workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.customers-grid {
  grid-template-columns: minmax(320px, .9fr) minmax(0, 1.1fr);
}

.chat-layout {
  display: grid;
  grid-template-columns: 260px minmax(360px, 1fr) 330px;
  gap: 14px;
  min-height: 680px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel.compact {
  padding: 13px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.muted {
  color: var(--muted);
  line-height: 1.65;
}

.list, .timeline, .card-grid, .messages {
  display: grid;
  gap: 10px;
}

.list {
  margin-top: 12px;
}

.list-item, .timeline-item, .asset-card {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 12px;
}

.selectable .list-item {
  cursor: pointer;
}

.selectable .list-item.active {
  border-color: var(--brand);
  background: #edf8f5;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip, .badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: #e7eff1;
  color: #36515c;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok, .chip.ok {
  background: #dcfce7;
  color: var(--ok);
}

.badge.warn, .chip.warn {
  background: #fef3c7;
  color: var(--accent);
}

.badge.danger, .chip.danger {
  background: #fee2e2;
  color: var(--danger);
}

.profile-empty {
  min-height: 210px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  padding: 20px;
}

.messages {
  min-height: 520px;
  max-height: 58vh;
  overflow-y: auto;
  padding-right: 4px;
}

.message {
  max-width: 86%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
}

.message.outbound {
  justify-self: end;
  background: #e7f4f2;
  border-color: #b8ded8;
}

.message.internal {
  justify-self: center;
  background: #fff8eb;
  border-color: #f3d49a;
}

.message small {
  color: var(--muted);
  display: block;
  margin-bottom: 5px;
}

.composer {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto auto;
  gap: 8px;
  margin-top: 12px;
}

.ai-panel {
  display: grid;
  gap: 12px;
}

.suggestion {
  border-left: 4px solid var(--brand);
  background: #edf8f5;
  border-radius: 7px;
  padding: 12px;
  line-height: 1.65;
}

.form {
  display: grid;
  gap: 10px;
}

.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.asset-card p, .timeline-item p, .list-item p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.risk-grid, .status-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.risk-grid span, .status-board span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-soft);
  font-weight: 700;
}

.check-list {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.ordered {
  line-height: 1.9;
  color: var(--muted);
}

.comparison {
  display: grid;
  gap: 10px;
}

.compare-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-soft);
}

.kv {
  display: grid;
  gap: 8px;
}

.kv div {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  border-radius: 8px;
  padding: 12px 14px;
  background: #0f172a;
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateY(120%);
  transition: transform .18s ease;
  z-index: 30;
}

.toast.show {
  transform: translateY(0);
}

[data-tip] {
  position: relative;
}

[data-tip]:hover::after, [data-tip]:focus::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 40;
  top: calc(100% + 7px);
  right: 0;
  width: min(320px, 82vw);
  padding: 9px 10px;
  border-radius: 7px;
  background: #102027;
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .sidebar {
    position: static;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  }

  .app-shell {
    margin-left: 0;
    padding: 16px;
  }

  .topbar, .two-col, .workspace-grid, .chat-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

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

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

@media (max-width: 620px) {
  .metric-grid, .card-grid {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions > * {
    width: 100%;
  }
}
