:root {
  --bg: #f5f8f7;
  --surface: #ffffff;
  --surface-2: #edf4f2;
  --surface-3: #e3efec;
  --text: #122220;
  --muted: #66807b;
  --line: #d8e5e1;
  --line-strong: #bed2cd;
  --teal: #087f7a;
  --teal-strong: #05625f;
  --teal-soft: #dff2ef;
  --teal-glow: rgba(8, 127, 122, .18);
  --orange: #b45d2a;
  --orange-soft: #fff0e6;
  --green: #18805b;
  --green-soft: #e0f3ea;
  --red: #b94a55;
  --red-soft: #fbe7ea;
  --yellow: #9a7415;
  --yellow-soft: #fff5d8;
  --shadow-sm: 0 1px 2px rgba(14, 48, 42, .05), 0 3px 12px rgba(14, 48, 42, .04);
  --shadow-md: 0 12px 28px rgba(14, 48, 42, .1), 0 2px 8px rgba(14, 48, 42, .06);
  --radius: 12px;
  --rail: 260px;
  --topbar: 68px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0e1918;
  --surface: #152422;
  --surface-2: #1a2c2a;
  --surface-3: #223734;
  --text: #e8f2ef;
  --muted: #9ab3ad;
  --line: #29413d;
  --line-strong: #395750;
  --teal: #46bdb2;
  --teal-strong: #6bd4c9;
  --teal-soft: #173d3a;
  --teal-glow: rgba(70, 189, 178, .2);
  --orange: #e59a68;
  --orange-soft: #3b2a20;
  --green: #72d4a9;
  --green-soft: #193b30;
  --red: #ed9ca7;
  --red-soft: #40272c;
  --yellow: #e7c565;
  --yellow-soft: #403719;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .22), 0 3px 12px rgba(0, 0, 0, .1);
  --shadow-md: 0 18px 34px rgba(0, 0, 0, .34), 0 3px 8px rgba(0, 0, 0, .2);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
input, textarea, select { color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; outline: 0; }
input:focus, textarea:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-glow); }
textarea { resize: vertical; }
a { color: inherit; text-decoration: none; }

