:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #18201d;
  background: #eef1ef;
  font-size: 15px;
  --ink: #18201d;
  --muted: #65706b;
  --line: #d9dfdc;
  --surface: #ffffff;
  --surface-soft: #f5f7f6;
  --green: #176b4d;
  --green-soft: #e6f3ed;
  --coral: #c5543c;
  --amber: #a86916;
  --sidebar: #1c2421;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #eef1ef; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; color: #f1f5f3; background: var(--sidebar); display: flex; flex-direction: column; }
.brand { display: flex; gap: 11px; align-items: center; padding: 0 8px 22px; border-bottom: 1px solid #34403b; }
.brand strong { display: block; font-size: 14px; }
.brand small { color: #98a69f; display: block; margin-top: 2px; font-size: 11px; }
.brand-mark { display: inline-grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; border-radius: 6px; color: #fff; background: var(--green); font-weight: 750; }
nav { display: flex; flex-direction: column; gap: 3px; padding-top: 18px; }
nav button, .sidebar-action { border: 0; color: #bfc9c4; background: transparent; min-height: 42px; padding: 0 10px; border-radius: 6px; display: flex; gap: 10px; align-items: center; text-align: left; }
nav button svg, .sidebar-action svg { width: 18px; height: 18px; flex: 0 0 18px; }
nav button:hover, nav button.active, .sidebar-action:hover { color: #fff; background: #2b3732; }
.nav-badge { margin-left: auto; color: #f0c978; font-size: 10px; }
.nav-divider { border-top: 1px solid #34403b; margin: 10px 8px; }
.sidebar-action { margin-top: auto; width: 100%; }
.workspace { min-width: 0; }
.topbar { height: 86px; padding: 18px 34px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.topbar p { margin: 0 0 3px; color: var(--green); text-transform: uppercase; font-size: 10px; font-weight: 700; }
.topbar h1 { margin: 0; font-size: 22px; line-height: 1.2; }
.system-state { color: var(--muted); display: flex; gap: 8px; align-items: center; font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #33a06f; box-shadow: 0 0 0 3px #e0f3e9; }
.content { width: min(1240px, 100%); padding: 28px 34px 48px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 20px; }
.toolbar .grow { flex: 1; min-width: 220px; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 12px; margin-bottom: 28px; }
.metric, .item-card { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.metric { padding: 17px; min-height: 102px; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 12px; font-size: 28px; }
.metric.pending strong { color: var(--amber); }
.section { margin: 0 0 30px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section h2 { margin: 0; font-size: 16px; }
.section-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.grid-two { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(360px, 1.2fr); gap: 22px; }
.form-panel { background: var(--surface); border: 1px solid var(--line); padding: 18px; border-radius: 7px; }
.form-panel h2 { margin: 0 0 16px; font-size: 15px; }
.field { display: grid; gap: 6px; margin-bottom: 13px; }
.field label { color: #3f4945; font-size: 12px; font-weight: 650; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
input, textarea, select { width: 100%; border: 1px solid #c9d1cd; border-radius: 5px; background: #fff; color: var(--ink); padding: 9px 10px; outline: none; }
textarea { min-height: 112px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.button { border: 1px solid #bec7c2; border-radius: 5px; min-height: 38px; padding: 7px 12px; color: var(--ink); background: #fff; display: inline-flex; gap: 7px; align-items: center; justify-content: center; }
.button:hover { background: var(--surface-soft); }
.button.primary { color: #fff; background: var(--green); border-color: var(--green); }
.button.danger { color: #a43e2a; border-color: #e0b7af; }
.button.small { min-height: 31px; padding: 4px 9px; font-size: 12px; }
.button.wide { width: 100%; }
.list { display: grid; gap: 9px; }
.item-card { padding: 14px 16px; }
.item-card header { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.item-card h3 { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.item-card p { color: var(--muted); margin: 7px 0 0; line-height: 1.55; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.pill { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 7px; border-radius: 999px; color: #345047; background: var(--green-soft); font-size: 10px; white-space: nowrap; }
.pill.warn { color: #78500f; background: #fff1d5; }
.pill.red { color: #923825; background: #fbe8e4; }
.empty { border: 1px dashed #bdc8c2; color: var(--muted); padding: 28px; text-align: center; border-radius: 7px; }
.code-block { white-space: pre-wrap; overflow-wrap: anywhere; background: #f5f7f6; border: 1px solid var(--line); border-radius: 5px; padding: 12px; max-height: 380px; overflow: auto; font: 12px/1.65 ui-monospace, SFMono-Regular, monospace; }
.search-result { border-left: 3px solid var(--green); }
.search-result[data-level="L2"] { border-left-color: var(--amber); }
.search-result[data-level="L3"] { border-left-color: var(--coral); }
.token-once { background: #fff8e8; border: 1px solid #e8c986; padding: 12px; border-radius: 5px; word-break: break-all; font-family: ui-monospace, monospace; }
.toast { position: fixed; right: 24px; bottom: 22px; z-index: 20; max-width: min(420px, calc(100vw - 48px)); color: #fff; background: #26322d; border-radius: 6px; padding: 11px 14px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #9f3e2b; }
.muted { color: var(--muted); }
.codex-layout { min-height: calc(100vh - 162px); display: grid; grid-template-columns: 270px minmax(0, 1fr); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface); }
.conversation-pane { padding: 14px; background: #f5f7f6; border-right: 1px solid var(--line); }
.conversation-pane .button { width: 100%; margin-bottom: 12px; }
.conversation-list { display: grid; gap: 5px; }
.conversation-list button { width: 100%; border: 1px solid transparent; background: transparent; padding: 9px; border-radius: 5px; text-align: left; color: var(--ink); }
.conversation-list button:hover, .conversation-list button.active { background: #fff; border-color: var(--line); }
.conversation-list strong { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-list small { color: var(--muted); font-size: 10px; }
.chat-surface { min-width: 0; display: grid; grid-template-rows: auto minmax(300px, 1fr) auto; }
.chat-header { min-height: 58px; padding: 12px 17px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.chat-header h2 { margin: 0; font-size: 14px; }
.chat-header p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.messages { padding: 20px; overflow: auto; display: flex; flex-direction: column; gap: 15px; }
.message { max-width: min(760px, 88%); line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user { align-self: flex-end; color: #fff; background: var(--green); border-radius: 7px 7px 2px 7px; padding: 10px 13px; }
.message.assistant { align-self: flex-start; }
.message.system { align-self: center; color: var(--muted); font-size: 11px; }
.approval-panel { border: 1px solid #e0bd77; background: #fff9eb; border-radius: 6px; padding: 12px; font-size: 12px; }
.approval-panel pre { max-height: 180px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.composer { border-top: 1px solid var(--line); padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: end; }
.composer textarea { min-height: 48px; max-height: 160px; }
.source-strip { margin-top: 8px; color: var(--muted); font-size: 10px; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #e9eeeb; }
.login-shell { width: min(820px, 100%); min-height: 420px; display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: 0 18px 50px rgba(35, 48, 42, .12); }
.login-brand { padding: 54px; color: #fff; background: #1d2a25; display: flex; flex-direction: column; justify-content: center; }
.login-brand .brand-mark { background: #2d8a66; margin-bottom: 28px; }
.login-brand h1 { margin: 0; font-size: 28px; }
.login-brand p { color: #adbbb4; margin: 10px 0 0; }
.login-form { padding: 54px; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.login-form label { font-size: 13px; font-weight: 650; }
.form-error { min-height: 20px; color: #a63d29; font-size: 12px; margin: 0; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand > span:last-child, nav button span:not(.nav-badge), .sidebar-action span { display: none; }
  nav button, .sidebar-action { justify-content: center; }
  .nav-badge { position: absolute; margin: -26px 0 0 28px; font-size: 0; width: 6px; height: 6px; border-radius: 50%; background: #e7b957; }
  .metrics { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
  .grid-two { grid-template-columns: 1fr; }
  .codex-layout { grid-template-columns: 210px minmax(0, 1fr); }
}

@media (max-width: 620px) {
  .app-shell { display: block; padding-bottom: 68px; }
  .sidebar { position: fixed; z-index: 10; inset: auto 0 0; width: 100%; height: 66px; padding: 7px; flex-direction: row; border-top: 1px solid #36423d; }
  .brand, .sidebar-action, .nav-divider, nav button:nth-of-type(n+7) { display: none; }
  nav { width: 100%; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
  nav button { min-width: 0; padding: 0; }
  .topbar { height: 74px; padding: 14px 18px; }
  .topbar h1 { font-size: 19px; }
  .system-state { display: none; }
  .content { padding: 20px 18px 36px; }
  .metrics { grid-template-columns: repeat(2, minmax(100px, 1fr)); }
  .field-row { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 180px; padding: 28px; }
  .login-brand .brand-mark { margin-bottom: 18px; }
  .login-form { padding: 32px 28px; }
  .codex-layout { display: block; min-height: 620px; }
  .conversation-pane { border-right: 0; border-bottom: 1px solid var(--line); max-height: 160px; overflow: auto; }
  .chat-surface { min-height: 500px; }
}
