:root {
  --p: #4f46e5; --pt: #3730a3; --muted: #eef2ff; --bg: #f3f4f6; --line: #e5e7eb; --line2: #d1d5db;
  --tx: #111827; --tx2: #374151; --tx3: #6b7280; --red: #dc2626; --amber: #b45309; --green: #15803d;
  --c1: #3730a3; --c2: #0f766e; --c3: #0369a1; --c4: #b45309; --c5: #475569;
  font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--tx); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--pt); outline-offset: 2px; }
svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* shell */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; position: relative; }
.side { width: 15rem; flex: none; background: #0f172a; color: #e2e8f0; display: flex; flex-direction: column; z-index: 40; }
.side-head { height: 56px; flex: none; background: #fff; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.glyph { width: 28px; height: 28px; border-radius: 6px; background: var(--pt); position: relative; flex: none; }
.glyph::after { content: ""; position: absolute; inset: 8px; border: 2px solid #fff; border-radius: 2px; }
.side-name { font-weight: 700; color: #0f172a; font-size: 15px; letter-spacing: -.01em; }
.side .side-close { margin-left: auto; display: none; color: #475569; }
.side-nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.side-nav :focus-visible { outline-color: #a5b4fc; }
.sec-btn { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: #94a3b8; border-radius: 4px; }
.sec-btn:hover { color: #cbd5e1; }
.sec-btn .chev { transition: transform .2s; font-size: 14px; }
.sec-btn[aria-expanded="true"] .chev { transform: rotate(90deg); }
.sec { margin-bottom: 8px; }
.sec-items[hidden] { display: none; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; font-size: 14px; color: #cbd5e1; text-align: left; margin-top: 1px; }
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.on { background: #1e293b; color: #fff; font-weight: 500; box-shadow: inset 3px 0 0 #818cf8; }
.nav-item .cnt { margin-left: auto; background: #f59e0b; color: #fff; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 99px; line-height: 1; }
.scrim { display: none; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { height: 56px; flex: none; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; padding: 0 16px; }
.crumb { min-width: 0; font-size: 14px; color: var(--tx3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb b { color: #1f2937; font-weight: 600; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 6px; color: var(--tx3); position: relative; }
.icon-btn:hover { background: #f3f4f6; }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 99px; background: #f59e0b; border: 2px solid #fff; }
.burger { display: none; }
.user { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 6px; text-align: left; }
.user:hover { background: #f3f4f6; }
.avatar { width: 28px; height: 28px; border-radius: 99px; background: var(--muted); color: var(--pt); font-size: 12px; font-weight: 600; display: grid; place-items: center; flex: none; }
.user-txt b { display: block; font-size: 14px; font-weight: 500; color: #1f2937; }
.user-txt small { display: block; font-size: 12px; color: #6b7280; }
.pop-wrap { position: relative; }
.pop { position: absolute; right: 0; top: calc(100% + 6px); width: 300px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,.12); z-index: 60; font-size: 14px; overflow: hidden; }
.pop-menu { width: 180px; padding: 4px 0; }
.pop-menu button { display: block; width: 100%; text-align: left; padding: 7px 12px; color: var(--tx2); }
.pop-menu button:hover, .note:hover { background: #f9fafb; }
.pop-h { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
.note { display: block; width: 100%; text-align: left; padding: 10px 12px; border-bottom: 1px solid #f3f4f6; }
.note small { display: block; color: var(--tx3); font-size: 12px; margin-top: 2px; }
.note.unread { box-shadow: inset 3px 0 0 var(--p); }
.main { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 24px; }
.tabs { display: none; }

/* page parts */
.ph { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.ph h1 { font-size: 20px; font-weight: 600; margin: 0; color: #111827; }
.ph p { margin: 4px 0 0; font-size: 14px; color: var(--tx3); }
.acts { display: flex; flex-wrap: wrap; gap: 8px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: 2fr 1fr; }
.card { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.card h2 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--tx2); }
.card h2 small { font-weight: 400; color: var(--tx3); margin-left: 6px; }
.mt { margin-top: 16px; }
.stat .l { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .03em; color: var(--tx3); overflow-wrap: anywhere; }
.stat .v { margin-top: 6px; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.stat.risk { border-color: #fecaca; background: rgba(254,242,242,.6); }
.stat.risk .v { color: var(--red); }
.stat.warn { border-color: #fde68a; background: rgba(255,251,235,.7); }
.stat.warn .v { color: #d97706; }
.stat.ok .v { color: var(--green); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 6px; padding: 6px 12px; font-size: 14px; font-weight: 500; background: var(--pt); color: #fff; white-space: nowrap; }
.btn:hover { opacity: .9; }
.btn:disabled { opacity: .5; }
.btn.sec { background: #fff; color: var(--tx2); border: 1px solid var(--line2); }
.btn.sec:hover { background: #f9fafb; opacity: 1; }
.btn.danger { background: #dc2626; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.link { color: var(--pt); font-size: 14px; }
.link:hover { text-decoration: underline; }
label.f { display: block; font-size: 14px; min-width: 0; }
label.f > span { display: block; margin-bottom: 4px; font-weight: 500; color: var(--tx2); }
.inp { width: 100%; border: 1px solid var(--line2); border-radius: 6px; padding: 6px 10px; font-size: 14px; background: #fff; min-height: 34px; }
.inp:focus { outline: none; border-color: var(--pt); box-shadow: 0 0 0 2px rgba(55,48,163,.25); }
.hint { font-size: 12px; color: var(--tx3); margin-top: 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.filters label.f { width: 170px; }
.filters label.f.grow { flex: 1; min-width: 180px; }
.chk { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--tx2); cursor: pointer; min-height: 34px; }
input[type="checkbox"] { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; flex: none; display: inline-grid; place-content: center; border: 2px solid #6b7280; border-radius: 3px; background: #fff; cursor: pointer; margin: 0; }
input[type="checkbox"]::before { content: ""; width: 10px; height: 10px; transform: scale(0); transition: transform .15s; clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); background: #fff; }
input[type="checkbox"]:checked { border-color: var(--pt); background: var(--pt); }
input[type="checkbox"]:checked::before { transform: scale(1); }
.badge { display: inline-block; border-radius: 4px; padding: 2px 6px; font-size: 12px; font-weight: 500; line-height: 16px; white-space: nowrap; }
.b-gray { background: #f3f4f6; color: #374151; } .b-blue { background: #e0f2fe; color: #075985; }
.b-ind { background: #eef2ff; color: #3730a3; } .b-amber { background: #fef3c7; color: #92400e; }
.b-green { background: #dcfce7; color: #166534; } .b-teal { background: #ccfbf1; color: #115e59; }
.b-red { background: #fee2e2; color: #991b1b; }
.tbl-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--tx3); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #f3f4f6; white-space: nowrap; color: var(--tx2); }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f9fafb; }
td.id { font-weight: 600; color: var(--pt); }
.muted { color: var(--tx3); }
.small { font-size: 12px; }
.empty { border: 1px dashed var(--line2); border-radius: 6px; text-align: center; padding: 28px; color: var(--tx3); font-size: 14px; }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 14px; border-bottom: 1px solid var(--line); }
.bar { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar i { display: block; width: 100%; max-width: 44px; border-radius: 4px 4px 0 0; background: var(--c1); }
.bar b { font-size: 12px; font-weight: 600; color: var(--tx2); margin-bottom: 4px; }
.bar-lbls { display: flex; gap: 10px; margin-top: 6px; }
.bar-lbls > span { flex: 1; min-width: 0; font-size: 11px; color: var(--tx3); text-align: center; line-height: 1.2; }
.bar-lbls .ls { display: none; }
.pair { margin-bottom: 12px; font-size: 13px; }
.pair .nm { display: flex; justify-content: space-between; margin-bottom: 4px; color: var(--tx2); }
.track { height: 8px; background: #f3f4f6; border-radius: 4px; margin-top: 3px; overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 4px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--tx3); margin-bottom: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.shortcuts { display: grid; gap: 6px; }
.shortcuts button { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; font-size: 14px; color: var(--pt); text-align: left; }
.shortcuts button:hover { background: var(--muted); }

/* kanban */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.kcol { background: #e9ebef; border-radius: 8px; padding: 10px; min-height: 260px; transition: background .15s; }
.kcol.over { background: var(--muted); outline: 2px dashed #a5b4fc; }
.kcol h2 { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin: 2px 4px 10px; color: var(--tx2); }
.kcol h2 span { background: #fff; border-radius: 99px; padding: 0 8px; font-size: 12px; color: var(--tx3); }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-bottom: 8px; cursor: grab; font-size: 14px; }
.kcard.drag { opacity: .4; }
.kcard .t { font-weight: 500; color: #1f2937; margin-bottom: 8px; }
.kinfo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--tx3); }
.kinfo .avatar { width: 22px; height: 22px; font-size: 10px; }
.kmove { margin-top: 8px; display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--tx3); }
.kmove select { min-height: 26px; padding: 2px 6px; font-size: 12px; width: auto; }

/* recommendations */
.rec-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; }
.rec-head .crew { font-weight: 600; color: var(--pt); }
.reasons { margin: 10px 0 0; padding-left: 20px; font-size: 14px; color: var(--tx2); line-height: 1.7; }
.why { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.why > div { background: #f9fafb; border-radius: 6px; padding: 12px; font-size: 12px; }
.why p { margin: 0 0 6px; }
.mb { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.mb span:first-child { width: 120px; color: var(--tx3); flex: none; }
.mb .track { flex: 1; height: 6px; margin: 0; background: #e5e7eb; }
.mb .track i { background: var(--pt); }
.mb span:last-child { width: 32px; text-align: right; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.scores td:last-child { text-align: right; }

/* safety */
.mod { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f3f4f6; flex-wrap: wrap; }
.mod:last-child { border-bottom: 0; }
.mod .code { font-size: 12px; font-weight: 600; color: var(--tx3); width: 64px; }
.mod .nm { flex: 1; min-width: 160px; font-size: 14px; color: #1f2937; }
.mod .nm small { display: block; color: var(--tx3); font-size: 12px; }
.read { background: #f9fafb; border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; font-size: 14px; color: var(--tx2); line-height: 1.6; max-height: 180px; overflow-y: auto; }
.read p { margin: 0 0 8px; }
.timer { font-size: 13px; color: var(--amber); margin: 10px 0; }
.stmt { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--tx2); margin: 8px 0; cursor: pointer; }
.stmt input { margin-top: 2px; }
.est-out { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }

/* modal + toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 8px; box-shadow: 0 20px 40px rgba(0,0,0,.2); width: 100%; max-width: 520px; padding: 20px; }
.modal-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-h h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-f { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.form { display: grid; gap: 12px; }
.dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; font-size: 14px; margin: 0; }
.dl dt { font-size: 12px; color: var(--tx3); }
.dl dd { margin: 2px 0 0; color: #1f2937; overflow-wrap: anywhere; }
.steps { display: flex; gap: 4px; margin: 16px 0 4px; }
.steps i { flex: 1; height: 6px; border-radius: 3px; background: #e5e7eb; }
.steps i.done { background: var(--pt); }
.toast-host { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: #111827; color: #fff; border-radius: 8px; padding: 10px 16px; font-size: 14px; box-shadow: 0 10px 20px rgba(0,0,0,.2); animation: tin .2s ease-out; }
.toast.err { background: #dc2626; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 860px) { .g3 { grid-template-columns: 1fr; } }
@media (max-width: 1023px) {
  .side { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .2s; }
  .app.open .side { transform: none; }
  .app.open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35; }
  .side .side-close, .burger { display: inline-flex; }
}
@media (max-width: 900px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g2, .why { grid-template-columns: 1fr; } }
@media (max-width: 767px) {
  .main { padding: 16px 16px 88px; }
  .top { padding: 0 8px 0 16px; }
  .burger { display: none; }
  .crumb .sec-l, .user-txt { display: none; }
  .ph h1 { font-size: 18px; }
  .board { grid-template-columns: 1fr; }
  .kcol { min-height: 0; }
  .filters label.f, .filters label.f.grow { width: 100%; min-width: 0; flex: none; }
  .tabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -1px 3px rgba(0,0,0,.06); padding-bottom: env(safe-area-inset-bottom); }
  .tabs button { flex: 1; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 500; color: var(--tx3); }
  .tabs button::before { content: ""; width: 32px; height: 4px; border-radius: 99px; background: transparent; margin-bottom: 2px; }
  .tabs button.on { color: var(--pt); }
  .tabs button.on::before { background: var(--pt); }
  .tabs svg.i { width: 18px; height: 18px; }
  .dl { grid-template-columns: 1fr; }
  .mod .nm { flex-basis: calc(100% - 76px); }
  .mod .badge { margin-left: 76px; }
  .toast-host { bottom: 76px; }
}
@media (max-width: 420px) { .g4, .est-out { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; } .stat .v { font-size: 20px; } .bars { gap: 4px; } .bar-lbls { gap: 4px; } .bar-lbls > span { font-size: 10px; } .bar-lbls .lf { display: none; } .bar-lbls .ls { display: inline; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