.app { min-height: 100vh; }
.shell { display: flex; min-height: 100vh; }
.rail { width: var(--rail); flex: 0 0 var(--rail); background: var(--surface); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; transition: width .2s ease, transform .2s ease; }
.brand { display: flex; align-items: center; gap: 11px; padding: 3px 10px 20px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; font-size: 17px; font-weight: 800; border-radius: 12px; background: linear-gradient(135deg, var(--teal), #55bcb0); box-shadow: 0 8px 18px var(--teal-glow); }
.brand-name { font-weight: 750; letter-spacing: -.02em; font-size: 17px; }
.brand-sub { color: var(--muted); font-size: 11px; }
.nav-section { color: var(--muted); text-transform: uppercase; letter-spacing: .09em; font-size: 10px; font-weight: 750; padding: 16px 10px 7px; }
.nav { display: grid; gap: 3px; }
.nav-link { min-height: 44px; display: flex; align-items: center; gap: 11px; padding: 0 11px; border-radius: 9px; color: var(--muted); font-weight: 620; position: relative; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--teal-soft); color: var(--teal-strong); }
.nav-link.active::before { content: ""; position: absolute; inset-inline-start: -14px; top: 8px; bottom: 8px; width: 3px; background: var(--teal); border-radius: 0 4px 4px 0; }
.nav-icon { width: 18px; height: 18px; flex: 0 0 18px; }
.rail-spacer { flex: 1; }
.rail-footer { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 9px; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: #fff; background: var(--teal); font-weight: 750; font-size: 12px; flex: 0 0 auto; }
.user-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--muted); font-size: 11px; }
.main { min-width: 0; flex: 1; }
.topbar { height: var(--topbar); background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 18px; padding: 0 28px; position: sticky; top: 0; z-index: 10; }
.mobile-menu { display: none; }
.page-heading { min-width: 175px; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 650; }
.page-title { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.workspace-select { min-width: 190px; height: 40px; padding: 0 11px; }
.icon-btn, .mobile-menu { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid transparent; color: var(--muted); background: transparent; border-radius: 9px; }
.icon-btn:hover, .mobile-menu:hover { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.avatar-button { display: flex; align-items: center; gap: 7px; border: 0; background: transparent; padding: 0 2px; color: var(--text); }
.avatar-button .avatar { width: 34px; height: 34px; }
.content { padding: 28px; max-width: 1540px; margin: 0 auto; }
.view { display: grid; gap: 22px; }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.view-title { margin: 0; font-size: 25px; line-height: 1.2; letter-spacing: -.04em; }
.view-description { margin: 5px 0 0; color: var(--muted); max-width: 700px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn { min-height: 40px; border: 1px solid transparent; border-radius: 8px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; transition: transform .15s ease, background .15s ease, border .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { color: #fff; background: var(--teal); box-shadow: 0 4px 10px var(--teal-glow); }
.btn-primary:hover { background: var(--teal-strong); }
.btn-secondary { color: var(--text); background: var(--surface); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn-quiet { color: var(--muted); background: transparent; }
.btn-danger { color: var(--red); background: var(--red-soft); border-color: transparent; }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.section-head h2, .section-head h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.section-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.label { display: block; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }
.field { display: grid; gap: 6px; }
.field input, .field textarea, .field select { width: 100%; min-height: 42px; padding: 9px 11px; }
.field textarea { min-height: 110px; }
.field legend { padding: 0; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.check-option { min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--surface); font-size: 12px; }
.check-option input { accent-color: var(--teal); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-stack { display: grid; gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 17px 18px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { margin-top: 3px; font-size: 28px; line-height: 1.15; font-weight: 760; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.stat-meta { margin-top: 6px; font-size: 11px; color: var(--teal-strong); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 16px; align-items: start; }
.table-wrap { overflow-x: auto; }
.data-table { border-collapse: collapse; width: 100%; min-width: 620px; }
.data-table th { color: var(--muted); text-align: start; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; font-weight: 750; padding: 0 13px 10px; }
.data-table td { border-top: 1px solid var(--line); padding: 13px; vertical-align: middle; }
.data-table tr:hover td { background: var(--surface-2); }
.task-title { font-weight: 700; }
.task-meta { margin-top: 2px; color: var(--muted); font-size: 11px; }
.task-link { display: block; color: inherit; }
.task-link:hover .task-title { color: var(--teal-strong); }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 8px; font-size: 11px; line-height: 1; font-weight: 750; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-teal { color: var(--teal-strong); background: var(--teal-soft); }
.badge-green { color: var(--green); background: var(--green-soft); }
.badge-yellow { color: var(--yellow); background: var(--yellow-soft); }
.badge-orange { color: var(--orange); background: var(--orange-soft); }
.badge-red { color: var(--red); background: var(--red-soft); }
.badge-neutral { color: var(--muted); background: var(--surface-2); }
.empty { display: grid; place-items: center; text-align: center; padding: 42px 22px; color: var(--muted); }
.empty-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; color: var(--teal); background: var(--teal-soft); margin-bottom: 12px; }
.empty-title { color: var(--text); font-weight: 750; }
.empty p { max-width: 350px; margin: 4px auto 16px; font-size: 12px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.35s infinite; border-radius: 7px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.banner { position: relative; overflow: hidden; padding: 23px; color: #eafffb; background: linear-gradient(125deg, #075e5e, #087f7a 52%, #4bb8a9); border: 0; }
.banner::after { content: ""; position: absolute; width: 280px; height: 280px; right: -85px; top: -150px; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; box-shadow: 0 0 0 35px rgba(255,255,255,.04), 0 0 0 70px rgba(255,255,255,.04); }
.banner h2 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.banner p { margin: 6px 0 0; max-width: 650px; color: rgba(234,255,251,.79); }
.banner .btn { margin-top: 17px; color: var(--teal-strong); background: #eafffb; }
.filterbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.filterbar input, .filterbar select { min-height: 40px; padding: 8px 11px; }
.filterbar input { min-width: 220px; }
.task-detail { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 16px; align-items: start; }
.detail-main, .detail-side { display: grid; gap: 16px; }
.detail-title { font-size: 28px; margin: 0; letter-spacing: -.045em; line-height: 1.2; }
.detail-meta { margin-top: 7px; display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.timeline { display: grid; gap: 14px; }
.message { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 9px; }
.message-body { padding: 11px 13px; background: var(--surface-2); border-radius: 10px; border-top-left-radius: 4px; }
.message-author { font-size: 11px; font-weight: 750; }
.message-kind { color: var(--muted); font-size: 10px; margin-inline-start: 5px; }
.message-content { margin-top: 3px; white-space: pre-wrap; }
.message-time { color: var(--muted); font-size: 10px; margin-top: 5px; }
.review-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.review-step { padding: 9px 8px; border-radius: 8px; background: var(--surface-2); color: var(--muted); text-align: center; font-size: 10px; font-weight: 700; }
.review-step.done { color: var(--teal-strong); background: var(--teal-soft); }
.review-step.current { color: var(--text); border: 1px solid var(--teal); }
.ref-grid { display: grid; gap: 10px; }
.ref-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 11px 12px; background: var(--surface-2); border-radius: 8px; }
.ref-label { color: var(--muted); font-size: 11px; }
.ref-value { margin-top: 2px; overflow-wrap: anywhere; }
.ref-value.empty-ref { color: var(--muted); font-style: italic; }
.poster-summary { display: grid; gap: 14px; }
.poster-packet-summary { border: 1px solid var(--line); border-radius: 12px; padding: 12px; overflow-wrap: anywhere; }
.poster-packet { max-height: 260px; margin: 10px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); white-space: pre-wrap; overflow: auto; overflow-wrap: anywhere; font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
details { margin-top: 14px; }
details > summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.conversation-input { display: flex; gap: 8px; align-items: flex-end; }
.conversation-input textarea { flex: 1; min-height: 46px; max-height: 120px; }
.job-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.job-row:first-child { padding-top: 0; border-top: 0; }
.job-title { font-weight: 700; }
.job-sub { color: var(--muted); font-size: 11px; margin-top: 3px; }
.job-actions { display: flex; gap: 6px; align-items: center; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(3, 24, 22, .48); display: grid; place-items: center; padding: 18px; }
.modal { width: min(620px, 100%); max-height: min(750px, calc(100vh - 36px)); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-md); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 20px; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 8% 14%, var(--teal-soft), transparent 30%), var(--bg); }
.login-card { width: min(420px, 100%); padding: 28px; }
.login-mark { margin-bottom: 18px; }
.login-title { margin: 0; font-size: 26px; letter-spacing: -.045em; }
.login-copy { color: var(--muted); margin: 5px 0 24px; }
.login-note { margin-top: 16px; padding: 11px 12px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 11px; }
.error-box { padding: 12px 13px; border-radius: 9px; background: var(--red-soft); color: var(--red); font-size: 12px; }
.success-box { padding: 12px 13px; border-radius: 9px; background: var(--green-soft); color: var(--green); font-size: 12px; }
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; width: min(340px, calc(100vw - 36px)); }
.toast { padding: 12px 14px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: 8px; box-shadow: var(--shadow-md); font-size: 12px; }
.toast.error { border-left-color: var(--red); }
.drawer-overlay { display: none; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1050px) {
  .rail { width: 76px; flex-basis: 76px; padding-inline: 9px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand-copy, .nav-section, .nav-link span, .rail-footer .user-copy, .rail-footer .toggle-copy { display: none; }
  .nav-link { justify-content: center; padding-inline: 0; }
  .nav-link.active::before { inset-inline-start: -9px; }
  .user-chip { justify-content: center; padding-inline: 0; }
  .rail-footer { justify-items: center; }
  .dashboard-grid, .task-detail { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .rail { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(82vw, 280px); transform: translateX(-105%); box-shadow: var(--shadow-md); padding: 18px 14px; }
  .rail.open { transform: translateX(0); }
  .brand { justify-content: flex-start; padding-inline: 10px; }
  .brand-copy, .nav-section, .nav-link span, .rail-footer .user-copy, .rail-footer .toggle-copy { display: block; }
  .nav-link { justify-content: flex-start; padding-inline: 11px; }
  .nav-link.active::before { inset-inline-start: -14px; }
  .user-chip { justify-content: flex-start; padding-inline: 8px; }
  .rail-footer { justify-items: stretch; }
  .mobile-menu { display: grid; }
  .drawer-overlay { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(3, 24, 22, .42); }
  .topbar { height: 62px; padding: 0 14px; gap: 10px; }
  .page-heading { min-width: 0; }
  .page-title { font-size: 17px; white-space: nowrap; }
  .eyebrow, .workspace-select { display: none; }
  .topbar-actions { gap: 2px; }
  .avatar-button .user-copy { display: none; }
  .content { padding: 20px 14px 34px; }
  .view-head { display: grid; }
  .head-actions { justify-content: flex-start; }
  .view-title { font-size: 23px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 25px; }
  .field-row { grid-template-columns: 1fr; }
  .card-pad { padding: 16px; }
  .banner { padding: 18px; }
  .detail-title { font-size: 24px; }
  .review-strip { grid-template-columns: repeat(2, 1fr); }
  .filterbar input { min-width: 0; width: 100%; flex: 1 1 100%; }
  .filterbar select { flex: 1; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
.simulation-panel { overflow-wrap: anywhere; min-inline-size: 0; }
.simulation-panel .btn { min-block-size: 44px; white-space: normal; }
.simulation-panel .job-actions { flex-wrap: wrap; }
.simulation-panel select { max-inline-size: 100%; font-size: 16px; }
