:root {
  color-scheme: light dark;
  --canvas: #f3f6f3;
  --panel: #fff;
  --paper: #f1f6f2;
  --text: #162720;
  --muted: #546960;
  --line: #d8e3da;
  --green: #28634c;
  --green-ink: #174534;
  --green-soft: #e1eee6;
  --aside: #142f26;
  --aside-ink: #f1f7f2;
  --aside-muted: #c0d4c7;
  --warn: #84511b;
  --warm: #fcf2e3;
  --bad: #a12932;
  --bad-soft: #fff0f1;
  --focus: #498c68;
  --radius: 14px;
  font: 14px/1.55 Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--canvas);
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #141e19;
    --panel: #1c2922;
    --paper: #202f26;
    --text: #f0f6f1;
    --muted: #b5c9bb;
    --line: #394b40;
    --green: #397d5c;
    --green-ink: #a7ddba;
    --green-soft: #283f32;
    --aside: #10241c;
    --aside-ink: #f1f7f2;
    --aside-muted: #c1d7c9;
    --warn: #ffd5a2;
    --warm: #473825;
    --bad: #ffb4bb;
    --bad-soft: #4b2e32;
    --focus: #89cda4;
  }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(27px, 4vw, 44px); letter-spacing: -.045em; font-weight: 720; line-height: 1.17; }
