:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #0f1b2d;
  --ink-2: #3c4a5e;
  --muted: #6b7789;
  --line: #e3e7ed;
  --navy: #0b1a2e;
  --navy-2: #12263f;
  --accent: #f26b1d;
  --accent-soft: #fff1e8;
  --steel: #2f6fb3;
  --steel-soft: #e8f0fa;
  --ok: #1f9d6b;
  --ok-soft: #e4f6ee;
  --warn: #c98a06;
  --warn-soft: #fdf4dc;
  --bad: #d64545;
  --bad-soft: #fde8e8;
  --violet: #7a5af5;
  --violet-soft: #efebff;
  --gray-soft: #eef1f5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15,27,45,.05), 0 4px 16px rgba(15,27,45,.05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --side: 236px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--steel); }

/* Layout */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%); color: #c9d4e3;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 14px; z-index: 40;
}
.side .brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 4px 8px 18px; }
.side .brand svg { width: 32px; height: 32px; }
.side .brand b { font-family: var(--display); font-size: 16px; display: block; line-height: 1.1; }
.side .brand small { font-size: 10px; letter-spacing: 2px; color: #8ea1ba; text-transform: uppercase; }
.side nav { display: grid; gap: 2px; }
.side nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px;
  color: #b8c5d6; text-decoration: none; font-weight: 500;
}
.side nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.active { background: rgba(242,107,29,.16); color: #fff; }
.side nav a.active svg { color: var(--accent); opacity: 1; }
.side nav a .count { margin-left: auto; font-size: 11px; background: rgba(255,255,255,.1); padding: 1px 7px; border-radius: 99px; }
.side .side-foot { margin-top: auto; display: grid; gap: 6px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.side .side-foot button, .side .side-foot a {
  background: none; border: 0; text-align: left; color: #8ea1ba; padding: 8px 12px; border-radius: 8px; cursor: pointer; text-decoration: none; font-size: 13px;
}
.side .side-foot button:hover, .side .side-foot a:hover { background: rgba(255,255,255,.06); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 12px 24px;
}
.menu-btn { display: none; background: none; border: 0; padding: 6px; cursor: pointer; }
.site-select { display: flex; align-items: center; gap: 8px; }
.site-select select { padding: 8px 32px 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-weight: 600; max-width: 300px; cursor: pointer; }
.search { flex: 1; max-width: 420px; position: relative; }
.search input { width: 100%; padding: 9px 12px 9px 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(15,27,45,.14); max-height: 380px; overflow: auto; display: none; z-index: 60;
}
.search-results.open { display: block; }
.search-results .sr { padding: 9px 12px; cursor: pointer; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); }
.search-results .sr:hover, .search-results .sr.hl { background: var(--surface-2); }
.search-results .sr small { color: var(--muted); }
.search-results .sr-kind { font-size: 10.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); width: 50px; flex: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; }
.user-meta { line-height: 1.2; font-size: 13px; }
.user-meta small { color: var(--muted); display: block; font-size: 11.5px; }

