@font-face {
    font-family: "InterV";
    src: url("inter.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --font: "InterV", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --primary: #714b67;
    --primary-d: #5e3e56;
    --primary-l: #f4eef3;
    --action: #017e84;
    --action-d: #016a6f;
    --action-l: #e6f3f3;
    --ink: #1f2937;
    --text: #374151;
    --muted: #6b7280;
    --faint: #9ca3af;
    --line: #e5e7eb;
    --line-2: #d1d5db;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --hover: #f9fafb;
    --warn: #b45309;
    --warn-bg: #fdf3dc;
    --warn-line: #f6d891;
    --warn-row: #fffaeb;
    --danger: #b42318;
    --danger-bg: #fde8e6;
    --ok: #157347;
    --ok-bg: #e3f4ea;
    --info-bg: #e7f0fb;
    --info: #1d5fa8;
    --radius: 6px;
    --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
    --shadow-lg: 0 12px 32px rgb(16 24 40 / .18), 0 2px 6px rgb(16 24 40 / .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}
button { font: inherit; color: inherit; }
a { color: var(--action); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: 3px; }
svg { flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top navbar ---------- */
.nav {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 4px;
    height: 46px; padding: 0 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.nav-apps {
    display: grid; place-items: center;
    width: 34px; height: 34px; border: 0; background: none; border-radius: 6px;
    color: var(--text); cursor: pointer;
}
.nav-apps svg { width: 17px; height: 17px; }
.nav-apps:hover { background: var(--bg); }
.nav-app { font-weight: 600; font-size: 15px; color: var(--ink); padding: 0 10px 0 4px; white-space: nowrap; }
.nav-menu { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-menu::-webkit-scrollbar { display: none; }
.nav-menu button {
    border: 0; background: none; padding: 7px 10px; border-radius: 5px; cursor: pointer;
    white-space: nowrap; color: var(--text);
}
.nav-menu button:hover { background: var(--bg); }
.nav-menu button.is-on { background: var(--bg); color: var(--ink); font-weight: 500; }
.nav-menu button.is-dim { color: var(--faint); cursor: default; }
.nav-menu button.is-dim:hover { background: none; }
.nav-menu .risk-count {
    display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
    border-radius: 9px; background: var(--warn-bg); color: var(--warn); font-size: 11px; font-weight: 600;
}
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 6px; padding-left: 8px; }
.nav-ico {
    position: relative; display: grid; place-items: center; width: 32px; height: 32px;
    border: 0; background: none; border-radius: 6px; color: var(--muted); cursor: default;
}
.nav-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.nav-dot {
    position: absolute; top: 2px; right: 1px; min-width: 15px; height: 15px; padding: 0 4px;
    border-radius: 8px; background: var(--action); color: #fff; font-size: 10px; font-weight: 600; line-height: 15px; text-align: center;
}
.nav-co { font-size: 13px; color: var(--ink); font-weight: 500; padding: 0 6px; white-space: nowrap; }

.avatar {
    display: inline-grid; place-items: center; flex: none;
    width: 26px; height: 26px; border-radius: 5px;
    font-size: 10.5px; font-weight: 600; color: #fff; letter-spacing: .02em;
}
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; border-radius: 4px; }
.av-ml { background: #8c5a7f; }
.av-sm { background: #2f7d6d; }
.av-tn { background: #b86b2c; }
.av-ic { background: #4b6fb0; }
.av-rb { background: #6e7d3a; }
.av-sys { background: #64748b; }

/* app switcher */
.apps-pop {
    position: fixed; top: 52px; left: 10px; z-index: 65; width: 360px; padding: 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; animation: modalIn .15s ease-out;
}
.apps-pop[hidden] { display: none; }
.app-tile { border: 0; background: none; border-radius: 8px; padding: 10px 4px 8px; display: grid; justify-items: center; gap: 6px; cursor: pointer; font-size: 12.5px; color: var(--ink); }
.app-tile:hover { background: var(--bg); }
.app-tile.is-dim { color: var(--faint); cursor: default; }
.app-tile.is-dim:hover { background: none; }
.app-ic { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; }
.app-ic svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.app-tile.is-dim .app-ic { opacity: .45; }

/* ---------- control panel ---------- */
.app { display: block; min-height: calc(100vh - 46px); outline: none; }
.cp {
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
}
.cp-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 15px; }
.crumbs a { color: var(--action); white-space: nowrap; }
.crumbs .sep { color: var(--faint); }
.crumbs strong { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-gear { width: 26px; height: 26px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); border-radius: 5px; cursor: default; }
.cp-gear svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.cp-search {
    flex: 1 1 340px; max-width: 560px; margin: 0 auto;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    min-height: 34px; padding: 3px 8px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface);
}
.cp-search svg { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.cp-search input { flex: 1; min-width: 80px; border: 0; outline: 0; font: inherit; background: none; padding: 3px 2px; color: var(--ink); }
.facet {
    display: inline-flex; align-items: center; gap: 0; border-radius: 4px; overflow: hidden; font-size: 12.5px;
    background: var(--bg); border: 1px solid var(--line);
}
.facet-k { background: var(--action); color: #fff; padding: 2px 6px; display: grid; place-items: center; }
.facet-k svg { width: 12px; height: 12px; stroke: #fff; fill: none; stroke-width: 1.8; }
.facet-v { padding: 2px 6px; color: var(--ink); white-space: nowrap; }
.facet-x { border: 0; background: none; padding: 2px 6px; cursor: pointer; color: var(--muted); }
.facet-x:hover { color: var(--danger); }
.cp-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.pager { font-size: 13px; color: var(--muted); white-space: nowrap; }
.viewsw { display: flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.viewsw button { border: 0; background: var(--surface); width: 34px; height: 30px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.viewsw button + button { border-left: 1px solid var(--line-2); }
.viewsw button.is-on { background: var(--bg); color: var(--ink); }
.viewsw svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 12px; border-radius: 5px; border: 1px solid transparent;
    font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap;
    transition: background .12s, border-color .12s, color .12s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--hover); border-color: var(--faint); }
.btn-light { background: var(--bg); color: var(--ink); }
.btn-light:hover { background: #e9eaee; }
.btn-link { background: none; color: var(--action); padding: 0 6px; }
.btn-link:hover { text-decoration: underline; }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12.5px; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.pulse { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgb(113 75 103 / .45); }
    50% { box-shadow: 0 0 0 6px rgb(113 75 103 / 0); }
}

/* ---------- form view ---------- */
.fv { display: grid; grid-template-columns: minmax(0, 1fr) 380px; align-items: start; min-height: calc(100vh - 46px - 55px); }
.fv-main { min-width: 0; padding: 0 16px 40px; }
.fv-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 10px 0;
}
.fv-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.statusbar { display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.statusbar span {
    position: relative; padding: 6px 14px 6px 20px; font-size: 12.5px; color: var(--muted); white-space: nowrap;
    display: flex; align-items: center;
}
.statusbar span:first-child { padding-left: 12px; }
.statusbar span + span::before {
    content: ""; position: absolute; left: -7px; top: 50%; width: 13px; height: 13px;
    transform: translateY(-50%) rotate(45deg);
    border-top: 1px solid var(--line-2); border-right: 1px solid var(--line-2); background: inherit; z-index: 1;
}
.statusbar span.is-on { background: var(--action-l); color: var(--action-d); font-weight: 600; }
.statusbar span.is-on + span::before { background: var(--action-l); }
.statusbar span.flash { animation: flash 900ms ease-out; }
@keyframes flash { 0% { background: #bfe3e4; } 100% { background: var(--action-l); } }

.sheet {
    position: relative; max-width: 1140px; margin: 0 auto;
    background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
    box-shadow: var(--shadow);
    padding: 22px 28px 28px;
}
.smart { display: flex; justify-content: flex-end; margin: -22px -28px 16px; border-bottom: 1px solid var(--line); min-height: 0; flex-wrap: wrap; }
.smart:empty { display: none; }
.smart-btn {
    display: flex; align-items: center; gap: 9px; padding: 8px 16px; min-width: 128px;
    border: 0; border-left: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left;
}
.smart-btn:hover { background: var(--hover); }
.smart-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.smart-btn b { display: block; color: var(--action); font-size: 14px; font-weight: 600; line-height: 1.1; }
.smart-btn small { display: block; color: var(--muted); font-size: 12px; }
.smart-btn.pop { animation: pop .5s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

.title-k { font-size: 12.5px; color: var(--muted); margin: 0 0 2px; }
.title-h { margin: 0 0 18px; font-size: 28px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; line-height: 1.2; overflow-wrap: anywhere; }
.title-h .pn { color: var(--primary); }

.groups { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; margin-bottom: 22px; }
.fld { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 5px 0; min-height: 34px; }
.fld > label, .fld > .lbl { font-weight: 600; color: var(--ink); font-size: 13.5px; }
.fld .val { min-width: 0; color: var(--ink); border-bottom: 1px solid transparent; padding: 2px 0; overflow-wrap: anywhere; }
.fld .val.muted { color: var(--muted); }
.fld .val a { color: var(--action); }
.pn-chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-weight: 600; color: var(--primary);
}
.pn-chip svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.mod-dot {
    display: inline-block; font-size: 10px; font-weight: 600; color: var(--primary); background: var(--primary-l);
    border-radius: 3px; padding: 0 4px; margin-left: 6px; vertical-align: 2px; letter-spacing: .03em;
}

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 0; overflow-x: auto; scrollbar-width: none; }
.tabs button {
    border: 1px solid transparent; border-bottom: 0; background: none; padding: 8px 14px; cursor: pointer;
    color: var(--muted); border-radius: 5px 5px 0 0; white-space: nowrap; margin-bottom: -1px;
}
.tabs button.is-on { color: var(--ink); background: var(--surface); border-color: var(--line); font-weight: 500; }
.tabs button.is-dim { cursor: default; }

/* order lines */
.lines { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.lines th {
    text-align: left; font-weight: 600; color: var(--ink); font-size: 13px;
    padding: 9px 8px; border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
.lines td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lines tr:hover td { background: var(--hover); }
.lines .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines .prod { color: var(--ink); font-weight: 500; }
.lines .desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.lines .spec-prev {
    margin-top: 6px; font-size: 12px; color: var(--text); background: var(--primary-l); border-left: 2px solid var(--primary);
    padding: 4px 8px; border-radius: 0 4px 4px 0; max-width: 520px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lines .act { text-align: right; white-space: nowrap; width: 1%; }
.tax-tag { display: inline-block; white-space: nowrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0 7px; font-size: 12px; color: var(--text); }
.svc-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.svc-tag svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.line-add { display: flex; gap: 16px; padding: 10px 8px; }
.line-add span { color: var(--action); font-size: 13px; opacity: .55; }
.totals { display: flex; justify-content: flex-end; margin-top: 12px; }
.totals table { border-collapse: collapse; min-width: 280px; font-size: 13.5px; }
.totals td { padding: 3px 0 3px 24px; text-align: right; font-variant-numeric: tabular-nums; }
.totals td:first-child { color: var(--muted); padding-left: 0; }
.totals tr.grand td { border-top: 1px solid var(--line-2); padding-top: 8px; font-size: 16px; font-weight: 600; color: var(--ink); }
.totals tr.grand td:first-child { color: var(--ink); }
.terms { color: var(--faint); font-size: 13px; margin-top: 12px; }

/* chatter */
.chatter { border-left: 1px solid var(--line); background: var(--surface); min-height: calc(100vh - 46px - 55px); padding: 14px 18px 40px; min-width: 0; }
.chatter-top { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.chatter-day { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; margin: 12px 0 8px; }
.chatter-day::before, .chatter-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 8px 0; }
.msg.new { animation: msgIn .45s ease-out; }
@keyframes msgIn { from { opacity: 0; transform: translateY(-6px); background: var(--action-l); } to { opacity: 1; transform: none; } }
.msg-h { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.msg-h b { color: var(--ink); font-weight: 600; font-size: 13px; }
.msg-h time { color: var(--faint); font-size: 12px; }
.msg-b { font-size: 13px; color: var(--text); margin-top: 2px; overflow-wrap: anywhere; }
.msg-b ul { margin: 2px 0 0; padding-left: 16px; }
.msg-b .from { color: var(--muted); text-decoration: line-through; text-decoration-color: rgb(107 114 128 / .5); }
.msg-b .arrow { color: var(--faint); margin: 0 4px; }
.msg-b .to { color: var(--action-d); font-weight: 500; }
.msg-b code { font-family: inherit; font-weight: 600; color: var(--primary); }
.note-tag { font-size: 11px; color: var(--muted); background: var(--bg); border-radius: 3px; padding: 0 5px; }

/* web ribbon (Past Deadline) */
.wribbon {
    position: absolute; top: 0; right: 0; width: 150px; height: 150px; overflow: hidden; pointer-events: none; z-index: 2;
}
.wribbon span {
    position: absolute; top: 34px; right: -42px; width: 200px; transform: rotate(45deg);
    background: #f0ad3c; color: #3d2600; text-align: center; font-size: 12px; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; padding: 6px 0; box-shadow: 0 2px 4px rgb(0 0 0 / .15);
}
.wribbon.in span { animation: ribbonIn .5s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes ribbonIn { from { transform: rotate(45deg) translateY(-40px); opacity: 0; } to { transform: rotate(45deg); opacity: 1; } }

/* badges */
.badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px;
    font-size: 12px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.badge svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-danger { background: var(--danger-bg); color: var(--danger); }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-muted { background: var(--bg); color: var(--muted); }
.b-info { background: var(--info-bg); color: var(--info); }

/* deadline field */
.dl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dlwrap { position: relative; display: inline-flex; }
.dlwrap input[type=date] { position: absolute; left: 0; bottom: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.dlshow {
    display: inline-flex; align-items: center; gap: 10px; border: 0; border-bottom: 1px solid var(--line-2); background: none;
    padding: 2px 0; cursor: pointer; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 128px; justify-content: space-between;
}
.dlshow:hover { border-bottom-color: var(--action); }
.dlshow svg { width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 1.5; }
.dlshow.is-late { color: var(--warn); font-weight: 600; }
.dl input.old-date {
    font: inherit; color: var(--ink); border: 0; border-bottom: 1px solid var(--line-2); padding: 2px 0; background: none;
    min-width: 0; width: 140px;
}
.dl input[type=date]:hover { border-bottom-color: var(--action); }
.dl input[type=date]:focus { outline: 0; border-bottom-color: var(--action); }
.dl input.is-late { color: var(--warn); font-weight: 600; }
.dl .clear { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 2px; display: grid; place-items: center; border-radius: 4px; }
.dl .clear:hover { color: var(--danger); background: var(--danger-bg); }
.dl .clear svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.nudge { display: flex; gap: 4px; }
.nudge button { border: 1px solid var(--line-2); background: var(--surface); border-radius: 4px; font-size: 11.5px; padding: 1px 6px; cursor: pointer; color: var(--text); }
.nudge button:hover { border-color: var(--action); color: var(--action); }
.flag { display: inline-flex; align-items: center; gap: 6px; }
.flag svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }

.drift-meter { margin: 4px 0 20px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--hover); }
.drift-meter.late { border-color: var(--warn-line); background: var(--warn-row); }
.dm-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.dm-row b { color: var(--ink); font-weight: 600; }
.dm-track { position: relative; height: 6px; background: var(--line); border-radius: 3px; margin: 10px 0 6px; overflow: visible; }
.dm-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--action); transition: width .35s ease; }
.dm-late { position: absolute; top: 0; bottom: 0; border-radius: 0 3px 3px 0; background: repeating-linear-gradient(-45deg, #f0ad3c 0 5px, #f6c56e 5px 10px); transition: left .35s ease, width .35s ease; }
.dm-mark { position: absolute; top: -4px; width: 2px; height: 14px; background: var(--ink); border-radius: 1px; }
.dm-mark i { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 10.5px; font-style: normal; color: var(--ink); white-space: nowrap; font-weight: 600; }

.descbox { padding: 14px 2px 0; color: var(--ink); font-size: 14px; }
.descbox p { margin: 0 0 8px; }
.descbox ul { margin: 0 0 8px; padding-left: 20px; }
.descbox .empty { color: var(--faint); }
.copied-from { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 4px; padding: 2px 8px; margin-bottom: 10px; }
.copied-from svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.7; }

/* ---------- kanban ---------- */
.kb-wrap { padding: 16px; overflow-x: auto; min-width: 0; }
.pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; padding: 16px; }
.pcard {
    position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 12px 16px;
    box-shadow: var(--shadow); cursor: pointer; text-align: left; width: 100%; display: block;
}
.pcard::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c, var(--line-2)); }
.pcard:hover { border-color: var(--line-2); box-shadow: 0 4px 14px rgb(16 24 40 / .1); }
.pcard.is-new { animation: pop .6s cubic-bezier(.2, .9, .3, 1.3); outline: 2px solid var(--action); outline-offset: 1px; }
.pcard h3 { margin: 0; font-size: 14.5px; color: var(--ink); font-weight: 600; line-height: 1.3; padding-right: 24px; }
.pcard .cust { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pcard .meta { display: grid; gap: 3px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.pcard .meta .flag { color: var(--ink); }
.pcard .foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 8px; }
.pcard .tasks { color: var(--action); font-weight: 600; font-size: 13px; }
.pcard .star { position: absolute; right: 12px; top: 12px; width: 15px; height: 15px; fill: none; stroke: var(--faint); stroke-width: 1.5; }
.pcard .star.on { fill: #f3b23b; stroke: #f3b23b; }
.avs { display: flex; }
.avs .avatar { border: 2px solid var(--surface); margin-left: -5px; }
.avs .avatar:first-child { margin-left: 0; }

.kb { display: flex; gap: 12px; align-items: flex-start; min-width: min-content; }
.kcol { width: 292px; flex: none; }
.kcol-h { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 6px; }
.kcol-h b { color: var(--ink); font-size: 14px; }
.kcol-h span { color: var(--muted); font-size: 13px; }
.kcol-bar { height: 4px; border-radius: 2px; background: var(--line); display: flex; overflow: hidden; margin: 0 4px 10px; }
.kcol-bar i { display: block; height: 100%; }
.kcol-body { display: grid; gap: 8px; min-height: 120px; padding: 4px; border-radius: var(--radius); transition: background .15s; }
.kcol-body.drop { background: var(--action-l); outline: 1px dashed var(--action); }
.tcard {
    position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
    box-shadow: var(--shadow); cursor: grab; text-align: left; display: block; width: 100%;
}
.tcard:hover { border-color: var(--line-2); }
.tcard.late { border-left: 3px solid #f0ad3c; padding-left: 10px; }
.tcard.dragging { opacity: .4; }
.tcard.is-new { animation: pop .55s cubic-bezier(.2, .9, .3, 1.3) both; }
.tcard .tn { color: var(--ink); font-weight: 500; font-size: 13.5px; line-height: 1.35; }
.tcard .tn .pn { color: var(--primary); font-weight: 600; }
.tcard .tp { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tcard .tf { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.tcard .td { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.tcard .td svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.tcard .td.late { color: var(--warn); font-weight: 600; }
.tcard .tl { display: flex; gap: 6px; align-items: center; }
.kb-hint { color: var(--muted); font-size: 12.5px; padding: 0 16px; margin-top: -4px; }

/* ---------- list view ---------- */
.lv-wrap { padding: 0 0 40px; min-width: 0; }
.lv-banner {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between;
    margin: 14px 16px 0; padding: 10px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
}
.lv-stats { display: flex; gap: 22px; flex-wrap: wrap; }
.lv-stat b { display: block; font-size: 20px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.lv-stat span { font-size: 12px; color: var(--muted); }
.lv-stat.warn b { color: var(--warn); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 11px; cursor: pointer; font-size: 12.5px; color: var(--text); }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.is-on { background: var(--action-l); color: var(--action-d); font-weight: 600; }
.lv-table-wrap { margin: 12px 16px 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.lv { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.lv th {
    text-align: left; font-weight: 600; color: var(--ink); font-size: 13px; white-space: nowrap;
    padding: 0; border-bottom: 1px solid var(--line-2); background: var(--surface); position: sticky; top: 0;
}
.lv th button {
    all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 5px; width: 100%; padding: 10px 10px; cursor: pointer;
}
.lv th button:focus-visible { outline: 2px solid var(--action); outline-offset: -2px; }
.lv th.num button { justify-content: flex-end; }
.lv th button svg { width: 10px; height: 10px; fill: none; stroke: var(--faint); stroke-width: 1.8; }
.lv th.sorted button svg { stroke: var(--ink); }
.lv th:hover { background: var(--hover); }
.lv td { padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lv tbody tr { cursor: pointer; }
.lv tbody tr:hover td { background: var(--hover); }
.lv tr.warn td { color: var(--warn); }
.lv tr.warn td.task { color: #92400e; }
.lv tr.warn:hover td { background: #fff4d6; }
.lv .num { text-align: right; font-variant-numeric: tabular-nums; }
.lv .task { color: var(--ink); font-weight: 500; white-space: normal; min-width: 220px; }
.lv .pnc { font-weight: 600; color: var(--primary); }
.lv tr.warn .pnc { color: var(--primary); }
.lv .stage { font-size: 12px; }
.lv-foot { display: flex; justify-content: space-between; padding: 10px 16px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; gap: 8px; }
.drift-bar { display: inline-block; height: 6px; border-radius: 3px; background: #f0ad3c; vertical-align: middle; margin-right: 8px; }
.empty-state { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty-state b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* ---------- modal ---------- */
.modal-bg {
    position: fixed; inset: 0; z-index: 60; background: rgb(17 24 39 / .45);
    display: grid; place-items: start center; padding: 56px 16px 16px; overflow-y: auto;
    animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
    width: min(820px, 100%); background: var(--surface); border-radius: 8px; box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; max-height: calc(100vh - 80px);
    animation: modalIn .2s ease-out;
}
@keyframes modalIn { from { transform: translateY(-10px); opacity: 0; } }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-h h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink); }
.modal-x { border: 0; background: none; width: 30px; height: 30px; border-radius: 5px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.modal-x:hover { background: var(--bg); }
.modal-x svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }
.modal-b { padding: 18px 22px; overflow-y: auto; }
.modal-b h3 { margin: 0 0 14px; font-size: 22px; font-weight: 600; color: var(--ink); }
.modal-f { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.editor { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.ed-tools { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--hover); flex-wrap: wrap; }
.ed-tools button { border: 0; background: none; width: 30px; height: 28px; border-radius: 4px; cursor: pointer; color: var(--text); display: grid; place-items: center; font-weight: 600; }
.ed-tools button:hover { background: var(--line); }
.ed-tools svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.ed-tools .sep { width: 1px; background: var(--line-2); margin: 4px 4px; }
.ed-tools .tpl { width: auto; padding: 0 8px; font-weight: 500; font-size: 12.5px; color: var(--action); }
.ed-area { min-height: 220px; padding: 14px 16px; outline: none; color: var(--ink); font-size: 14px; }
.ed-area:empty::before { content: attr(data-ph); color: var(--faint); }
.ed-area p { margin: 0 0 8px; }
.ed-area ul { margin: 0 0 8px; padding-left: 20px; }
.ed-note { font-size: 12px; color: var(--muted); margin-top: 10px; display: flex; gap: 6px; align-items: center; }
.ed-note svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; top: 58px; right: 16px; z-index: 70; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
    pointer-events: auto; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--ok);
    border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px 14px; font-size: 13px; color: var(--ink);
    animation: toastIn .3s ease-out;
}
.toast.warn { border-left-color: #f0ad3c; }
.toast b { display: block; margin-bottom: 1px; }
.toast span { color: var(--muted); }
.toast.out { animation: toastOut .3s ease-in forwards; }
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } }
@keyframes toastOut { to { transform: translateX(20px); opacity: 0; } }

/* ---------- confirm overlay (automation trace) ---------- */
.trace {
    margin: 0 auto 12px; max-width: 1140px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 14px; box-shadow: var(--shadow);
}
.trace-h { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.trace-h b { color: var(--ink); }
.trace-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.trace-step {
    position: relative; border: 1px solid var(--line); border-radius: 5px; padding: 8px 10px; font-size: 12.5px; color: var(--faint);
    background: var(--hover); transition: all .3s;
}
.trace-step small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.trace-step b { display: block; color: inherit; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trace-step i { display: block; font-style: normal; font-size: 12px; margin-top: 1px; }
.trace-step.on { border-color: var(--action); background: var(--action-l); color: var(--action-d); }
.trace-step.on b { color: var(--ink); }
.trace-step.on i { color: var(--primary); font-weight: 600; }

/* ---------- demo tour ---------- */
.tour {
    position: fixed; right: 16px; bottom: 16px; z-index: 50; width: 300px;
    background: #1c1f26; color: #e5e7eb; border-radius: 10px; box-shadow: 0 16px 40px rgb(0 0 0 / .3);
    font-size: 13px; overflow: hidden;
}
.tour-head { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 1fr auto; gap: 0 8px; width: 100%; padding: 11px 14px; cursor: pointer; }
.tour-head:focus-visible { outline: 2px solid #7dd3d8; outline-offset: -2px; }
.tour-k { grid-column: 1; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #9aa3b2; }
.tour-t { grid-column: 1; font-weight: 600; color: #fff; }
.tour-chev { grid-column: 2; grid-row: 1 / 3; align-self: center; width: 12px; height: 12px; fill: none; stroke: #9aa3b2; stroke-width: 1.6; transition: transform .2s; }
.tour.min .tour-chev { transform: rotate(180deg); }
.tour.min .tour-steps, .tour.min .tour-reset { display: none; }
.tour-steps { list-style: none; margin: 0; padding: 0 8px 4px; }
.tour-steps li { display: grid; grid-template-columns: 20px 1fr; gap: 8px; padding: 7px 6px; border-radius: 6px; }
.tour-steps li.cur { background: rgb(255 255 255 / .06); }
.tour-steps li button { all: unset; cursor: pointer; color: #cbd2dc; }
.tour-steps li.cur button { color: #fff; }
.tour-steps li button:hover { text-decoration: underline; }
.tour-steps li button:focus-visible { outline: 2px solid #7dd3d8; outline-offset: 2px; border-radius: 3px; }
.tour-n { width: 20px; height: 20px; border-radius: 50%; border: 1px solid #4b5563; display: grid; place-items: center; font-size: 11px; color: #9aa3b2; }
.tour-steps li.done .tour-n { background: #2a9d8f; border-color: #2a9d8f; color: #fff; }
.tour-steps li.done .tour-n svg { width: 11px; height: 11px; fill: none; stroke: #fff; stroke-width: 2.4; }
.tour-steps li.done button { color: #8b95a5; }
.tour-reset { all: unset; display: block; margin: 0 14px 10px; font-size: 12px; color: #9aa3b2; cursor: pointer; }
.tour-reset:hover { color: #fff; text-decoration: underline; }
.tour-reset:focus-visible { outline: 2px solid #7dd3d8; }

.ribbon {
    position: fixed; left: 12px; bottom: 12px; z-index: 55;
    font-size: 11px; font-weight: 600; letter-spacing: .02em; color: #fff; background: rgb(28 31 38 / .82);
    padding: 4px 9px; border-radius: 4px; text-decoration: none;
}
.ribbon:hover { background: #1c1f26; text-decoration: none; }

/* ---------- responsive ---------- */
@media (max-width: 1279px) {
    .fv { grid-template-columns: minmax(0, 1fr); }
    .chatter { border-left: 0; border-top: 1px solid var(--line); min-height: 0; max-width: 1172px; margin: 0 auto; width: 100%; background: transparent; padding: 8px 32px 120px; }
}
@media (max-width: 900px) {
    .groups { grid-template-columns: 1fr; }
    .trace-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    body { font-size: 14px; }
    .nav { padding: 0 6px; gap: 2px; }
    .nav-co, .nav-ico, .nav-menu button.is-dim { display: none; }
    .tour.min .tour-t { display: none; }
    .tour.min .tour-head { padding: 9px 12px; }
    .nav-app { padding: 0 6px 0 2px; font-size: 14px; }
    .nav-menu button { padding: 7px 8px; font-size: 13px; }
    .cp { padding: 8px 12px; gap: 8px; }
    .cp-search { order: 3; flex-basis: 100%; max-width: none; }
    .cp-right .pager { display: none; }
    .fv-main { padding: 0 0 24px; }
    .fv-bar { padding: 10px 12px; }
    .statusbar span { padding: 5px 10px 5px 16px; font-size: 11.5px; }
    .statusbar span:first-child { padding-left: 9px; }
    .sheet { border-radius: 0; border-left: 0; border-right: 0; padding: 16px 14px 20px; }
    .smart { margin: -16px -14px 14px; }
    .smart-btn { flex: 1; min-width: 0; padding: 8px 12px; }
    .title-h { font-size: 22px; }
    .fld { grid-template-columns: 118px minmax(0, 1fr); gap: 8px; }
    .lines thead { display: none; }
    .lines, .lines tbody, .lines tr, .lines td { display: block; width: 100%; }
    .lines tr { border-bottom: 1px solid var(--line); padding: 10px 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
    .lines td { border: 0; padding: 0; }
    .lines td.c-prod { grid-column: 1 / -1; }
    .lines td.c-qty::before { content: "Qty "; color: var(--muted); }
    .lines td.c-qty, .lines td.c-price, .lines td.c-tax { display: none; }
    .lines td.c-amt { grid-column: 2; grid-row: 2; text-align: right; font-weight: 600; color: var(--ink); }
    .lines td.act { grid-column: 1; grid-row: 2; text-align: left; }
    .lines tr:hover td { background: none; }
    .totals table { min-width: 0; width: 100%; }
    .chatter { padding: 8px 14px 110px; }
    .trace { margin: 0 0 10px; border-radius: 0; border-left: 0; border-right: 0; }
    .trace-row { grid-template-columns: 1fr 1fr; }
    .wribbon { width: 120px; height: 120px; }
    .wribbon span { top: 24px; right: -50px; font-size: 10.5px; }
    .kcol { width: 264px; }
    .kb-wrap { padding: 12px; }
    .pk-grid { padding: 12px; grid-template-columns: minmax(0, 1fr); }
    .lv-banner, .lv-table-wrap { margin-left: 0; margin-right: 0; border-radius: 0; border-left: 0; border-right: 0; }
    .lv thead { display: none; }
    .lv, .lv tbody { display: block; }
    .lv tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
    .lv td { padding: 0; border: 0; white-space: normal; }
    .lv tr.warn { background: var(--warn-row); }
    .lv td.c-pn { grid-column: 1; }
    .lv td.c-drift { grid-column: 2; grid-row: 1 / 3; align-self: center; }
    .lv td.task { grid-column: 1; min-width: 0; }
    .lv td.c-proj { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
    .lv td.c-orig, .lv td.c-dl { grid-column: 1 / -1; font-size: 12.5px; }
    .lv td.c-orig::before { content: "Original "; color: var(--muted); }
    .lv td.c-dl::before { content: "Deadline "; color: var(--muted); }
    .lv td.c-user, .lv td.c-stage { display: none; }
    .lv-mobile-sort { display: flex !important; }
    .modal-bg { padding: 0; place-items: stretch; }
    .modal { width: 100%; max-height: none; min-height: 100vh; border-radius: 0; }
    .ed-area { min-height: 280px; }
    .tour { left: 10px; right: 10px; bottom: 10px; width: auto; }
    .tour.min { left: auto; width: 210px; }
    .tour:not(.min) { bottom: 44px; }
    .ribbon { left: 10px; bottom: 14px; }
    .apps-pop { left: 6px; right: 6px; width: auto; }
    .toast-wrap { top: 54px; right: 10px; }
}
.lv-mobile-sort { display: none; align-items: center; gap: 8px; padding: 10px 14px 0; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
