:root {
  --bg: #f4f6f8; --panel: #ffffff; --ink: #18232e; --muted: #5d6b78; --line: #dde3e9; --brand: #0f3d5e; --brand-2: #1d6a99;
  --accent: #f5b82e; --ok: #1f8a4c; --ok-bg: #e3f4ea; --warn: #a86400; --warn-bg: #fff2d6; --bad: #b42318; --bad-bg: #fde7e5;
  --info: #1d5fa8; --info-bg: #e3eefb; --chip: #eef1f4; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 10px; font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1419; --panel: #172029; --ink: #e5ebf0; --muted: #98a6b3; --line: #2b3742; --brand: #12476d; --brand-2: #5aa7d8;
    --ok-bg: #12301f; --warn-bg: #3a2a0a; --bad-bg: #3a1512; --info-bg: #13283f; --chip: #222d37; --ok: #4cc27f; --warn: #f0b04a; --bad: #ff7b6e; --info: #7db6f0; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }
.hidden { display: none !important; }
.topbar { position: sticky; top: var(--bar-off, 0px); z-index: 20; background: var(--brand); color: #fff; display: flex; align-items: center; gap: 12px; padding: 8px 16px; flex-wrap: wrap; }
.topbar .logo { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.topbar .logo img { width: 26px; height: 26px; }
.topbar select { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: 6px; padding: 4px 8px; max-width: 260px; }
.topbar select option { color: #000; }
.topbar .spacer { flex: 1; }
.sync { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #4cd28a; display: inline-block; }
.dot.off { background: #f5b82e; }
.topbar .btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; }
.nav { display: flex; gap: 2px; background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; position: sticky; top: calc(var(--bar-off, 0px) + var(--top-h, 46px)); z-index: 15; }
.nav button { background: none; border: 0; padding: 11px 12px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.nav button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.nav .badge { background: var(--bad); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
main { padding: 16px; max-width: 1500px; margin: 0 auto; }
h1 { font-size: 21px; margin: 4px 0 12px; } h2 { font-size: 17px; margin: 18px 0 8px; } h3 { font-size: 15px; margin: 14px 0 6px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 6px 12px; cursor: pointer; }
.btn:hover { border-color: var(--brand-2); }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 8px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input[type=url], input:not([type]), select, textarea {
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; background: var(--panel); min-width: 0; }
textarea { width: 100%; min-height: 64px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); cursor: default; }
.kpi .v { font-size: 26px; font-weight: 700; } .kpi .l { color: var(--muted); font-size: 13px; }
.kpi.click { cursor: pointer; } .kpi.click:hover { border-color: var(--brand-2); }
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); max-height: calc(100vh - 230px); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--chip); font-weight: 600; z-index: 2; cursor: pointer; user-select: none; }
td.wrap { white-space: normal; min-width: 220px; }
tr:hover td { background: rgba(29,106,153,.05); }
tr.group td { background: var(--chip); font-weight: 600; }
td.edit { cursor: text; } td.edit:hover { outline: 1px dashed var(--brand-2); outline-offset: -2px; }
td input, td select { width: 100%; padding: 3px 5px; }
.chip { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12px; background: var(--chip); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.info { background: var(--info-bg); color: var(--info); }
.bar { height: 7px; background: var(--chip); border-radius: 4px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--brand-2); }
.flag { color: var(--warn); font-weight: 700; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 100%); background: var(--panel); border-left: 1px solid var(--line); z-index: 40;
  box-shadow: -8px 0 24px rgba(0,0,0,.15); overflow-y: auto; padding: 16px; }
.drawer .close { position: absolute; right: 12px; top: 10px; }
.modal { position: fixed; inset: 0; background: rgba(10,20,30,.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal .box { background: var(--panel); border-radius: 12px; padding: 18px; width: min(460px, 100%); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #18232e; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 80; max-width: 90vw; }
.toast.err { background: var(--bad); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs a, .thumbs .t { width: 92px; height: 92px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 11px; text-align: center; background: var(--chip); color: var(--muted); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { border-bottom: 1px solid var(--line); padding: 8px 0; }
.cards { display: grid; gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.card .t { font-weight: 600; } .card .meta { color: var(--muted); font-size: 12.5px; margin: 4px 0 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 7px 10px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; } .seg button.on { background: var(--brand-2); color: #fff; }
.login { max-width: 400px; margin: 8vh auto; }
.login .panel { padding: 22px; }
.login .demo { font-size: 12.5px; color: var(--muted); margin-top: 14px; line-height: 1.6; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.ms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.mapping td select { min-width: 160px; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
@media (max-width: 760px) {
  main { padding: 10px; } .grid2 { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 8px 10px; } .topbar select { max-width: 150px; }
  .hide-sm { display: none; }
  .tbl-wrap { max-height: none; }
}
/* Work Readiness (Release 3 AI edition) */
.rd-panel { border-left: 4px solid var(--bad); }
.rd-panel.calm { border-left-color: var(--ok); }
.rd-alerts { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.rd-alerts li { background: var(--chip); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.rd-alerts .meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.rd-ask { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.rd-ask input { flex: 1 1 260px; min-width: 0; }
.rd-answer { white-space: pre-wrap; background: var(--chip); border-radius: 8px; padding: 10px 12px; margin-top: 8px; font-size: 13px; line-height: 1.5; }
.rd-check { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid var(--line, #ddd); }
.rd-check:last-child { border-bottom: 0; }
.rd-src { font-size: 12px; color: var(--muted); }
.rd-src q { font-style: italic; }
.ai-badge { font-size: 10px; letter-spacing: .04em; text-transform: uppercase; border: 1px solid currentColor; border-radius: 3px; padding: 0 4px; color: var(--info); }
@media (max-width: 640px) { .rd-check { grid-template-columns: 1fr; } }
/* Help (read-only user guide) */
.help-layout{display:grid;grid-template-columns:240px minmax(0,1fr);gap:14px;align-items:start}
.help-toc{position:sticky;top:8px;max-height:calc(100vh - 24px);overflow:auto;font-size:14px}.help-toc ol{margin:8px 0 0;padding-left:20px;display:grid;gap:4px}
.help-body{max-width:860px;line-height:1.6}.help-body h1{margin-top:0}.help-body h2{margin-top:28px;padding-top:8px;border-top:1px solid var(--line, #ddd)}.help-body h3{margin-top:18px}
.help-body ol,.help-body ul{padding-left:22px}.help-body li{margin:3px 0}.help-body code{background:rgba(0,0,0,.06);padding:1px 4px;border-radius:3px}
.help-tbl{max-height:none;margin:8px 0;overflow-x:auto}.help-body{min-width:0;overflow-wrap:anywhere}
@media (max-width:760px){.help-layout{grid-template-columns:minmax(0,1fr)}.help-toc{position:static;max-height:none}}

/* demo banner: shown on every screen when the server runs OMOS_MODE=demo */
.demo-banner { position: sticky; top: 0; z-index: 30; display: flex; gap: 10px; align-items: center; padding: 7px 16px; background: #f5b82e; color: #1d1600; font-size: 13.5px; line-height: 1.35; border-bottom: 1px solid #c9921b; }
.demo-banner b { background: #1d1600; color: #f5b82e; padding: 2px 8px; border-radius: 4px; letter-spacing: 1.5px; font-size: 12.5px; flex: none; }
body.is-demo .topbar { top: var(--bar-off, 0px); }
@media (max-width: 760px) { .demo-banner { position: static; font-size: 12.5px; padding: 6px 12px; } }

/* 4.0 schedule views */
.seg { gap: 4px; } .pv-filters { margin: 10px 0; gap: 10px; flex-wrap: wrap; } .pv-filters .field { min-width: 150px; }
.gantt { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; position: relative; }
.g-row { display: flex; min-height: 26px; border-bottom: 1px solid var(--line); }
.g-label { position: sticky; left: 0; z-index: 3; flex: none; width: 300px; max-width: 45vw; background: var(--panel); padding: 4px 8px; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--line); }
.g-label a { color: inherit; text-decoration: none; } .g-label a:hover { text-decoration: underline; }
.g-track { position: relative; flex: none; }
.g-head { position: sticky; top: 0; z-index: 4; background: var(--panel); min-height: 40px; } .g-head .g-label { z-index: 5; font-weight: 600; display: flex; align-items: flex-end; }
.g-mons, .g-ticks { position: relative; height: 20px; } .g-mon { position: absolute; top: 2px; font-size: 11.5px; font-weight: 600; padding-left: 3px; border-left: 1px solid var(--line); white-space: nowrap; }
.g-tick { position: absolute; top: 2px; font-size: 10.5px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 2px; height: 18px; } .gantt { --we: rgba(120,140,160,.10); }
.g-group { background: var(--chip); } .g-group .g-label { background: var(--chip); font-weight: 600; }
.g-dd { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); z-index: 1; }
.g-bar { position: absolute; top: 5px; height: 16px; border-radius: 4px; overflow: hidden; z-index: 2; text-decoration: none; display: block; }
.g-bar.todo { background: #9fb6c9; } .g-bar.prog { background: var(--brand-2); } .g-bar.done { background: var(--ok); } .g-bar.late { background: var(--bad); }
.g-pct { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(0,0,0,.22); } .g-txt { position: relative; font-size: 10.5px; color: #fff; padding-left: 4px; line-height: 16px; white-space: nowrap; }
.g-fc { position: absolute; top: 11px; height: 4px; background: repeating-linear-gradient(90deg, var(--bad) 0 4px, transparent 4px 7px); z-index: 2; }
.g-ms { position: absolute; top: 6px; width: 14px; height: 14px; background: var(--brand); transform: rotate(45deg); z-index: 2; display: block; } .g-ms.late { background: var(--bad); } .g-ms.fc { background: transparent; border: 2px dashed var(--bad); }
.g-legend { gap: 12px; align-items: center; } .g-key { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.g-key.todo { background: #9fb6c9; } .g-key.prog { background: var(--brand-2); } .g-key.done { background: var(--ok); } .g-key.late { background: var(--bad); } .g-key.dd { background: var(--accent); width: 3px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: 10px; }
.cal-h { background: var(--chip); font-size: 12px; font-weight: 600; padding: 6px; text-align: center; }
.cal-day { min-height: 112px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding: 4px; font-size: 11.5px; min-width: 0; } .cal-day.out { opacity: .45; } .cal-day.we { background: var(--bg); } .cal-day.dd { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-n { font-weight: 600; margin-bottom: 2px; } .cal-it { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; color: var(--ink); border-radius: 3px; padding: 1px 3px; margin-bottom: 2px; }
.cal-it.st { background: var(--info-bg); } .cal-it.fi { background: var(--chip); } .cal-it.done { color: var(--muted); } .cal-it.ms { background: var(--warn-bg); font-weight: 600; } .cal-it.con { background: var(--bad-bg); color: var(--bad); } .cal-more { font-size: 11px; }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; margin-top: 10px; align-items: flex-start; }
.b-col { flex: 0 0 280px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; min-height: 120px; } .b-col.over { outline: 2px dashed var(--brand-2); }
.b-head { font-weight: 600; margin-bottom: 8px; } .b-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; box-shadow: var(--shadow); font-size: 13px; }
.b-card[draggable="true"] { cursor: grab; } .b-card.dragging { opacity: .5; } .b-card.late { border-left: 4px solid var(--bad); } .b-card a { color: inherit; text-decoration: none; } .b-move { margin-top: 6px; font-size: 12px; }
.bell .badge { background: var(--bad); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.inbox li.unread { border-left: 3px solid var(--brand-2); padding-left: 8px; } .modal .box.modal-box { width: min(640px, 100%); max-height: 80vh; overflow: auto; }
@media (max-width: 760px) { .g-label { width: 150px; } .cal-day { min-height: 70px; font-size: 10.5px; } .cal-it { font-size: 10px; } .b-col { flex-basis: 240px; } }

/* 4.0 enterprise */
.sso-btn { display: block; text-align: center; text-decoration: none; margin-bottom: 8px; } .or { text-align: center; color: var(--muted); font-size: 12px; margin: 6px 0 10px; }
.tfa-key { font: 600 18px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 1px; background: var(--chip); padding: 8px 10px; border-radius: 6px; margin: 6px 0; word-break: break-all; user-select: all; }
.tfa-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; } .tfa-codes code { background: var(--chip); padding: 6px; border-radius: 4px; text-align: center; user-select: all; }
.cards4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.cards4 .stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; } .cards4 .stat b { font-size: 22px; } .cards4 .stat span { font-size: 12.5px; color: var(--muted); }

/* 4.0 AI */
.ai-grid { align-items: start; }
.ai-chat { max-height: 460px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.ai-msg { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; max-width: 92%; min-width: 0; }
.ai-msg.user { align-self: flex-end; background: var(--info-bg); } .ai-msg.assistant { align-self: flex-start; background: var(--panel); }
.ai-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.ai-token { display: block; background: var(--chip); padding: 8px; border-radius: 6px; word-break: break-all; user-select: all; }
#aiAsk input { min-width: 0; } #aiDraftText { font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
fieldset { min-width: 0; } .cards > * { min-width: 0; } main select, main input, main textarea { max-width: 100%; } .grid2 > * { min-width: 0; } .field select { min-width: 0; }