.demo-banner { background: var(--accent-soft); color: #8a3a0c; font-size: 13px; padding: 8px 24px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid #fbd9c4; }
.demo-banner b { color: #6b2a05; }
.demo-banner button { margin-left: auto; background: none; border: 0; color: #8a3a0c; cursor: pointer; font-size: 18px; line-height: 1; }

.view { padding: 24px; max-width: 1500px; width: 100%; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.view-head h1 { font-family: var(--display); font-size: 26px; margin: 0; letter-spacing: -.3px; }
.view-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: #c9d1dc; background: var(--surface-2); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #e15f13; border-color: #e15f13; }
.btn-dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-dark:hover { background: var(--navy-2); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #198a5d; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-icon { padding: 6px 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Cards & KPIs */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; gap: 12px; }
.card-h h3 { margin: 0; font-size: 15px; }
.card-h small { color: var(--muted); }
.card-b { padding: 16px 18px 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-family: var(--display); font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.kpi .value small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .sub.good { color: var(--ok); }
.kpi .sub.bad { color: var(--bad); }
.kpi .bar { height: 5px; border-radius: 99px; background: var(--gray-soft); margin-top: 10px; overflow: hidden; }
.kpi .bar i { display: block; height: 100%; border-radius: 99px; }

.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: 1.6fr 1fr; }
.g-2e { grid-template-columns: 1fr 1fr; }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.mt { margin-top: 18px; }

/* Charts */
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.hbar { display: grid; grid-template-columns: 110px 1fr 46px; gap: 10px; align-items: center; margin: 9px 0; font-size: 13px; }
.hbar .track { height: 10px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 99px; }
.hbar b { text-align: right; font-variant-numeric: tabular-nums; }

/* Tables */
.table-wrap { overflow: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #fafbfd; }
.t .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; color: var(--ink-2); }
.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.t .sub { color: var(--muted); font-size: 12px; display: block; }
.t .strong { font-weight: 600; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Badges */
.b { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.b::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b.nodot::before { display: none; }
.b-gray { background: var(--gray-soft); color: #556274; }
.b-blue { background: var(--steel-soft); color: var(--steel); }
.b-green { background: var(--ok-soft); color: var(--ok); }
.b-amber { background: var(--warn-soft); color: var(--warn); }
.b-red { background: var(--bad-soft); color: var(--bad); }
.b-violet { background: var(--violet-soft); color: var(--violet); }
.b-orange { background: var(--accent-soft); color: #c2540f; }
.crit { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-weight: 700; font-size: 11.5px; }
.crit-A { background: var(--bad-soft); color: var(--bad); }
.crit-B { background: var(--warn-soft); color: var(--warn); }
.crit-C { background: var(--gray-soft); color: #556274; }
.health { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.health .track { flex: 1; height: 6px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; }
.health .track i { display: block; height: 100%; }
.health b { font-size: 12px; width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.overdue { color: var(--bad); font-weight: 600; }

/* Filters */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 11px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.chip:hover { border-color: #c9d1dc; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip .n { opacity: .65; margin-left: 4px; font-weight: 500; }
.toolbar select, .toolbar input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; }
.toolbar input { min-width: 200px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.seg button.on { background: var(--navy); color: #fff; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; color: var(--muted); font-size: 13px; gap: 10px; flex-wrap: wrap; }

/* Board */
.board { display: grid; grid-template-columns: repeat(5, minmax(230px, 1fr)); gap: 14px; overflow-x: auto; padding: 16px; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 300px; max-height: 70vh; }
.col-h { padding: 12px 14px; font-weight: 700; font-size: 13px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.col-b { padding: 10px; overflow-y: auto; display: grid; gap: 8px; align-content: start; flex: 1; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.wo-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: grab; box-shadow: 0 1px 2px rgba(15,27,45,.04); }
.wo-card:hover { border-color: #c9d1dc; }
.wo-card .id { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }
.wo-card .ttl { font-weight: 600; margin: 3px 0 6px; font-size: 13px; line-height: 1.35; }
.wo-card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 11.5px; color: var(--muted); }
.more { text-align: center; font-size: 12px; color: var(--muted); padding: 6px; }

/* Drawer & modal */
.scrim { position: fixed; inset: 0; background: rgba(11,26,46,.4); z-index: 80; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 90;
  transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(15,27,45,.18);
}
.drawer.open { transform: none; }
.drawer-h { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.drawer-h h2 { margin: 2px 0 0; font-size: 19px; font-family: var(--display); line-height: 1.25; }
.drawer-h .kicker { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }
.drawer-h .x { margin-left: auto; background: none; border: 0; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; }
.drawer-b { padding: 20px 22px; overflow-y: auto; flex: 1; }
.drawer-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; background: var(--surface-2); }
.dl { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin: 0 0 20px; }
.dl div dt { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.dl div dd { margin: 3px 0 0; font-weight: 500; }
.sec-t { font-size: 13px; font-weight: 700; margin: 22px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 0 0 14px 16px; position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--steel); }
.timeline li small { color: var(--muted); display: block; }
.mini-list { display: grid; gap: 6px; }
.mini { display: flex; gap: 10px; align-items: center; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font-size: 13px; }
.mini:hover { background: var(--surface-2); }
.mini .grow { flex: 1; min-width: 0; }
.mini .grow small { color: var(--muted); display: block; }
.ring { width: 96px; height: 96px; flex: none; }
.ring text { font-family: var(--display); font-weight: 700; }
.asset-hero { display: flex; gap: 18px; align-items: center; margin-bottom: 18px; padding: 14px; background: var(--surface-2); border-radius: 12px; }
.asset-hero .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; flex: 1; }
.asset-hero .stats b { display: block; font-family: var(--display); font-size: 18px; }
.asset-hero .stats span { font-size: 11.5px; color: var(--muted); }
.desc { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; color: var(--ink-2); line-height: 1.55; margin: 0 0 18px; }

.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -48%) scale(.98); width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 40px);
  background: var(--surface); border-radius: 16px; z-index: 100; opacity: 0; pointer-events: none; transition: all .2s ease; display: flex; flex-direction: column;
  box-shadow: 0 30px 80px rgba(11,26,46,.3);
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.modal-h { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-h h2 { margin: 0; font-size: 18px; font-family: var(--display); }
.modal-h .x { margin-left: auto; background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); }
.modal-b { padding: 20px 22px; overflow-y: auto; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.f { display: grid; gap: 5px; }
.f.full { grid-column: 1 / -1; }
.f label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.f input, .f select, .f textarea { padding: 9px 11px; border: 1px solid #cfd6e0; border-radius: 8px; background: #fff; }
.f textarea { min-height: 90px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus, .toolbar input:focus, .toolbar select:focus, .search input:focus { outline: 2px solid rgba(242,107,29,.3); border-color: var(--accent); }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .f { min-width: 120px; }

.toast-wrap { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 200; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: 13.5px; display: flex; gap: 10px; align-items: center; animation: tin .25s ease; max-width: 380px; }
.toast i { width: 8px; height: 8px; border-radius: 50%; background: #4fd1a1; flex: none; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* Calendar strip */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .d { border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; min-height: 58px; background: var(--surface); font-size: 11.5px; color: var(--muted); }
.cal .d b { display: block; font-family: var(--display); font-size: 17px; color: var(--ink); margin-top: 2px; }
.cal .d.today { border-color: var(--accent); background: var(--accent-soft); }
.cal .d.l1 b { color: var(--steel); }
.cal .d.l2 { background: var(--steel-soft); }
.cal .d.l3 { background: #d4e3f5; }
.cal .dow { font-size: 11px; text-align: center; color: var(--muted); font-weight: 600; }

/* Team */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tech { padding: 16px; }
.tech-top { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.tech-top .avatar { width: 42px; height: 42px; font-size: 14px; }
.tech-top b { display: block; }
.tech-top small { color: var(--muted); }
.tech-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; background: var(--surface-2); border-radius: 10px; padding: 10px 6px; }
.tech-stats b { display: block; font-family: var(--display); font-size: 18px; }
.tech-stats span { font-size: 11px; color: var(--muted); }
.util { margin-top: 12px; font-size: 12px; color: var(--muted); }
.util .track { height: 6px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; margin-top: 5px; }
.util .track i { display: block; height: 100%; background: var(--steel); }

.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button { width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; line-height: 1; }
.qty button:hover { background: var(--surface-2); }
.qty b { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }

/* Responsive */
@media (max-width: 1200px) {
  .g-2, .g-3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .25s ease; }
  .side.open { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.3); }
  .menu-btn { display: block; }
  .user-meta { display: none; }
  .g-2e { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .top { padding: 10px 16px; flex-wrap: wrap; }
  .search { order: 5; max-width: none; flex-basis: 100%; }
  .site-select select { max-width: 200px; }
  .view { padding: 16px; }
  .demo-banner { padding: 8px 16px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 22px; }
  .dl, .form { grid-template-columns: 1fr; }
  .asset-hero { flex-direction: column; align-items: stretch; }
  .top-right .btn span { display: none; }
  .hbar { grid-template-columns: 90px 1fr 40px; }
  .toolbar input { min-width: 0; flex: 1; }
}
