:root {
  --bg: #f5f6f8; --surface: #ffffff; --line: #e5e7eb; --line2: #eef0f2; --ink: #1f2328; --ink2: #545c66; --muted: #8b939d;
  --accent: #e8681d; --accent-d: #cf5a14; --link: #1e5bb8; --hover: #f7f8f9; --active: #f0f1f3;
  --pos: #237a3e; --pos-bg: #e4f3e8; --neg: #c0392b; --neg-bg: #fbe6e3; --warn: #9a5b00; --warn-bg: #fdf0db;
  --r: 6px; --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 14px; color: var(--ink); -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); cursor: pointer; text-decoration: none; }
.ic { flex: none; display: block; }
.sp { flex: 1; }

/* ---------- top bar ---------- */
.top { height: 64px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 24px; gap: 18px; position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: baseline; gap: 6px; user-select: none; }
.brand b { color: var(--accent); font-size: 22px; letter-spacing: -.4px; font-weight: 700; }
.brand i { color: var(--ink2); font-size: 16px; }
.top .search { position: relative; margin: 0 auto; width: min(400px, 40vw); }
.top .search input { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 4px; padding: 0 12px 0 34px; background: var(--surface); }
.top .search .ic { position: absolute; left: 11px; top: 11px; color: var(--muted); }
.top-r { display: flex; align-items: center; gap: 14px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.lang button { border: 0; background: transparent; padding: 5px 9px; font-size: 12.5px; color: var(--ink2); cursor: pointer; }
.lang button.on { background: var(--active); color: var(--ink); font-weight: 600; }
.purpose { border: 1px solid var(--line); border-radius: 4px; height: 32px; padding: 0 8px; background: var(--surface); font-size: 13px; color: var(--ink2); max-width: 210px; }
.avatar { width: 36px; height: 36px; border-radius: 4px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; display: grid; place-items: center; border: 0; cursor: pointer; }
.icon-btn { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 4px; display: grid; place-items: center; cursor: pointer; color: var(--ink2); }
.icon-btn:hover { background: var(--active); color: var(--ink); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 64px); }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 8px 0 24px; position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto; }
.side h2 { font-size: 19px; font-weight: 700; margin: 22px 24px 16px; }
.nav-i { display: flex; align-items: center; gap: 12px; padding: 11px 24px; color: var(--ink); font-weight: 500; cursor: pointer; border-left: 3px solid transparent; }
.nav-i:hover { background: var(--hover); }
.nav-i.on { background: var(--active); }
.nav-i .ch { margin-left: auto; color: var(--ink2); transition: transform .15s; }
.nav-g.open > .nav-i .ch { transform: rotate(180deg); }
.nav-sub { display: none; }
.nav-g.open .nav-sub { display: block; }
.nav-s { display: block; padding: 10px 24px 10px 54px; color: var(--ink2); cursor: pointer; border-left: 3px solid transparent; }
.nav-s:hover { background: var(--hover); }
.nav-s.on { color: var(--accent); background: var(--active); border-left-color: var(--accent); font-weight: 500; }
.main { padding: 26px 32px 48px; min-width: 0; }
.ws-pop { position: absolute; top: 56px; left: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px rgba(16, 24, 40, .12); padding: 8px; width: 280px; z-index: 40; }
.ws-pop button { display: flex; width: 100%; gap: 12px; align-items: center; padding: 10px 12px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; text-align: left; }
.ws-pop button:hover, .ws-pop button.on { background: var(--active); }
.ws-pop .ic { color: var(--ink2); }

