:root {
  --ink: #141210;
  --ink-2: #2a2622;
  --paper: #f4f0ea;
  --card: #fffcf7;
  --line: rgba(28, 22, 16, 0.08);
  --gold: #8b6b3e;
  --gold-2: #c4a574;
  --muted: #6f675e;
  --ok: #1f7a54;
  --bad: #b42318;
  --side-w: 248px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Manrope", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body.is-login {
  height: auto;
  overflow: auto;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: var(--paper);
}

.login-hero {
  background:
    radial-gradient(800px 500px at 20% 20%, rgba(196, 165, 116, 0.18), transparent 55%),
    linear-gradient(165deg, #1a1714 0%, #0e0c0b 100%);
  color: #f6f1e8;
  padding: 64px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #d7b889, #8b6b3e);
}

.login-hero h1 {
  font-size: 36px;
  font-weight: 650;
  letter-spacing: 0.04em;
  margin: 28px 0 12px;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(20, 16, 12, 0.06);
}

.login-card h2 { font-weight: 650; margin-bottom: 6px; }
.btn-gold {
  --bs-btn-bg: #1a1714;
  --bs-btn-border-color: #1a1714;
  --bs-btn-hover-bg: #2b261f;
  --bs-btn-hover-border-color: #2b261f;
  --bs-btn-color: #f7f1e6;
  --bs-btn-hover-color: #fff;
}

.layout {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: #141210;
  color: #efe8dc;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px 22px;
}

.sidebar .brand b { font-size: 14px; letter-spacing: 0.08em; }
.sidebar .brand small { display: block; color: #b7ae9f; font-size: 11px; }

.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cfc6b8;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 4px;
}

.sidebar a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar a.active {
  background: rgba(196, 165, 116, 0.16);
  color: #f3e6d0;
}

.main {
  min-width: 0;
  min-height: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 64px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  z-index: 20;
}

.page {
  padding: 20px 28px 24px;
}

.page:not(.page-fill) {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.page-fill {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.2fr);
  gap: 16px;
}

.pane {
  min-height: 0;
  height: 100%;
  overflow: auto;
}

.pane-flex {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 20px 20px;
}

.pane-head {
  flex: 0 0 auto;
  padding: 16px 20px 8px;
}

.pane thead th {
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}

.card-soft {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(20, 16, 12, 0.04);
}

.stat {
  padding: 20px 22px;
}

.stat .n { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.stat .l { color: var(--muted); font-size: 12px; margin-top: 4px; }

.table thead th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  border-bottom-color: var(--line);
}

.score-lg { font-size: 42px; font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
.score-lg.ok { color: var(--ok); }
.score-lg.bad { color: var(--bad); }

.chat-box {
  min-height: 0;
  overflow: auto;
  background: #faf7f2;
  border-radius: 14px;
  padding: 16px;
}

.chat-box.fill {
  flex: 1;
}

.msg {
  max-width: 82%;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
}
.msg .who { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg.agent { margin-left: auto; background: #1a1714; color: #f6f1e8; }
.msg.agent .who { color: #d7cbb8; }
.msg.customer { background: #fff; border: 1px solid var(--line); }

.side-scroll {
  min-height: 0;
  overflow: auto;
}

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; background: #c5bdb1;
}
.dot.live { background: var(--ok); }
.score-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  background: #efeae2;
  border-radius: 12px;
}
.score-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
}
.score-tabs button.on {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(20,16,12,0.06);
}

@media (max-width: 960px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { min-height: 220px; padding: 32px 24px; }
  .layout { grid-template-columns: 1fr; height: auto; overflow: auto; }
  .sidebar { height: auto; position: relative; }
  html, body { height: auto; overflow: auto; }
  .main, .page-fill, .page-split { height: auto; }
  .page-split { grid-template-columns: 1fr; }
  .pane, .pane-flex { height: min(70vh, 640px); }
}
