.agent-page {
  min-height: 100%;
  background:
    linear-gradient(180deg, #dcefe2 0%, #eef6ef 40%, #e7f1ea 100%);
}

.login-wrap[hidden],
.workbench[hidden],
.empty-pane[hidden],
.chat-pane[hidden],
.login-error[hidden] {
  display: none !important;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.login-card {
  width: min(400px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.85rem;
  animation: rise 0.4s ease;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.login-brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.55rem;
  color: var(--brand);
}
.login-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.login-card label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.login-card input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  color: var(--ink);
}
.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.88rem;
}

.workbench {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 280px 1fr 260px;
  gap: 0;
  background: rgba(255,255,255,0.45);
}

.side, .info-pane {
  background: rgba(255,255,255,0.78);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.info-pane {
  border-right: 0;
  border-left: 1px solid var(--line);
  padding: 1rem;
}
.info-pane h3 {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
}
.info-pane dl {
  margin: 0;
  display: grid;
  gap: 0.75rem;
}
.info-pane dl > div {
  display: grid;
  gap: 0.2rem;
}
.info-pane dt {
  font-size: 0.75rem;
  color: var(--muted);
}
.info-pane dd {
  margin: 0;
  font-size: 0.9rem;
  word-break: break-all;
}

.side-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}
.side-brand {
  font-family: var(--display);
  font-weight: 700;
  color: var(--brand);
}
.side-agent {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.side-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  padding: 0.75rem;
}
.tab {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 0.45rem 0.5rem;
  font: inherit;
  cursor: pointer;
  color: var(--muted);
}
.tab.active {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: transparent;
  font-weight: 600;
}

.conv-list {
  overflow-y: auto;
  padding: 0.25rem 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.conv-item {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0.75rem 0.7rem;
  border-radius: 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: grid;
  gap: 0.25rem;
}
.conv-item:hover { background: rgba(31, 107, 69, 0.06); }
.conv-item.active { background: var(--brand-soft); }
.conv-item-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}
.conv-name { font-weight: 600; font-size: 0.92rem; }
.conv-time { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.conv-preview {
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge {
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.7rem;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
}
.badge-queue {
  background: #c2410c;
  min-width: auto;
  padding: 0 0.4rem;
}

.main-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.empty-pane {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 1.5rem;
  gap: 0.5rem;
}
.empty-hint {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}
.empty-hint a {
  color: var(--brand);
  text-decoration: underline;
}
.chat-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.pane-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.7);
}
.pane-title { font-weight: 700; }
.pane-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }
.pane-actions { display: flex; gap: 0.4rem; }

.agent-page .msg-agent {
  align-self: flex-end;
  align-items: flex-end;
}
.agent-page .msg-visitor,
.agent-page .msg-bot {
  align-self: flex-start;
  align-items: flex-start;
}
.agent-page .msg-agent .bubble {
  background: var(--agent-bubble);
  color: #fff;
  border: 0;
  border-bottom-right-radius: 6px;
  border-bottom-left-radius: 16px;
}
.agent-page .msg-visitor .bubble,
.agent-page .msg-bot .bubble {
  background: var(--visitor-bubble);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 16px;
}
.agent-page .msg-bot .bubble {
  background: #f2faf5;
  border-color: rgba(31, 107, 69, 0.28);
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.35rem 1rem 0;
}
.quick-row button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
}
.quick-row button:hover {
  color: var(--brand);
  border-color: rgba(31, 107, 69, 0.35);
}

@media (max-width: 980px) {
  .workbench {
    grid-template-columns: 240px 1fr;
  }
  .info-pane { display: none; }
}

@media (max-width: 720px) {
  .workbench {
    grid-template-columns: 1fr;
  }
  .side {
    max-height: 38vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
