:root {
  --slb: #0014dc;
  --slb-dark: #051464;
  --slb-soft: #e8ebfd;
  --ink: #141a33;
  --muted: #5b6382;
  --line: #dfe3ef;
  --bg: #f4f6fb;
  --card: #ffffff;
  --ok: #15803d;
  --ok-soft: #e3f5ea;
  --warn: #b45309;
  --warn-soft: #fff3df;
  --bad: #b91c1c;
  --bad-soft: #fde8e8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 26, 51, .06), 0 4px 16px rgba(20, 26, 51, .05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); font-size: 14px; line-height: 1.45; }
a { color: var(--slb); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: #b9c0d8; }
.btn.primary { background: var(--slb); border-color: var(--slb); color: #fff; }
.btn.primary:hover { background: #0010b5; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--slb); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: default; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid rgba(0, 20, 220, .35); outline-offset: 1px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 4px; }

/* login */
.auth-page { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(135deg, var(--slb-dark), var(--slb) 70%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.auth-card .logo { height: 54px; margin: -8px 0 6px -14px; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card .btn.primary { width: 100%; justify-content: center; padding: 10px; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--slb-soft); color: var(--slb-dark); margin: 12px 0; font-size: 13px; }
.notice.error { background: var(--bad-soft); color: var(--bad); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

/* app shell */
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 16px; gap: 14px; position: sticky; top: 0; z-index: 20; }
.topbar .logo { height: 40px; margin-left: -10px; }
.topbar .title { font-weight: 700; color: var(--slb-dark); }
.topbar .title small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.viewas { display: flex; align-items: center; gap: 6px; background: var(--warn-soft); border: 1px solid #f5d29a; padding: 4px 8px; border-radius: 8px; font-size: 12px; }
.viewas select { width: 230px; padding: 3px 6px; font-size: 12px; }
.userchip { text-align: right; font-size: 12px; line-height: 1.2; }
.userchip b { display: block; font-size: 13px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: calc(100vh - 56px); }
.layout.no-chat { grid-template-columns: minmax(0, 1fr); }
.main { overflow: auto; padding: 20px; }
.chat { border-left: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; min-height: 0; }
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .chat { border-left: 0; border-top: 1px solid var(--line); height: 70vh; }
  .viewas select { width: 150px; }
  .userchip { display: none; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.pagehead { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.pagehead h1 { font-size: 22px; color: var(--slb-dark); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; background: var(--slb-soft); color: var(--slb-dark); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.gray { background: #eef0f5; color: var(--muted); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .v { font-size: 24px; font-weight: 700; color: var(--slb-dark); font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi.good .v { color: var(--ok); }
.kpi.bad .v { color: var(--bad); }
.kpi.warn .v { color: var(--warn); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tab { border: 0; background: none; padding: 9px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--slb); border-color: var(--slb); }

/* tables */
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.grid th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfe; position: sticky; top: 0; z-index: 1; }
table.grid tr.clickable { cursor: pointer; }
table.grid tr.group-row td { background: #eef2fb; border-bottom: 1px solid var(--line); padding: 8px; }
table.grid tr.group-row[data-group] { cursor: pointer; user-select: none; }
table.grid tr.group-row .caret { display: inline-block; width: 14px; color: var(--muted); }
table.grid tr.clickable:hover td { background: #f6f8ff; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; max-height: 62vh; border: 1px solid var(--line); border-radius: 8px; }
.table-wrap table.grid th { border-top: 0; }
input.count { width: 70px; text-align: right; padding: 4px 6px; }

/* utilization bars */
.util { display: grid; grid-template-columns: 220px 1fr 64px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.util:last-child { border-bottom: 0; }
.bar { position: relative; height: 14px; background: #eef0f6; border-radius: 7px; overflow: hidden; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--slb); border-radius: 7px; }
.bar.low > i { background: #e0a43a; }
.bar.high > i { background: var(--bad); }
.bar .target { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); left: 75%; opacity: .5; }
@media (max-width: 700px) { .util { grid-template-columns: 120px 1fr 48px; } }

/* timeline */
.timeline { position: relative; overflow-x: auto; }
.tl-inner { min-width: 980px; position: relative; }
.tl-months, .tl-row { display: grid; grid-template-columns: 200px 1fr; }
.tl-months { position: sticky; top: 0; background: #fff; z-index: 3; border-bottom: 1px solid var(--line); }
.tl-months .cells { display: grid; grid-template-columns: repeat(12, 1fr); }
.tl-months .cells div { font-size: 11px; color: var(--muted); padding: 6px 4px; border-left: 1px solid var(--line); font-weight: 600; }
.tl-months .q { font-size: 11px; color: var(--slb-dark); }
.tl-row { border-bottom: 1px solid var(--line); min-height: 40px; }
.tl-name { padding: 8px 8px 8px 0; font-weight: 600; font-size: 12px; display: flex; flex-direction: column; justify-content: center; }
.tl-name small { font-weight: 400; color: var(--muted); }
.tl-track { position: relative; background-image: linear-gradient(to right, var(--line) 1px, transparent 1px); background-size: calc(100% / 12) 100%; }
.tl-lock { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, rgba(21, 128, 61, .06), rgba(21, 128, 61, .06) 6px, transparent 6px, transparent 12px); pointer-events: none; }
.tl-bar { position: absolute; height: 22px; border-radius: 5px; color: #fff; font-size: 10.5px; padding: 3px 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); border: 1px solid rgba(255, 255, 255, .5); }
.tl-bar:hover { filter: brightness(1.1); z-index: 2; }
.tl-bar.guest { background: repeating-linear-gradient(45deg, #f59e0b, #f59e0b 6px, #f7b23d 6px, #f7b23d 12px) !important; color: #3d2600; }
.tl-bar.locked { outline: 2px solid var(--ok); }
.tl-bar.mine { outline: 2px solid #111; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* wizard */
.steps { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-weight: 600; color: var(--muted); cursor: pointer; }
.step b { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #eef0f5; font-size: 12px; }
.step.active { color: var(--slb); border-color: var(--slb); }
.step.active b { background: var(--slb); color: #fff; }
.step.done b { background: var(--ok); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; background: #fff; user-select: none; }
.chip.on { background: var(--slb); border-color: var(--slb); color: #fff; }
.chip.off-team { border-style: dashed; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.person { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.person.on { border-color: var(--slb); background: #f7f8ff; }
.person .meta { flex: 1; min-width: 0; }
.person .meta b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .meta span { font-size: 11px; color: var(--muted); }
.person input.leave { width: 64px; padding: 3px 6px; text-align: right; }
.stickybar { position: sticky; bottom: -20px; background: rgba(244, 246, 251, .95); padding: 12px 0; display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line); margin-top: 8px; flex-wrap: wrap; }

/* chat */
.chat-head { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chat-head h3 { display: flex; align-items: center; gap: 8px; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; }
.msg.user { align-self: flex-end; background: var(--slb); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: #f1f3f9; border-bottom-left-radius: 4px; }
.msg.assistant ul { margin: 4px 0; padding-left: 18px; }
.msg.assistant p { margin: 4px 0; }
.msg.thinking { color: var(--muted); font-style: italic; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 8px; }
.chat-input { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { resize: none; height: 64px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 14, 40, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal h2 { margin-bottom: 4px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }
.toast.error { background: var(--bad); }
.overlay { position: fixed; inset: 0; background: rgba(255, 255, 255, .75); display: grid; place-items: center; z-index: 55; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--slb-soft); border-top-color: var(--slb); border-radius: 50%; animation: spin .9s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.md ul { margin: 6px 0; padding-left: 20px; }
.md li { margin: 3px 0; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }
.quarters { display: flex; gap: 6px; flex-wrap: wrap; }
.qbtn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 600; font-size: 12px; }
.qbtn.on { background: var(--ok-soft); border-color: #9bd3ae; color: var(--ok); }
.overlay.boot { background: var(--bg); text-align: center; }
