:root {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #192a36;
  background: #f1f5f4;
  --ink: #192a36;
  --muted: #4f626e;
  --line: #dce6e6;
  --green: #006454;
  --dark: #102e33;
  --mint: #a7f3ce;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.35rem); line-height: 1.16; letter-spacing: -.035em; }
h2 { font-size: 1.22rem; }
h3 { font-size: 1rem; }
button, input, textarea, select { font: inherit; }
button, input, textarea, select {
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: white;
  color: var(--ink);
  padding: .65rem .8rem;
  min-width: 0;
}
button { cursor: pointer; font-weight: 650; }
button:hover { border-color: var(--green); }
button:disabled { opacity: .5; cursor: wait; }
input, textarea, select { width: 100%; }
:focus-visible { outline: 3px solid #158b76; outline-offset: 2px; }
label { display: grid; gap: .35rem; font-size: .92rem; font-weight: 650; }
textarea { resize: vertical; }
.primary { border-color: var(--green); background: var(--green); color: white; }
.primary:hover { background: #08493e; }
.muted { color: var(--muted); line-height: 1.55; }
.eyebrow { color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .16em; }
.brand { display: inline-flex; align-items: center; gap: .7rem; font-weight: 800; line-height: 1.2; color: inherit; }
.brand small { display: block; margin-top: .25rem; font-size: .56rem; letter-spacing: .14em; opacity: .85; }
.brand-mark { display: grid; place-items: center; width: 2.55rem; height: 2.55rem; border-radius: .8rem; color: #08332a; background: var(--mint); font-size: 1.35rem; }
.landing { min-height: 100dvh; padding: clamp(1.6rem, 5vw, 5rem); color: #f5fff9; background: radial-gradient(ellipse at 85% 5%, #176d61, transparent 50%), var(--dark); }
.landing > .eyebrow { margin: 4.5rem 0 1rem; }
.landing .eyebrow, .login-hero .eyebrow { color: var(--mint); }
.landing h1, .login-hero h1 { font-size: clamp(2.65rem, 6vw, 5.4rem); }
.intro { margin-top: 1.25rem; color: #d1e8e5; }
.portal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 3rem; max-width: 65rem; }
.portal-grid a { border: 1px solid #608582; border-radius: 1.1rem; padding: 1.4rem; color: inherit; background: #193e42; }
.portal-grid a:hover { border-color: var(--mint); text-decoration: none; }
.portal-grid h2 { margin: .75rem 0 .4rem; font-size: 1.65rem; }
.portal-grid p { color: #d1e8e5; margin-bottom: 1.2rem; }
.portal-grid span, .portal-grid b { color: var(--mint); font-size: .8rem; }
.login-layout { display: grid; grid-template-columns: 1fr 1fr; min-height: 100dvh; }
.login-hero { background: radial-gradient(ellipse at 80% 25%, #197668, transparent 58%), var(--dark); color: white; padding: clamp(1.5rem, 5vw, 5rem); display: grid; align-content: space-between; min-height: 28rem; }
.login-hero .eyebrow { margin-bottom: 1rem; }
.login-box { display: grid; place-items: center; padding: 2rem; background: white; }
.login-box form { display: grid; gap: 1rem; width: min(100%, 25rem); }
.login-box h2 { font-size: 2rem; }
.workspace { display: grid; grid-template-columns: 14rem minmax(0, 1fr); min-height: 100dvh; }
.sidebar { display: flex; flex-direction: column; align-items: stretch; padding: 1.35rem 1rem; gap: 2rem; background: var(--dark); color: white; }
.sidebar .brand { padding: .3rem; }
.nav-group { display: grid; gap: .35rem; }
.nav-group p { color: var(--mint); padding: 0 .6rem .45rem; }
.nav-button { color: #dfefed; background: transparent; border-color: transparent; text-align: left; }
.nav-button[aria-current="page"] { background: #245457; border-color: #527f7a; color: white; }
.account { margin-top: auto; display: flex; align-items: center; gap: .5rem; justify-content: space-between; }
.account p { color: #b8d7d1; font-size: .82rem; margin-top: .25rem; }
.topbar { display: flex; gap: 1rem; align-items: center; justify-content: space-between; padding: 1rem clamp(1rem, 4vw, 2.75rem); background: white; border-bottom: 1px solid var(--line); font-size: .9rem; }
.page { padding: 1.75rem clamp(1rem, 4vw, 2.75rem) 3rem; max-width: 98rem; }
.page-heading { display: grid; gap: .55rem; margin-bottom: 1.5rem; }
.card { background: white; border: 1px solid var(--line); border-radius: .95rem; padding: 1.15rem; min-width: 0; }
.card h2 { margin-bottom: .65rem; }
.kpis { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .8rem; margin-bottom: .9rem; }
.kpis strong { display: block; color: var(--green); font-size: 2.25rem; margin-top: .5rem; font-variant-numeric: tabular-nums; }
.dashboard-grid, .content-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .9rem; align-items: start; }
.activity { display: flex; gap: .5rem; align-items: center; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.activity time { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.inbox { display: grid; grid-template-columns: minmax(15rem, 1fr) minmax(20rem, 2fr); background: white; border: 1px solid var(--line); border-radius: .95rem; overflow: hidden; }
.inbox-list { border-right: 1px solid var(--line); min-width: 0; }
.filters { display: grid; gap: .55rem; padding: .85rem; }
#rows { max-height: 31rem; overflow: auto; }
.row { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: .5rem; text-align: left; border-width: 1px 0 0; border-radius: 0; padding: .85rem; overflow-wrap: anywhere; }
.row.selected { background: #e6f6ee; }
.row small { display: block; color: var(--muted); margin-top: .2rem; }
.badge { padding: .3rem .55rem; border-radius: 2rem; font-weight: 750; font-size: .73rem; white-space: nowrap; color: #394b56; background: #e7edf0; }
.badge.ai { background: #dff1ff; color: #154870; }
.badge.queued { background: #fff0cf; color: #744b00; }
.badge.active { background: #d5f5e7; color: #005546; }
.thread { min-height: 27rem; min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 1rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.section-head .muted { font-size: .85rem; }
.empty { color: var(--muted); padding: 1.3rem; }
.messages { min-height: 15rem; max-height: min(49vh, 31rem); overflow: auto; display: flex; flex-direction: column; gap: .65rem; padding: 1rem; background: #f7faf9; }
.message { max-width: 88%; align-self: start; background: white; border: 1px solid var(--line); border-radius: .8rem .8rem .8rem .15rem; padding: .65rem .8rem; }
.message.visitor { background: #dff5ea; align-self: end; border-radius: .8rem .8rem .15rem .8rem; }
.message.system { align-self: center; background: transparent; border: 0; text-align: center; color: var(--muted); font-size: .83rem; }
.message div { display: flex; gap: .55rem; align-items: baseline; margin-bottom: .25rem; font-size: .78rem; }
.message.system div { justify-content: center; }
.message time { color: var(--muted); font-size: .72rem; }
.message p, .entry p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.compose, .chat-tools, #assign { display: flex; align-items: center; gap: .45rem; }
.compose, .chat-tools { padding: .65rem 1rem; flex-wrap: wrap; }
.compose input { flex: 1; }
.chat-tools select { width: auto; max-width: 100%; }
.visitor-shell { width: min(100%, 47rem); margin: 0 auto; padding: 1rem; }
.visitor-shell header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.3rem; gap: .6rem; }
.visitor-card { border-radius: 1.1rem; border: 1px solid var(--line); overflow: hidden; background: white; }
.visitor-card h1 { font-size: 1.6rem; margin-top: .3rem; }
.visitor-form { display: grid; gap: .85rem; padding: 1rem; }
.visitor-form .primary { justify-self: start; }
.visitor-footer { padding: .65rem; text-align: center; font-size: .8rem; }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; white-space: nowrap; text-align: left; }
th, td { padding: .6rem; border-bottom: 1px solid var(--line); }
.edit-form { margin-top: .9rem; }
.content-grid .edit-form { margin: 0; }
.edit-form label { margin-bottom: .8rem; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .5rem 1rem; }
.entry { padding: .75rem 0; border-bottom: 1px solid var(--line); }
.entry:last-child { border: 0; }
.entry p { margin: .45rem 0; }
.settings { max-width: 40rem; }
#notice { position: fixed; inset: auto 1rem 1rem auto; background: var(--dark); color: white; padding: .75rem 1rem; border-radius: .7rem; box-shadow: 0 8px 25px #102e3333; max-width: calc(100% - 2rem); z-index: 5; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 850px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { gap: .7rem; padding: .75rem; }
  .nav-group { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
  .nav-group p { padding: 0 .4rem; }
  .nav-button { padding: .4rem .5rem; }
  .account { gap: 1rem; justify-content: start; }
  .account p { display: inline; margin-left: .4rem; }
}
@media (max-width: 620px) {
  .portal-grid, .dashboard-grid, .content-grid, .inbox, .login-layout { grid-template-columns: minmax(0,1fr); }
  .landing > .eyebrow { margin-top: 2.3rem; }
  .login-hero { min-height: auto; gap: 1.3rem; }
  .login-hero h1 { font-size: 2rem; }
  .kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .inbox-list { border: 0; border-bottom: 1px solid var(--line); }
  #rows { max-height: 12rem; }
  .thread { min-height: 12rem; }
}

.import-card { margin-bottom: 1rem; }
.import-card summary { cursor: pointer; font-weight: 700; font-size: 1.1rem; }
.import-card label { margin: .8rem 0; }
.import-table { table-layout: fixed; white-space: normal; }
.import-table td { white-space: pre-wrap; overflow-wrap: anywhere; vertical-align: top; }
.import-errors { color: #a42e2e; }
#confirm-import { margin-top: 1rem; }
fieldset { border: 0; padding: 0; min-width: 0; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; }
.checkbox-label input { width: auto; }
.ai-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