h2 { font-size: 18px; letter-spacing: -.015em; line-height: 1.35; }
h3 { font-size: 15px; }
a { color: var(--green-ink); text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .62; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
button, input, textarea, select { min-width: 0; }
button { border: 0; background: none; }
input, textarea, select { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
input, textarea { width: 100%; }
label { display: grid; gap: 5px; color: var(--muted); }
textarea { min-height: 78px; resize: vertical; }
.skip { position: fixed; transform: translateY(-120%); left: 10px; top: 10px; padding: 8px 12px; background: var(--panel); border-radius: 6px; z-index: 20; }
.skip:focus { transform: translateY(0); }
.primary, .standard { min-height: 38px; border-radius: 9px; padding: 8px 13px; font-weight: 630; }
.primary { background: var(--green); color: #fff; }
.primary:hover:not(:disabled) { background: #1b4e3a; }
.standard { border: 1px solid var(--line); background: var(--panel); }
.standard:hover:not(:disabled) { background: var(--green-soft); }
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 28px 20px; background: var(--canvas); }
.login { width: min(100%, 420px); padding: clamp(23px, 7vw, 40px); border: 1px solid var(--line); border-radius: 22px; background: var(--panel); }
.login > h1 { margin-top: 28px; }
.login p { color: var(--muted); margin-top: 9px; }
.login form { display: grid; gap: 16px; margin-top: 24px; }
.login form button, .login > button { margin-top: 7px; }
#login-error { color: var(--bad); }
.brand { display: flex; align-items: center; gap: 11px; width: fit-content; color: inherit; text-decoration: none; }
.brand strong { font-size: 21px; letter-spacing: -.045em; }
.brand small { display: block; color: var(--aside-muted); font-size: 11px; line-height: 1.1; }
.mark { display: block; width: 36px; height: 36px; flex: none; border-radius: 10px; background: #10382f; }
.workspace { min-height: 100dvh; display: grid; grid-template-columns: 208px minmax(0, 1fr); align-items: start; }
.rail { position: sticky; top: 0; min-height: 100dvh; display: flex; flex-direction: column; padding: 25px 14px 18px; background: var(--aside); color: var(--aside-ink); }
.rail > .brand { margin: 0 8px; }
.nav { display: grid; gap: 5px; margin-top: 39px; }
.nav a, .rail-bottom button { display: flex; align-items: center; gap: 9px; border-radius: 8px; padding: 10px; min-height: 43px; color: var(--aside-muted); text-decoration: none; }
.nav a[aria-current=page] { background: #284b3d; color: #fff; font-weight: 650; }
.nav a:hover, .rail-bottom button:hover { background: #284b3d; }
.nav .icon, .rail-bottom .icon { width: 18px; height: 18px; flex: none; }
.nav .nav-count { margin-left: auto; min-width: 19px; padding: 0 4px; border-radius: 5px; background: #bce6c8; color: #123622; text-align: center; font-size: 11px; font-weight: 700; }
.rail-bottom { margin-top: auto; padding-top: 18px; }
.rail-bottom button { width: 100%; text-align: left; }
.main { padding: 29px clamp(24px, 4vw, 61px) 48px; max-width: 1690px; width: 100%; min-width: 0; }
.top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 21px; }
.today { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.refresh button { display: flex; align-items: center; gap: 7px; }
.icon { display: inline-block; width: 18px; height: 18px; vertical-align: middle; flex: none; }
.notice { padding: 9px 12px; margin-bottom: 14px; border-radius: 8px; background: var(--green-soft); color: var(--green-ink); }
.notice.error, .form-error { color: var(--bad); background: var(--bad-soft); }
.notice.warning { color: var(--warn); background: var(--warm); }
.muted, .section-note { color: var(--muted); }
.section-note { margin-top: 5px; font-size: 13px; }
.panel { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.panel + .panel { margin-top: 14px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 162px), 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); padding: 16px 18px; border-top: 2px solid var(--line); border-bottom: 1px solid var(--line); display: grid; gap: 3px; }
.stat.is-key { border-top-color: var(--green); }
.stat-label, .stat-note { color: var(--muted); font-size: 12px; }
.stat-number { display: block; font-size: clamp(23px, 3vw, 34px); font-weight: 740; letter-spacing: -.06em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.16; }
.empty { padding: 22px 12px; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.warning-list { display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
.warning-list li { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 5px 10px; padding: 10px 12px; background: var(--warm); color: var(--warn); border-radius: 8px; }
.warning-list p { grid-column: 2; font-size: 13px; }
.warning-list .icon { grid-row: 1 / span 2; }
.warning-list li[data-level=critical], .warning-list li[data-level=error] { background: var(--bad-soft); color: var(--bad); }
.table-scroll { overflow: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
caption { text-align: left; }
th, td { text-align: left; padding: 10px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 640; }
td:first-child, th:first-child { padding-left: 0; }
td:last-child, th:last-child { padding-right: 0; }
tr:last-child td { border-bottom: 0; }
.budget-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 16px; }
.budget-label { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; align-items: baseline; font-size: 13px; }
progress { width: 100%; height: 8px; border: 0; border-radius: 9px; appearance: none; background: var(--green-soft); accent-color: var(--green); }
progress::-webkit-progress-bar { background: var(--green-soft); border-radius: 9px; }
progress::-webkit-progress-value { background: var(--green); border-radius: 9px; }
progress::-moz-progress-bar { background: var(--green); border-radius: 9px; }
.chart { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chart li { display: grid; grid-template-columns: 46px minmax(35px, 1fr) 90px; align-items: center; gap: 9px; font-size: 12px; }
.chart .bar { min-height: 7px; }
.chart li span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.inbox { display: grid; grid-template-columns: clamp(245px, 28vw, 330px) minmax(0, 1fr); min-height: min(74vh, 770px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.inbox-list { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-width: 0; }
.inbox-filters { padding: 12px; display: flex; gap: 5px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.inbox-filters button, .badge { padding: 4px 8px; border-radius: 6px; font-size: 12px; color: var(--muted); font-weight: 620; }
.inbox-filters button { min-height: 34px; }
.inbox-filters button[aria-pressed=true], .badge.green { background: var(--green-soft); color: var(--green-ink); }
.inbox-filters button:hover, .conversation-link:hover { background: var(--paper); }
.badge.warning { background: var(--warm); color: var(--warn); }
.conversation-list { display: grid; align-content: start; min-height: 0; max-height: 67vh; overflow-y: auto; list-style: none; padding: 0; margin: 0; }
.conversation-link { display: grid; position: relative; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px; width: 100%; border-bottom: 1px solid var(--line); padding: 12px 14px; color: inherit; text-align: left; text-decoration: none; }
.conversation-link[aria-current=true] { background: var(--green-soft); box-shadow: inset 3px 0 var(--green); }
.conversation-link[data-unread=true] strong::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--green); vertical-align: 1px; }
.conversation-link strong, .snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-link small, .snippet { font-size: 12px; color: var(--muted); }
.snippet { grid-column: 1 / -1; }
.conversation-link .badge { justify-self: start; grid-column: 1 / -1; }
.list-more { margin: 9px 12px; align-self: start; }
.inbox-detail { min-width: 0; display: grid; grid-template-rows: auto minmax(150px, 1fr) auto; }
.inbox-detail .detail-empty { grid-row: 1 / -1; align-self: center; }
.message-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.message-head h2 { overflow-wrap: anywhere; }
.message-head p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.head-info { min-width: 0; flex: 1 1 165px; }
.message-controls { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.message-area { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; padding: 10px 13px; background: var(--paper); }
.message-area > button { justify-self: center; margin-bottom: 7px; }
.messages { align-content: start; display: grid; gap: 14px; list-style: none; padding: 4px 2px 8px; margin: 0; overflow: auto; min-height: 150px; max-height: 57dvh; scrollbar-gutter: stable; }
.message { max-width: min(85%, 680px); min-width: 0; justify-self: start; }
.message[data-role=human], .message[data-role=agent] { justify-self: end; }
.message-meta { font-size: 12px; color: var(--muted); margin: 0 2px 4px; }
.message[data-role=human] .message-meta, .message[data-role=agent] .message-meta { text-align: right; }
.message-body { border: 1px solid var(--line); background: var(--panel); padding: 9px 12px; border-radius: 2px 11px 11px; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-wrap; }
.message[data-role=human] .message-body { background: var(--green-soft); border-radius: 11px 2px 11px 11px; }
.message[data-role=agent] .message-body { border-radius: 11px 2px 11px 11px; }
.attachments { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.attachments button { text-align: left; font-size: 12px; }
.composer { padding: 12px 14px; display: grid; gap: 8px; border-top: 1px solid var(--line); }
.composer .composer-footer { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; }
.composer .composer-footer .muted { font-size: 12px; }
.mobile-back { display: none; }
.form-grid { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.form-grid label { flex: 1 1 136px; }
.form-error { padding: 8px; margin-top: 5px; border-radius: 7px; }
.settings-data { display: grid; grid-template-columns: repeat(auto-fit, minmax(98px, 1fr)); gap: 10px; margin: 10px 0 0; }
.settings-data dt { font-size: 12px; color: var(--muted); }
.settings-data dd { margin: 0; font-size: 19px; font-variant-numeric: tabular-nums; }
dialog { width: min(740px, calc(100vw - 28px)); max-height: calc(100dvh - 36px); padding: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: var(--radius); }
dialog::backdrop { background: #13251ec7; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; gap: 9px; }
dialog > img { display: block; max-width: 100%; max-height: 73dvh; margin: 0 auto; object-fit: contain; }
@media (max-width: 860px) {
  .workspace { grid-template-columns: 164px minmax(0, 1fr); }
  .main { padding: 23px 17px 38px; }
  .inbox { grid-template-columns: 220px minmax(0, 1fr); }
}
@media (max-width: 690px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .rail { position: sticky; z-index: 3; padding: 8px 10px 3px; min-height: auto; display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .rail > .brand { margin: 0 0 0 3px; }
  .rail > .brand small { display: none; }
  .nav { order: 3; grid-column: 1 / -1; display: grid; grid-template-columns: .85fr 1.25fr 1.25fr 1.25fr .8fr; gap: 1px; margin-top: 4px; }
  .nav a { padding: 5px 2px; gap: 3px; justify-content: center; min-height: 36px; font-size: 11px; }
  .nav .icon { width: 13px; height: 13px; }
  .nav .nav-count { margin-left: 0; min-width: 14px; padding: 0 2px; font-size: 9px; }
  .rail-bottom { margin: 0; padding: 0; }
  .rail-bottom button { min-height: 38px; padding: 4px 7px; font-size: 12px; }
  .main { padding: 16px 11px 26px; }
  .top { margin-bottom: 14px; }
  .today { margin-bottom: 3px; }
  .inbox { grid-template-columns: 1fr; min-height: 58dvh; }
  .inbox-list { border-right: 0; }
  .inbox:not(.conversation-open) .inbox-detail, .inbox.conversation-open .inbox-list { display: none; }
  .inbox .mobile-back { display: inline-flex; align-items: center; gap: 5px; }
  .message-head { padding: 9px 11px; }
  .messages { max-height: 49dvh; }
  .message { max-width: min(90%, 550px); }
  .panel { padding: 12px; }
}
@media (max-width: 340px) {
  .nav .icon { display: none; }
  .chart li { grid-template-columns: 37px 1fr 78px; gap: 5px; }
}
.messages { grid-row: 2; }
.timestamp-note { margin: -8px 0 16px; font-size: 12px; }
.balance-form + .balance-form { margin-top: 10px; }
.form-grid .form-error { flex: 1 0 100%; }