/* ---------- page parts ---------- */
.ph { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; min-height: 36px; }
.ph h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.2px; }
.ph .glyph { width: 28px; height: 28px; border-radius: 4px; background: #eef2f8; color: #3d4f6e; display: grid; place-items: center; }
.btn { height: 34px; padding: 0 14px; border-radius: 4px; border: 1px solid #d4d8dd; background: var(--surface); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-d); }
.btn.ghost { border-color: transparent; color: var(--link); padding: 0 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.strip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 18px; margin-bottom: 22px; box-shadow: var(--shadow); }
.strip-row { display: flex; gap: 12px 48px; flex-wrap: wrap; align-items: center; }
.strip-more .strip-row { border-top: 1px solid var(--line2); margin-top: 12px; padding-top: 12px; }
.kv { min-width: 110px; }
.kv label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.kv > div { font-size: 13.5px; }
.strip-act { margin-left: auto; display: flex; gap: 4px; }
.tabs { display: flex; gap: 30px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a { padding: 10px 0 11px; color: var(--ink); font-weight: 600; font-size: 15px; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.toolbar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; display: flex; align-items: center; gap: 10px; margin-bottom: 18px; box-shadow: var(--shadow); }
.toolbar .search { position: relative; width: min(390px, 100%); }
.toolbar .search input { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 4px; padding: 0 12px 0 32px; }
.toolbar .search .ic { position: absolute; left: 10px; top: 10px; color: var(--muted); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; color: var(--ink2); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--active); color: var(--ink); font-weight: 600; }

/* filter bar (dashboard) */
.fbar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: flex; align-items: stretch; margin-bottom: 18px; overflow-x: auto; box-shadow: var(--shadow); }
.fb { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-right: 1px solid var(--line); position: relative; min-width: 0; }
.fb:last-child { border-right: 0; margin-left: auto; }
.fb .ic { color: var(--ink2); }
.fb label { display: block; font-size: 12px; color: var(--muted); }
.fb select { border: 0; padding: 0 18px 0 0; font-size: 15px; font-weight: 500; color: var(--accent); background: transparent; appearance: none; cursor: pointer; }
.fb .chev { position: absolute; right: 14px; bottom: 13px; color: var(--ink2); pointer-events: none; }

/* panels & grids */
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-7-5 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.span2 { grid-column: span 2; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; }
.panel-h { display: flex; align-items: center; gap: 6px; padding: 14px 18px 4px; }
.panel-h h3 { font-size: 15px; font-weight: 600; margin: 0; }
.panel-b { padding: 10px 18px 16px; flex: 1; min-width: 0; }
.panel.flush .panel-b { padding: 0; }
.panel.muted-b { background: #fbfbfc; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 18px; box-shadow: var(--shadow); }
.kpi { padding: 18px 26px 20px; border-right: 1px solid var(--line2); }
.kpi:last-child { border-right: 0; }
.kpi-h { display: flex; align-items: center; gap: 6px; color: var(--ink2); font-size: 14px; }
.kpi-v { font-size: 32px; font-weight: 700; margin-top: 10px; letter-spacing: -.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delta { font-size: 12px; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.delta.up { background: var(--pos-bg); color: var(--pos); } .delta.down { background: var(--neg-bg); color: var(--neg); }

/* tables */
.tbl { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 13px; font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
th .tip { display: inline-block; vertical-align: -3px; margin-left: 4px; }
th.sortable { cursor: pointer; } th.sortable::after { content: '↕'; color: var(--muted); margin-left: 6px; font-size: 11px; } th.sorted::after { content: '↑'; color: var(--ink); }
td { padding: 11px 16px; border-bottom: 1px solid var(--line2); vertical-align: middle; font-size: 13.5px; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono, .mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12.5px; color: var(--ink2); }
td.empty, .empty { color: var(--muted); padding: 22px 16px; text-align: center; }
.lnk { color: var(--link); font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.lnk:hover { text-decoration: underline; }
.lnk-ic { width: 18px; height: 18px; border-radius: 3px; background: #1f4e8c; color: #fff; display: grid; place-items: center; }
.sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.st { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--ink2); }
.st::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #b8bec6; }
.st.pos::before { background: #3a9b5a; } .st.neg::before { background: #d0473a; } .st.warn::before { background: #e0a23a; }
.chip { display: inline-block; font-size: 12px; padding: 2px 7px; border-radius: 4px; background: var(--active); color: var(--ink2); white-space: nowrap; }
.chip.neg { background: var(--neg-bg); color: var(--neg); } .chip.warn { background: var(--warn-bg); color: var(--warn); } .chip.pos { background: var(--pos-bg); color: var(--pos); }

/* tooltip: annotations visible only on hover/focus */
.tip { color: var(--muted); cursor: help; position: relative; display: inline-grid; place-items: center; outline: none; }
.tip:hover, .tip:focus { color: var(--ink2); }
.tip::after, .has-tip::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: 280px;
  background: #1f2328; color: #fff; font-size: 12.5px; font-weight: 400; line-height: 1.45; padding: 8px 10px; border-radius: 4px; white-space: normal; text-align: left;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s; z-index: 60; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.tip:hover::after, .tip:focus::after, .has-tip:hover::after, .has-tip:focus::after { opacity: 1; visibility: visible; }
.has-tip { position: relative; display: inline-flex; outline: none; }
.tip.r::after { left: auto; right: -6px; transform: none; }

/* menus, modal, toast */
.menu { position: relative; }
.menu-l { display: none; position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px rgba(16, 24, 40, .12); min-width: 200px; padding: 6px; z-index: 35; }
.menu.on .menu-l { display: block; }
.menu-l button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.menu-l button:hover { background: var(--active); } .menu-l button:disabled { color: var(--muted); cursor: default; background: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(20, 24, 31, .38); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--surface); border-radius: 8px; width: min(560px, 94vw); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal header { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); } .modal header h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-b { padding: 18px 20px; overflow: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.fld.wide, .fld:has(textarea) { grid-column: 1 / -1; }
.fld label { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ink2); margin-bottom: 6px; }
.fld input, .fld select, .fld textarea, .inp { width: 100%; height: 36px; border: 1px solid #d4d8dd; border-radius: 4px; padding: 0 10px; background: var(--surface); }
.fld textarea { height: auto; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(232, 104, 29, .25); border-color: var(--accent); }
:focus-visible { outline: 2px solid rgba(232, 104, 29, .45); outline-offset: 1px; }
.toast { position: fixed; right: 22px; bottom: 22px; display: flex; gap: 10px; align-items: flex-start; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--pos); padding: 12px 14px; border-radius: 4px; box-shadow: 0 8px 24px rgba(16, 24, 40, .14); z-index: 70; }
.toast.err { border-left-color: var(--neg); } .toast .ic { margin-top: 1px; color: var(--pos); } .toast.err .ic { color: var(--neg); }

/* charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .cl { font-size: 11px; fill: var(--muted); } .chart .cv { font-size: 11px; fill: var(--ink2); } .chart .gl { stroke: var(--line2); stroke-width: 1; }
.chart .cc { font-size: 13px; font-weight: 600; fill: var(--ink); } .chart .gv { font-size: 24px; font-weight: 700; fill: var(--ink); }
.bars .chart { max-height: 190px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink2); margin-bottom: 6px; justify-content: flex-end; }
.legend span, .dl li { display: inline-flex; align-items: center; gap: 6px; }
.legend i, .dl i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.donut { display: grid; grid-template-columns: 150px 1fr; gap: 18px; align-items: center; }
.donut .chart.sq { width: 150px; }
.dl { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }
.dl li { display: grid; grid-template-columns: 12px 1fr auto; } .dl b { font-weight: 600; font-variant-numeric: tabular-nums; }
.gauge .chart.g { max-width: 260px; margin: 0 auto; }
.hbars { display: grid; gap: 10px; }
.hb { display: grid; grid-template-columns: 150px 1fr 60px; gap: 10px; align-items: center; font-size: 13px; }
.hb-l { color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-t { height: 10px; background: var(--line2); border-radius: 2px; overflow: hidden; } .hb-t i { display: block; height: 100%; border-radius: 2px; }
.hb b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* misc */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: #eef0f3; border-radius: var(--r); padding: 10px; min-height: 120px; }
.kcol h4 { margin: 2px 4px 10px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; color: var(--ink2); }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.kcard:hover { border-color: #c9ced5; }
.kcard b { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.kcard .row { display: flex; justify-content: space-between; color: var(--ink2); font-size: 12.5px; }
.stages { display: flex; gap: 0; margin: -2px 0 18px; overflow-x: auto; }
.stages span { flex: 1; min-width: 104px; text-align: center; font-size: 12.5px; padding: 8px 6px; background: #eceef1; color: var(--ink2); clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%); margin-right: -6px; }
.stages span.done { background: #dfe7f3; color: #2c4a77; } .stages span.cur { background: var(--accent); color: #fff; font-weight: 600; }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: grid; grid-template-columns: 130px 1fr; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line2); }
.tl li:last-child { border-bottom: 0; }
.tl time { color: var(--muted); font-size: 12.5px; }
.tl b { font-weight: 600; }
.dl2 { display: grid; grid-template-columns: 160px 1fr; gap: 9px 14px; font-size: 13.5px; margin: 0; }
.dl2 dt { color: var(--muted); } .dl2 dd { margin: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
pre.out { white-space: pre-wrap; background: var(--hover); border: 1px solid var(--line2); border-radius: 4px; padding: 12px; font-size: 13px; margin: 0; }
.login { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.login .box { width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 30px 32px; box-shadow: var(--shadow); }
.login .box .brand { margin-bottom: 22px; }
.login .box .form { grid-template-columns: 1fr; }
.login .box footer { display: flex; align-items: center; gap: 10px; margin-top: 20px; }

@media (max-width: 1180px) { .g4, .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-7-5 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; } .side { display: none; position: fixed; z-index: 45; width: 270px; top: 64px; left: 0; } .side.show { display: block; box-shadow: 4px 0 18px rgba(0,0,0,.12); }
  .g2, .g3, .g4, .kpis { grid-template-columns: 1fr; } .main { padding: 18px 16px 40px; } .top .search, .purpose { display: none; } .form { grid-template-columns: 1fr; }
}

/* ---------- Sales App (mobile) ---------- */
.m-app { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.m-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 12px 16px; display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 4; }
.m-head .brand b { font-size: 19px; } .m-head .brand i { font-size: 14px; }
.m-sync { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink2); }
.m-body { flex: 1; padding: 14px 14px 20px; }
.m-h { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink2); margin: 18px 2px 8px; }
.m-h:first-child { margin-top: 2px; }
.m-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 13px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.m-item .tx { flex: 1; min-width: 0; } .m-item .tx b { display: block; font-weight: 600; font-size: 14px; } .m-item .tx span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.m-nav { position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(6, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.m-nav a { display: grid; justify-items: center; gap: 3px; padding: 8px 2px 9px; font-size: 11px; color: var(--ink2); }
.m-nav a.on { color: var(--accent); font-weight: 600; }
.m-btn { width: 100%; justify-content: center; height: 42px; margin-top: 10px; }
.m-app .form { grid-template-columns: 1fr; }
/* schema forms & result views */
.req { color: var(--neg); font-weight: 600; }
.fs { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px 12px; margin: 0; }
.fs legend { font-size: 12.5px; font-weight: 600; color: var(--ink2); padding: 0 6px; }
.fs .form { margin-top: 4px; }
.form select[multiple] { height: auto; padding: 4px; }
.form textarea.mono { font-size: 12.5px; }
.result { max-height: 62vh; overflow: auto; }
.result .dl2 { margin: 0; }
.row.nowrap { flex-wrap: nowrap; gap: 4px; }
.or { text-align: center; color: var(--muted); font-size: 12.5px; margin: 14px 0; position: relative; }
.or::before, .or::after { content: ''; position: absolute; top: 50%; width: 42%; border-top: 1px solid var(--line); }
.or::before { left: 0; } .or::after { right: 0; }
.login .m-btn { width: 100%; justify-content: center; height: 42px; gap: 8px; }
ul.plain { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13.5px; }
