:root {
  color-scheme: light;
  --paper: #f5f3ee;
  --panel: #fffdfa;
  --ink: #17201f;
  --muted: #68716e;
  --line: #d9ddd8;
  --forest: #183b36;
  --mint: #dbece4;
  --coral: #d8704f;
  --amber: #e5ad45;
  --red: #b8493f;
  --radius: 22px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 90% 0, #e4eee8 0, transparent 30%), var(--paper); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.demo-banner { position: fixed; inset: 0 0 auto; z-index: 50; text-align: center; padding: 7px; background: #332f22; color: white; font-size: 12px; }
.demo-banner:not([hidden]) + .setup-shell, .demo-banner:not([hidden]) ~ .app-shell { padding-top: 31px; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 76px; display: flex; align-items: center; gap: 28px; padding: 0 max(24px, 4vw); background: rgba(245,243,238,.92); backdrop-filter: blur(18px); border-bottom: 1px solid rgba(23,32,31,.1); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 44px; min-height: 44px; border: 0; background: none; color: inherit; text-align: left; padding: 0; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: var(--forest); color: #fff; font-weight: 900; font-size: 20px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; }
.brand small { color: var(--muted); margin-top: 2px; font-size: 10px; }
nav { display: flex; gap: 4px; flex: 1; }
nav button, .range-switch button { min-height: 44px; border: 0; border-radius: 999px; padding: 10px 15px; color: var(--muted); background: transparent; font-weight: 750; }
nav button:hover, nav button:focus-visible, nav button.active, .range-switch button.active { color: #fff; background: var(--forest); outline: none; }
.account { display: flex; gap: 15px; align-items: center; color: var(--muted); font-size: 12px; }
.text-button, .icon-button { border: 0; background: transparent; color: var(--forest); font-weight: 800; }
main { max-width: 1440px; margin: auto; padding: 52px max(22px, 4vw) 90px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--coral); font-size: 10px; font-weight: 900; letter-spacing: .19em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(38px, 5vw, 64px); letter-spacing: -.055em; line-height: 1; }
.page-head p:not(.eyebrow) { color: var(--muted); margin-bottom: 0; }
.primary, .secondary { border: 0; border-radius: 13px; padding: 12px 17px; min-height: 44px; font-weight: 850; }
.primary { color: white; background: var(--forest); }
.primary:hover, .primary:focus-visible { background: #24554e; outline: 3px solid rgba(24,59,54,.16); }
.secondary { color: var(--forest); background: var(--mint); }
.card { background: rgba(255,253,250,.93); border: 1px solid rgba(23,32,31,.11); border-radius: var(--radius); box-shadow: 0 18px 55px rgba(40,46,43,.06); }
.history-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.summary-chip { padding: 17px 18px; border-radius: 17px; background: rgba(255,253,250,.8); border: 1px solid rgba(23,32,31,.1); }
.summary-chip span { display: block; color: var(--muted); font-size: 11px; }
.summary-chip strong { display: block; margin-top: 6px; font-size: 20px; }
.history-layout { display: grid; grid-template-columns: minmax(420px,.8fr) minmax(520px,1.2fr); gap: 20px; align-items: start; }
.calendar-card { padding: 23px; position: sticky; top: 96px; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.calendar-head h2 { margin: 0; font-size: 22px; }
.calendar-head button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--forest); }
.weekday-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.weekday-row { margin-bottom: 7px; color: var(--muted); font-size: 11px; text-align: center; }
.calendar-day { position: relative; aspect-ratio: 1; min-width: 42px; border: 1px solid transparent; border-radius: 15px; background: #f2f1ec; color: var(--ink); font-weight: 750; }
.calendar-day.outside { opacity: .35; }
.calendar-day.today { border-color: var(--coral); }
.calendar-day.selected { background: var(--forest); color: white; }
.calendar-day:focus-visible { outline: 3px solid rgba(24,59,54,.25); }
.calendar-day .status-dot { position: absolute; width: 7px; height: 7px; border-radius: 50%; left: 50%; bottom: 7px; transform: translateX(-50%); background: #c9cdc8; }
.calendar-day .status-dot.complete, .legend .complete { background: #438667; }
.calendar-day .status-dot.partial, .legend .partial { background: var(--amber); }
.calendar-day .status-dot.alert, .legend .alert { background: var(--red); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: #c9cdc8; }
.day-panel { padding: 28px; min-height: 590px; }
.day-header { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.day-header h2 { font-size: 32px; margin-bottom: 7px; }
.revision { padding: 7px 10px; height: fit-content; border-radius: 999px; background: var(--mint); color: var(--forest); font-size: 11px; font-weight: 800; }
.daily-kpis { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin: 20px 0; }
.daily-kpis div { padding: 15px; border-radius: 15px; background: #f1f0eb; }
.daily-kpis span, .metric-row span { display: block; color: var(--muted); font-size: 11px; }
.daily-kpis strong { display: block; margin-top: 5px; font-size: 19px; }
.day-sections { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.day-section { padding: 18px; border: 1px solid var(--line); border-radius: 17px; }
.day-section h3 { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; font-size: 15px; }
.day-section h3 span { color: var(--muted); font-size: 10px; font-weight: 600; }
.metric-list, .item-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.metric-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; font-size: 13px; }
.item-list li { padding: 11px; border-radius: 12px; background: #f4f3ef; font-size: 12px; line-height: 1.5; }
.item-list small { display: block; margin-top: 4px; color: var(--muted); }
.recent-section { margin-top: 42px; }
.section-head { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.section-head h2 { margin-bottom: 0; font-size: 24px; }
.section-head > p { color: var(--muted); font-size: 12px; }
.recent-timeline { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 11px; margin-top: 17px; }
.recent-day { min-height: 154px; padding: 16px; border: 1px solid rgba(23,32,31,.11); border-radius: 17px; color: var(--ink); background: rgba(255,253,250,.9); text-align: left; }
.recent-day:hover, .recent-day:focus-visible { border-color: var(--forest); outline: 3px solid rgba(24,59,54,.1); }
.recent-day time, .recent-day small { display: block; color: var(--muted); font-size: 10px; }
.recent-day strong { display: block; margin: 10px 0 5px; font-size: 17px; }
.recent-day .mini-metrics { display: grid; gap: 3px; margin-top: 12px; font-size: 11px; }
.empty-day { min-height: 470px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty-day strong { display: block; color: var(--ink); font-size: 22px; margin-bottom: 7px; }
.range-switch { display: flex; padding: 4px; background: #e8e8e2; border-radius: 999px; }
.coverage-card { display: grid; grid-template-columns: 1fr auto; gap: 20px; padding: 22px; margin-bottom: 18px; }
.coverage-card strong { font-size: 28px; }
.coverage-dots { display: flex; gap: 4px; align-items: center; }
.coverage-dots i { width: 9px; height: 28px; border-radius: 5px; background: #d8dad5; }
.coverage-dots i.filled { background: #438667; }
.trend-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.trend-card { padding: 22px; }
.trend-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.trend-head h2 { margin: 0; font-size: 18px; }
.trend-head strong { color: var(--forest); }
.chart { width: 100%; height: 190px; overflow: visible; }
.chart .grid { stroke: #e3e4df; stroke-width: 1; }
.chart .line { fill: none; stroke: var(--forest); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--coral); }
.chart-empty { height: 190px; display: grid; place-items: center; color: var(--muted); }
.readonly-badge { display: inline-flex; align-items: center; min-height: 34px; padding: 7px 11px; border: 1px solid rgba(24,59,54,.18); border-radius: 999px; color: var(--forest); background: #eef7f2; font-size: 11px; font-weight: 850; white-space: nowrap; }
.memory-toolbar { display: grid; grid-template-columns: minmax(260px,1fr) minmax(150px,220px) auto; gap: 12px; align-items: end; margin-bottom: 12px; padding: 18px; }
.memory-layout { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(300px,.65fr); gap: 20px; align-items: start; }
.memory-card, .source-card { padding: 24px; }
.memory-turns, .source-snapshots { display: grid; gap: 12px; margin-top: 19px; }
.memory-turn { padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: #fff; }
.memory-turn header { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.memory-turn header strong, .memory-turn header small { display: block; }
.memory-turn header small { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.memory-turn header time { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.memory-summary { margin: 14px 0; padding: 13px 14px; border-left: 4px solid var(--coral); border-radius: 11px; background: #fff3ed; line-height: 1.65; font-size: 13px; }
.memory-turn details { border-top: 1px solid var(--line); }
.memory-turn details summary { min-height: 44px; display: flex; align-items: center; color: var(--forest); cursor: pointer; font-size: 12px; font-weight: 850; }
.memory-turn details summary:focus-visible { border-radius: 8px; outline: 3px solid rgba(24,59,54,.13); }
.message { margin-top: 9px; padding: 13px 14px; border-radius: 13px; }
.message b { display: block; margin-bottom: 5px; font-size: 11px; }
.message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; font-size: 12px; }
.user-message { background: #f1f0eb; }
.assistant-message { background: var(--mint); }
.topic-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.topic-list span { padding: 5px 8px; border-radius: 999px; color: var(--muted); background: #f1f0eb; font-size: 10px; }
.source-snapshot { display: grid; gap: 6px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.source-snapshot time, .source-snapshot small { color: var(--muted); font-size: 11px; }
.memory-empty { padding: 28px 20px; border: 1px dashed #c7cec8; border-radius: 16px; color: var(--muted); text-align: center; line-height: 1.65; }
.memory-empty strong { display: block; margin-bottom: 7px; color: var(--ink); }
.memory-empty p { margin-bottom: 0; }
.profile-layout { display: grid; grid-template-columns: minmax(0,.85fr) minmax(480px,1.15fr); gap: 20px; align-items: start; }
.profile-card, .connections-card { padding: 25px; }
.profile-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-top: 20px; }
.profile-field { padding: 15px; border-radius: 14px; background: #f1f0eb; }
.profile-field span { display: block; color: var(--muted); font-size: 11px; }
.profile-field strong { display: block; margin-top: 5px; font-size: 14px; overflow-wrap: anywhere; }
.connection-intro { margin: 19px 0; color: var(--muted); line-height: 1.65; font-size: 13px; }
.agent-kit-card { display: grid; gap: 17px; margin: 0 0 18px; padding: 20px; border: 1px solid rgba(24,59,54,.18); border-radius: 18px; background: linear-gradient(145deg, #f2f8f4, #fffaf5); }
.agent-kit-title { display: flex; gap: 12px; align-items: center; }
.agent-kit-title h3 { margin: 0; font-size: 19px; }
.agent-kit-title .eyebrow { margin-bottom: 5px; }
.agent-kit-mark { display: grid; place-items: center; flex: 0 0 39px; width: 39px; height: 39px; border-radius: 13px; color: #fff; background: var(--forest); font-size: 20px; font-weight: 900; }
.agent-kit-copy > p { margin: 13px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.agent-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.agent-badges span { padding: 6px 9px; border: 1px solid rgba(24,59,54,.13); border-radius: 999px; color: var(--forest); background: rgba(255,255,255,.72); font-size: 10px; font-weight: 850; }
.download-button { display: inline-grid; place-items: center; width: 100%; text-decoration: none; text-align: center; }
.new-machine-guide { border-top: 1px solid rgba(24,59,54,.13); padding-top: 13px; color: var(--muted); font-size: 12px; }
.new-machine-guide summary { min-height: 44px; display: flex; align-items: center; color: var(--forest); cursor: pointer; font-weight: 850; }
.new-machine-guide summary:focus-visible { border-radius: 8px; outline: 3px solid rgba(24,59,54,.13); }
.new-machine-guide ol { margin: 5px 0 0; padding-left: 21px; line-height: 1.7; }
.new-machine-guide li + li { margin-top: 5px; }
.connection-form { display: grid; grid-template-columns: minmax(180px,1fr) 120px; gap: 12px; align-items: end; padding: 18px; border-radius: 17px; background: #f1f0eb; }
.connection-form .primary { grid-column: 1 / -1; }
.check-label { min-height: 44px; display: flex; align-items: center; gap: 9px; grid-column: 1 / -1; }
.check-label input { width: 20px; min-height: 20px; margin: 0; }
.secure-pill { padding: 7px 10px; border-radius: 999px; color: var(--forest); background: var(--mint); font-size: 10px; font-weight: 850; }
.connection-list { display: grid; gap: 10px; }
.connection-item { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 15px; border: 1px solid var(--line); border-radius: 15px; }
.connection-item.revoked { opacity: .58; }
.connection-item strong, .connection-item small { display: block; }
.connection-item small { margin-top: 4px; color: var(--muted); line-height: 1.5; }
.danger-button { min-height: 42px; border: 1px solid rgba(184,73,63,.25); border-radius: 11px; padding: 8px 12px; color: var(--red); background: #fff8f6; font-weight: 800; }
.profile-logout { margin-top: 20px; }
.token-warning { padding: 13px 15px; border-left: 4px solid var(--coral); border-radius: 12px; color: #6a3525; background: #fff0e9; line-height: 1.55; }
.copy-button { width: 100%; margin: 8px 0 18px; }
code { font-family: "Cascadia Code", Consolas, monospace; font-size: .95em; }
.setup-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 20%, rgba(216,112,79,.09), transparent 27%), radial-gradient(circle at 85% 75%, rgba(24,59,54,.1), transparent 30%); }
.setup-card { width: min(460px,100%); padding: 34px; border-radius: 26px; background: rgba(255,253,250,.96); border: 1px solid rgba(23,32,31,.11); box-shadow: 0 26px 80px rgba(30,44,39,.12); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { font-size: 15px; }
.login-brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.setup-card h1 { margin: 10px 0 12px; font-size: 34px; line-height: 1.12; letter-spacing: -.045em; }
.setup-card .login-intro { margin-bottom: 0; color: var(--muted); line-height: 1.7; }
label { display: block; color: var(--muted); font-size: 12px; font-weight: 750; }
label span { font-weight: 500; }
input, textarea, select { width: 100%; min-height: 44px; margin-top: 7px; padding: 12px 13px; color: var(--ink); background: #fff; border: 1px solid #cdd2cd; border-radius: 12px; }
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(24,59,54,.13); border-color: var(--forest); }
#loginForm, #otpForm { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 26px; }
#loginForm[hidden], #otpForm[hidden] { display: none; }
#loginForm .primary, #otpForm .primary { width: 100%; }
#loginOtp { letter-spacing: .35em; font-variant-numeric: tabular-nums; }
.otp-entry-link { display: block; width: 100%; min-height: 44px; margin-top: 10px; border: 1px solid var(--line); border-radius: 13px; background: transparent; cursor: pointer; text-align: center; }
.otp-entry-link[hidden] { display: none; }
.otp-email-hint { margin: 0; padding: 11px 13px; border-radius: 12px; color: var(--forest); background: var(--mint); font-size: 12px; }
.setup-card > .demo-link:last-child { display: block; margin-top: 18px; text-align: center; font-size: 12px; }
.status-text { min-height: 22px; margin-top: 15px; }
.demo-link { color: var(--forest); font-weight: 800; }
dialog { width: min(620px,calc(100% - 28px)); max-height: calc(100vh - 40px); overflow: auto; border: 1px solid var(--line); border-radius: 24px; padding: 25px; color: var(--ink); background: var(--panel); box-shadow: 0 35px 110px rgba(10,20,18,.25); }
dialog::backdrop { background: rgba(17,27,25,.55); backdrop-filter: blur(5px); }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.dialog-head h2 { margin: 0; font-size: 26px; }
.icon-button { width: 42px; height: 42px; border-radius: 50%; font-size: 25px; }
.icon-button:hover { background: var(--mint); }
.form-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 13px; margin: 16px 0; }
.form-help { margin: 14px 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.change-summary { display: grid; gap: 10px; }
.change-row { border-left: 4px solid var(--amber); border-radius: 12px; padding: 13px 15px; background: #f2f1ed; }
.change-row.delete { border-left-color: var(--red); }
.change-row.update { border-left-color: #4b7390; }
.change-row strong { display: block; margin-bottom: 6px; }
.change-values { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .topbar { min-height: 68px; padding: 0 15px; gap: 10px; }
  .brand span:last-child, .account span { display: none; }
  nav { justify-content: center; }
  nav button { padding: 10px 12px; }
  main { padding: 30px 14px 78px; }
  .page-head { align-items: start; }
  .history-layout { grid-template-columns: 1fr; }
  .calendar-card { position: static; }
  .day-panel { min-height: 0; }
  .trend-grid { grid-template-columns: 1fr; }
  .memory-layout { grid-template-columns: 1fr; }
  .profile-layout { grid-template-columns: 1fr; }
  .recent-timeline { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 560px) {
  .topbar { align-items: center; }
  .brand-mark { width: 38px; height: 38px; }
  .account { display: none; }
  nav { justify-content: end; }
  nav button { font-size: 12px; padding: 9px 10px; }
  .page-head { display: grid; }
  .page-head .primary { width: 100%; }
  h1 { font-size: 42px; }
  .calendar-card, .day-panel { padding: 16px; border-radius: 18px; }
  .calendar-day { min-width: 0; border-radius: 11px; font-size: 12px; }
  .legend { gap: 8px; }
  .daily-kpis { grid-template-columns: repeat(2,1fr); }
  .history-summary { grid-template-columns: repeat(2,1fr); }
  .recent-timeline { grid-template-columns: 1fr 1fr; }
  .recent-day { min-height: 136px; }
  .day-sections { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .coverage-card { grid-template-columns: 1fr; }
  .memory-toolbar { grid-template-columns: 1fr; }
  .memory-toolbar .primary { width: 100%; }
  .memory-card, .source-card { padding: 16px; border-radius: 18px; }
  .memory-turn header { display: grid; }
  .coverage-dots { overflow: hidden; }
  .setup-shell { padding: 14px; }
  .setup-card { padding: 26px 21px; border-radius: 22px; }
  .setup-card h1 { font-size: 30px; }
  .login-brand { margin-bottom: 28px; }
  .change-values { grid-template-columns: 1fr; }
  .profile-card, .connections-card { padding: 18px; border-radius: 18px; }
  .connection-form { grid-template-columns: 1fr; }
  .connection-form .check-label, .connection-form .primary { grid-column: auto; }
  .profile-grid { grid-template-columns: 1fr; }
}
