:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  color: #14213b;
  background: #f3f5fa;
  --ink: #14213b;
  --muted: #536179;
  --line: #dce2ed;
  --accent: #324ac9;
  --surface: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); letter-spacing: -.03em; line-height: 1.25; }
h2 { font-size: 1.16rem; line-height: 1.35; }
h3 { font-size: 1rem; margin-bottom: .65rem; }
p { color: var(--muted); overflow-wrap: anywhere; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid #6276fa; outline-offset: 3px; }
[hidden] { display: none !important; }

.brand-mark { display: inline-grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; border-radius: .65rem;
  color: white; background: linear-gradient(135deg, #596fff, #7860db); font-weight: 800; letter-spacing: -.07em; }
.login-shell { width: min(59rem, calc(100% - 2.5rem)); min-height: min(32rem, calc(100vh - 3rem));
  margin: max(1.25rem, 9vh) auto; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface);
  border: 1px solid var(--line); border-radius: 1.15rem; overflow: hidden; box-shadow: 0 24px 65px #19285914; }
.login-cover { min-width: 0; background: radial-gradient(circle at 0% 110%, #554fc5 0%, transparent 53%), #15264c;
  color: white; padding: clamp(1.5rem, 5vw, 3.45rem); display: flex; flex-direction: column; justify-content: center; align-items: start; }
.login-cover p { color: #d9e2ff; }
.login-cover .login-brand { font-weight: 700; margin-top: .8rem; }
.login-cover .login-headline { margin: 1.7rem 0 .6rem; color: white; font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 750; line-height: 1.22; }
#sign-in { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: clamp(1.5rem, 5vw, 3.45rem); }
#sign-in h1 { margin-bottom: 1.45rem; }

.console-layout { display: grid; grid-template-columns: 14rem minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; align-self: start; height: 100vh; overflow: auto; background: #111b34; color: #f3f5ff;
  padding: 1.45rem .9rem; border-right: 1px solid #222e4b; }
.brand { display: flex; align-items: center; gap: .65rem; margin: 0 .4rem 2rem; line-height: 1.25; font-weight: 700; }
.brand small { display: block; margin-top: .2rem; color: #b1bdd9; font-size: .7rem; font-weight: 500; }
.side-nav { display: grid; gap: .3rem; }
.side-nav p { margin: .75rem .65rem .25rem; color: #a3b1d0; font-size: .73rem; letter-spacing: .09em; }
.side-nav a { display: flex; align-items: center; gap: .65rem; min-height: 2.65rem; padding: .5rem .65rem; text-decoration: none;
  border: 1px solid transparent; border-radius: .6rem; color: #d5def2; font-size: .91rem; font-weight: 580; }
.side-nav a span { display: grid; place-items: center; width: 1.3rem; flex: none; color: #a5b5ff; }
.side-nav a:hover { background: #233253; }
.side-nav a[aria-current="page"] { color: white; background: #304483; border-color: #46609e; }
.console-main { min-width: 0; }
.topbar { min-height: 4.05rem; background: var(--surface); border-bottom: 1px solid var(--line); padding: .65rem clamp(1rem, 3.5vw, 2.55rem);
  display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.topbar-context, .account { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; min-width: 0; font-size: .88rem; color: var(--muted); }
.topbar-context strong, .account #identity { color: var(--ink); }
.account { justify-content: flex-end; }
.account #identity { overflow-wrap: anywhere; }
.account-mark { display: inline-grid; place-items: center; width: 1.85rem; height: 1.85rem; flex: none; border-radius: 50%;
  background: #e6ebff; color: #253ba0; font-weight: 750; }
.console-body { width: min(100%, 108rem); margin: 0 auto; padding: clamp(1rem, 3vw, 2.55rem); }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.35rem; }
.page-heading p { margin-top: .4rem; }
.page-heading button { flex-shrink: 0; }
.page-panel { display: grid; gap: 1rem; min-width: 0; }
.overview-intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; min-width: 0;
  padding: clamp(1.25rem, 3.5vw, 2.4rem); border-radius: .86rem; background: linear-gradient(115deg, #202e60, #394eb5); color: white; }
.overview-intro h2 { font-size: clamp(1.45rem, 3vw, 2.2rem); }
.overview-intro p { margin-top: .45rem; color: #e4e9ff; }
.primary-link { color: #1e316d; text-decoration: none; background: white; border-radius: .55rem; padding: .55rem .8rem; font-weight: 700;
  display: inline-flex; gap: .55rem; align-items: center; white-space: nowrap; }
.primary-link:hover { background: #e7edff; }
.metric-grid, .work-grid { display: grid; gap: 1rem; min-width: 0; align-items: start; }
.metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: stretch; }
.work-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.work-grid.narrow-right { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: .75rem; display: grid; gap: .25rem;
  min-height: 7.3rem; padding: 1rem 1.15rem; align-content: center; }
.metric span { color: var(--muted); font-size: .87rem; }
.metric strong { font-size: clamp(1.35rem, 2vw, 1.85rem); line-height: 1.22; overflow-wrap: anywhere; }
.metric small { color: var(--muted); font-size: .78rem; }
.card { min-width: 0; background: var(--surface); padding: clamp(1rem, 2.4vw, 1.6rem); border-radius: .75rem; border: 1px solid var(--line); }
.card-heading { margin-bottom: .9rem; }
.card-heading p { font-size: .9rem; margin-top: .27rem; }
.panel-bar { display: flex; align-items: start; justify-content: space-between; flex-wrap: wrap; gap: .55rem; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.quick-grid a { display: grid; gap: .25rem; padding: .75rem; color: var(--ink); text-decoration: none; border: 1px solid var(--line);
  background: #f8faff; border-radius: .65rem; }
.quick-grid a:hover { border-color: #8da1ef; background: #ecf0ff; }
.quick-grid small { color: var(--muted); font-size: .76rem; }
.quick-icon { display: inline-grid; place-items: center; width: 1.65rem; height: 1.65rem; background: #e7ecff; color: var(--accent); border-radius: .4rem; }

form { display: grid; gap: .6rem; }
.card > h2 + form { margin-top: .85rem; }
label { font-weight: 630; font-size: .92rem; }
input, textarea, select, button { font: inherit; padding: .57rem .75rem; border-radius: .5rem; min-height: 2.55rem; }
input, textarea, select { background: white; color: var(--ink); border: 1px solid #aeb9d1; min-width: 0; width: 100%; }
button { background: var(--accent); color: white; border: 1px solid var(--accent); cursor: pointer; font-weight: 640; }
button:hover { background: #293bb2; }
button:disabled { opacity: .58; cursor: wait; }
.secondary { background: white; color: var(--accent); border-color: #bdc7e4; }
.secondary:hover { background: #f0f3ff; }
.compact { min-height: 2.15rem; padding: .32rem .62rem; font-size: .84rem; }
.text-button { padding: 0; min-height: 1.65rem; border: 0; border-radius: .2rem; color: var(--accent); background: transparent;
  text-align: start; overflow-wrap: anywhere; }
.text-button:hover { background: transparent; text-decoration: underline; }
.filter { display: flex; align-items: center; gap: .45rem; }
.filter select { width: auto; }
.lookup-row { display: grid; grid-template-columns: minmax(0, 20rem) auto; gap: .55rem; justify-content: start; }
.inline-form { margin-bottom: .8rem; }
.table-frame { width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: .87rem; }
thead { background: #f0f3fa; color: #36455f; }
th, td { padding: .62rem .55rem; vertical-align: top; overflow-wrap: anywhere; }
th { font-weight: 650; }
td { border-bottom: 1px solid #e8ecf4; }
tbody tr:hover { background: #f9faff; }
.table-frame + button, [id$="-list"] + button { margin-top: .75rem; }
.badge { display: inline-block; width: fit-content; padding: .16rem .49rem; border-radius: .4rem;
  font-size: .76rem; white-space: nowrap; font-weight: 640; }
.badge.neutral { background: #edf1fb; color: #334776; }
.badge.positive { background: #dff4ea; color: #135e45; }
.badge.alert { background: #fbe9ee; color: #8d2345; }
.empty-state { border: 1px dashed #cad3e7; padding: .8rem; border-radius: .55rem; background: #f9fbff; }
.record-detail { margin-top: .9rem; padding: .85rem; border: 1px solid var(--line); background: #f8faff; border-radius: .55rem; }
.record-detail > h3:not(:first-child) { margin-top: .9rem; }
.record-fields { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .3rem .75rem; margin: 0 0 .55rem; }
.record-fields dt { color: var(--muted); font-size: .85rem; }
.record-fields dd { margin: 0; overflow-wrap: anywhere; }
.ticket-controls { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.ticket-assignee-search { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.ticket-assignee-search input { flex: 1 1 12rem; min-width: 0; }
.preserve-lines, #result, #agent-answer, #confirmation-preview, #knowledge-answer { white-space: pre-wrap; overflow-wrap: anywhere; }
#result, #ticket-result, #agent-status, #agent-answer, #knowledge-answer, #approval-status:not(:empty) {
  margin-top: .65rem; }
#result, #knowledge-answer { background: #eef2ff; border-radius: .45rem; padding: .65rem; }
.agent-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.knowledge-card details { margin-top: .85rem; }
.knowledge-card summary { color: var(--accent); cursor: pointer; font-weight: 650; }
.knowledge-card details form { margin-top: .65rem; }
.knowledge-roles { display: flex; flex-wrap: wrap; gap: .4rem .8rem; border: 1px solid var(--line); border-radius: .45rem; }
.knowledge-roles label { display: flex; align-items: center; gap: .3rem; }
.knowledge-roles input { width: auto; min-height: 0; }
.knowledge-sources { padding-inline-start: 1.4rem; }
.knowledge-sources:empty, .agent-actions:empty { display: none; }
.knowledge-sources li + li { margin-top: .5rem; }
#notice { position: fixed; z-index: 3; right: 1rem; bottom: 1rem; width: min(30rem, calc(100% - 2rem)); padding: .8rem;
  background: #e9efff; border: 1px solid #b9c5eb; border-radius: .6rem; color: #20316c; box-shadow: 0 8px 35px #19285922; }
#notice.error { color: #8a263e; background: #fff1f4; border-color: #edbccb; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .work-grid.narrow-right { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 800px) {
  .console-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: .7rem .8rem; }
  .brand { margin: 0 .15rem .55rem; }
  .side-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .side-nav p { display: none; }
  .side-nav a { font-size: .8rem; min-height: 2.2rem; padding: .34rem .3rem; gap: .24rem; }
  .side-nav a span { width: .92rem; }
}
@media (max-width: 600px) {
  .login-shell, .work-grid { grid-template-columns: minmax(0, 1fr); }
  .login-cover .login-headline { margin-top: .9rem; }
  .overview-intro { align-items: flex-start; flex-direction: column; }
  .topbar-context > span { display: none; }
  .topbar { align-items: flex-start; }
  .page-heading { align-items: flex-start; }
  .page-heading button { padding-inline: .43rem; font-size: .8rem; }
  .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-mark { display: none; }
}
