:root { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; background: #f4f6f8; color: #0f172a; font-size: 16px; }
a { color: inherit; }
button, input, select { font: inherit; }
h1 { margin: 0 0 6px; font-size: 28px; }
h2 { margin: 0 0 8px; font-size: 18px; }
h3 { margin: 16px 0 6px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: #94a3b8; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid #e8edf3; border-radius: 24px; box-shadow: 0 20px 40px rgba(15, 23, 42, .08); padding: 32px; }
.login-icon { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 16px; overflow: hidden; box-shadow: 0 8px 20px rgba(15, 23, 42, .12); }
.login-icon img { width: 100%; height: 100%; display: block; }
.login-card h1, .sub, .hint { text-align: center; }
.sub { color: #64748b; margin: 6px 0 18px; }
.hint { color: #94a3b8; font-size: 13px; margin: 18px 0 0; }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: #111827; color: #e5e7eb; display: flex; flex-direction: column; padding: 18px 14px; }
.brand { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; padding: 4px 8px 16px; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.brand strong { display: block; font-size: 16px; }
.brand small { color: #9ca3af; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { text-decoration: none; color: #d1d5db; border-radius: 10px; padding: 10px 12px; font-weight: 700; }
.sidebar nav a[aria-current="page"] { background: #fff; color: #111827; }
.side-foot { margin-top: auto; padding: 14px 8px 0; }
.who { display: flex; gap: 8px; align-items: center; color: #e5e7eb; font-size: 13px; margin-bottom: 8px; min-width: 0; }
.who span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.side-foot button { background: transparent; color: #e5e7eb; border: 1px solid #374151; border-radius: 10px; padding: 8px 12px; cursor: pointer; }

main { padding: 28px; max-width: 1360px; }
.lead { margin: 0 0 18px; color: #64748b; }
.banner { border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; font-weight: 700; }
.banner.ok { background: #ecfdf5; color: #065f46; }
.banner.err { background: #fef2f2; color: #b91c1c; }
.muted { color: #64748b; font-size: 14px; }
.empty { color: #64748b; }

.panel { background: #fff; border: 1px solid #e6ebf2; border-radius: 18px; padding: 18px; margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tile { display: block; background: #fff; border: 1px solid #e6ebf2; border-radius: 18px; padding: 18px; text-decoration: none; }
.tile:hover { border-color: #c7d2fe; }
.tile img { width: 48px; height: 48px; border-radius: 12px; }
.tile h2 { margin: 12px 0 6px; }
.tile p { margin: 0; color: #64748b; font-size: 14px; }
.tile span { display: inline-block; margin-top: 14px; color: #4f46e5; font-weight: 800; font-size: 14px; }

.ask { background: #fff; border: 1px solid #e6ebf2; border-radius: 18px; padding: 16px; margin-bottom: 16px; }
.ask-row { display: flex; gap: 8px; align-items: end; }
.ask-row input[type="search"] { width: auto; flex: 1; font-size: 18px; padding: 14px 16px; }
.ask-row .btn { height: 52px; }
.date { margin: 0; font-size: 12px; font-weight: 800; color: #64748b; }
.date input { display: block; margin-top: 4px; width: 148px; height: 52px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.examples a { background: #fff; border: 1px solid #e6ebf2; border-radius: 999px; padding: 8px 12px; text-decoration: none; font-weight: 700; color: #334155; }
.note { margin: 0 0 16px; color: #64748b; font-weight: 700; }
.results { display: grid; gap: 14px; }
.result { background: #fff; border: 1px solid #e6ebf2; border-radius: 18px; padding: 18px; }
.result-top { display: flex; gap: 10px; align-items: center; }
.result h2 { margin: 0; }
.tag { background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 800; }
.figure { margin: 12px 0 8px; font-size: 42px; font-weight: 800; letter-spacing: -0.03em; }
.figure small { font-size: 18px; font-weight: 700; color: #64748b; }
.result ul { margin: 0 0 12px; padding-left: 18px; color: #475569; }
.result .open { color: #4f46e5; font-weight: 800; text-decoration: none; }

.online { border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; background: #fff; border: 1px solid #e6ebf2; font-weight: 700; }
.online.on { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.invite, .search { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search { margin: 8px 0 14px; }
.invites { list-style: none; margin: 14px 0 0; padding: 0; }
.invites li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid #f1f5f9; }
.invites li span:first-child { font-weight: 700; }
.invites form { margin-left: auto; }

label.field { display: block; font-size: 13px; font-weight: 700; color: #64748b; margin: 0 0 12px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"], input:not([type]), select {
  width: 100%; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 10px 12px; color: #0f172a; font-weight: 600;
}
label.field input, label.field select { margin-top: 6px; }
.invite input, .invite select, .search input { width: auto; flex: 1; min-width: 180px; }
label.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 700; margin: 0 0 12px; }
label.check input { width: 18px; height: 18px; margin-top: 2px; }
label.check .muted { display: block; font-weight: 500; }

.btn { border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 800; cursor: pointer; text-decoration: none; display: inline-block; }
.btn.indigo { background: #4f46e5; color: #fff; }
.btn.dark { background: #0f172a; color: #fff; }
.btn.ghost { background: #f1f5f9; color: #334155; }
.btn.amber { background: #d97706; color: #fff; }
.btn.danger { background: transparent; color: #dc2626; padding-left: 8px; padding-right: 8px; }
.btn.wide { width: 100%; }
.btn:hover { filter: brightness(.97); }

.split { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 14px; align-items: start; }
.person-list { background: #fff; border: 1px solid #e6ebf2; border-radius: 18px; overflow: auto; max-height: calc(100vh - 280px); }
.person { display: flex; gap: 10px; align-items: center; padding: 12px 14px; text-decoration: none; border-bottom: 1px solid #f1f5f9; }
.avatar { width: 36px; height: 36px; border-radius: 999px; object-fit: cover; background: #e0e7ff; color: #3730a3; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.person-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.person-head h2 { margin: 0; }
.person.on { background: #eef2ff; }
.person strong, .person small { display: block; }
.person small { color: #64748b; font-weight: 600; margin-top: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; margin-top: 6px; flex: none; font-style: normal; }
.dot.online { background: #10b981; }
.dot.recent { background: #f59e0b; }
.person-card form { margin-top: 16px; }
.quiet { border-top: 1px solid #f1f5f9; padding-top: 8px; }

.roles-layout { display: grid; grid-template-columns: 280px 1fr; gap: 14px; align-items: start; }
.role-list { display: grid; gap: 8px; position: sticky; top: 16px; max-height: calc(100vh - 120px); overflow: auto; }
.role-link { display: block; background: #fff; border: 1px solid #e6ebf2; border-radius: 14px; padding: 12px; text-decoration: none; }
.role-link.on { border-color: #818cf8; background: #eef2ff; }
.role-link strong, .role-link small, .role-link code, .role-link em { display: block; }
.role-link small { color: #64748b; margin-top: 4px; }
.role-link code, code { font-size: 12px; background: #f1f5f9; padding: 2px 6px; border-radius: 6px; }
.role-link em, .mod em { font-style: normal; color: #b45309; font-size: 12px; font-weight: 800; }
.role-new { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; align-items: end; }
.role-new .btn { height: 44px; }
details summary { cursor: pointer; font-weight: 800; }
.proj { border: 1px solid #e6ebf2; border-radius: 14px; margin-top: 12px; overflow: hidden; }
.proj.on { background: #f0fdf4; }
.proj-h { padding: 12px 14px; margin: 0; }
.proj-b { padding: 0 14px 12px; }
.mod { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid #e2e8f0; }
.mod .check { margin: 0; }
.mod.off .mps { display: none; }
.mps { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.mps label { display: flex; gap: 4px; align-items: center; margin: 0; font-size: 13px; font-weight: 800; color: #334155; white-space: nowrap; }
.mps input { width: 16px; height: 16px; }
.savebar { position: sticky; bottom: 0; background: #fff; padding: 12px 0 0; }
.empty-side { color: #64748b; }

.issued { background: #fffbeb; border-color: #fcd34d; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
pre { white-space: pre-wrap; background: #fff; border: 1px solid #fcd34d; border-radius: 12px; padding: 12px; font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; color: #94a3b8; padding: 0 8px 8px 0; }
td { padding: 10px 8px 10px 0; border-top: 1px solid #f1f5f9; vertical-align: middle; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
tr.dead { color: #94a3b8; }
input[readonly] { background: #fff; }

.proj-switch { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 20px; }
.proj-chip { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid #e6ebf2; border-radius: 14px; padding: 10px 16px 10px 10px; text-decoration: none; font-weight: 800; color: #334155; }
.proj-chip img { width: 32px; height: 32px; border-radius: 9px; }
.proj-chip:hover { border-color: #c7d2fe; }
.proj-chip.on { border-color: #4f46e5; background: #eef2ff; color: #3730a3; box-shadow: 0 6px 16px rgba(79, 70, 229, .12); }
.proj-chip.off { opacity: .5; }
.proj-chip.fav { margin-left: auto; padding-left: 12px; }
.fav-mark { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; color: #e11d48; }
.fav-mark svg { width: 18px; height: 18px; fill: currentColor; }
.heart { width: 36px; height: 36px; border-radius: 999px; border: 1px solid #e2e8f0; background: #fff; color: #cbd5e1; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.heart svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.heart.on { color: #e11d48; border-color: #fecdd3; background: #fff1f2; }
.heart.on svg { fill: currentColor; }
.heart:hover { color: #e11d48; border-color: #fecdd3; }
.dismiss { width: 22px; height: 22px; border: 0; background: transparent; color: #d5dde8; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.dismiss svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.dismiss:hover { color: #64748b; }
.proj-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin: 0 0 16px; }
.proj-head .tag { display: inline-block; margin-bottom: 6px; }
.proj-head h2 { margin: 0 0 4px; font-size: 24px; }
.proj-head p { margin: 0; }
.proj-head-actions { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.period { display: flex; gap: 8px; align-items: flex-end; margin: 0; }
.period .btn { height: 44px; }
.proj-head-actions .btn.indigo { height: 44px; display: inline-flex; align-items: center; }

.add-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: #4f46e5; border-style: dashed; border-width: 2px; border-color: #c7d2fe; background: #fbfcff; min-height: 160px; font-weight: 800; }
.add-tile:hover { background: #eef2ff; }
.add-plus { font-size: 34px; line-height: 1; font-weight: 800; }
.add-panel { margin-top: 18px; }
.add-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.add-head h2 { margin: 0; font-size: 18px; }
.add-list { list-style: none; margin: 10px 0 0; padding: 0; }
.add-list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid #f1f5f9; }
.add-list li span { font-weight: 700; }

.section-label { margin: 22px 0 12px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: #94a3b8; }
.mosaic { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 14px; align-items: start; }
.widget { background: #fff; border: 1px solid #e6ebf2; border-radius: 18px; margin: 0; overflow: hidden; padding-bottom: 14px; }
.widget[data-id] { cursor: grab; }
.widget.dragging { cursor: grabbing; box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18); }
.drag-gap { border: 1px dashed #c7d2fe; border-radius: 18px; background: #eef2ff; min-height: 88px; }
.widget-h { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 16px 18px; border-bottom: 1px solid #f1f5f9; }
.widget-h h2 { margin: 0; font-size: 20px; }
.widget-id { display: flex; gap: 12px; align-items: center; min-width: 0; }
.widget-icon { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; }

.kpi { padding: 16px 18px 6px; }
.kpi-main { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.kpi-value { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; color: #0f172a; }
.kpi-value.good { color: #047857; }
.kpi-value.mid { color: #b45309; }
.kpi-value.bad { color: #b91c1c; }
.kpi-unit { font-size: 20px; font-weight: 700; color: #94a3b8; margin-left: 4px; }
.kpi-delta { display: inline-flex; align-items: baseline; gap: 5px; font-size: 15px; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: #f1f5f9; color: #475569; }
.kpi-delta.good { background: #ecfdf5; color: #047857; }
.kpi-delta.bad { background: #fef2f2; color: #b91c1c; }
.kpi-delta em { font-style: normal; font-weight: 600; opacity: .75; font-size: 12px; }
.kpi-label { display: block; margin-top: 6px; color: #64748b; font-weight: 700; font-size: 13px; }

.zones { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 18px 2px; }
.zone { display: inline-flex; align-items: baseline; gap: 6px; font-weight: 800; font-size: 15px; color: #334155; background: #f8fafc; border: 1px solid #eef2f7; border-radius: 10px; padding: 5px 10px; }
.zone i { width: 9px; height: 9px; border-radius: 50%; align-self: center; }
.zone.good i { background: #10b981; }
.zone.mid i { background: #f59e0b; }
.zone.bad i { background: #ef4444; }
.zone em { font-style: normal; font-weight: 600; font-size: 12px; color: #94a3b8; }

.more { margin-top: 2px; }
.more summary { color: #4f46e5; font-weight: 800; font-size: 13px; padding: 4px 0; }
.more > .bar-row { margin-top: 6px; }
.widget-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.widget-actions form { margin: 0; }
.widget-actions .open { color: #4f46e5; font-weight: 800; text-decoration: none; }
.widget[data-id] .widget-actions button { cursor: pointer; }
.widget-note { padding: 14px 18px; }
.widget-body { min-height: 72px; }
.pending { color: #94a3b8; }
.widget[data-pending] .pending { animation: pending-pulse 1.1s ease-in-out infinite; }
@keyframes pending-pulse { 50% { opacity: .35; } }
.bars { padding: 14px 18px 6px; display: grid; gap: 8px; }
.group-label { margin: 0 0 2px; color: #64748b; font-size: 13px; font-weight: 700; }
.bar-row { display: grid; grid-template-columns: minmax(72px, 140px) 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.bar-row b { font-variant-numeric: tabular-nums; }
.bar-track { background: #f1f5f9; border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; min-width: 0; transition: width .35s ease; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px 0; }
.chips form { margin: 0; }
.chips a, .chips button { border: 1px solid #e2e8f0; background: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: 13px; text-decoration: none; color: #334155; cursor: pointer; }
.chips .on, .chips a.on { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.chart-title { padding: 14px 18px 0; margin: 0; }
.chart { width: 100%; height: auto; display: block; background: linear-gradient(#f8fafc, #fff); }
.chart .grid-line { stroke: #e9eef5; stroke-width: 1; }
.chart .grid-label { fill: #b2bccb; font-size: 12px; font-weight: 700; }
.chart .chart-last { font-size: 15px; font-weight: 800; }
.bar-fill.good { background: #10b981; }
.bar-fill.mid { background: #f59e0b; }
.bar-fill.bad { background: #ef4444; }
.bar-fill.muted { background: #94a3b8; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; padding: 0 18px 10px; color: #64748b; font-size: 13px; font-weight: 700; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 99px; margin-right: 6px; }
.legend .axis { font-weight: 600; }
table.grid th, table.grid td { padding: 8px 12px; white-space: nowrap; }
table.grid th { background: #f8fafc; }
table.grid a { color: #2563eb; font-weight: 800; text-decoration: none; }
td.good { color: #047857; font-weight: 800; }
td.mid { color: #b45309; font-weight: 800; }
td.bad { color: #b91c1c; font-weight: 800; }
.caption { margin: 0; padding: 8px 18px 14px; color: #64748b; font-size: 13px; }
.bars .caption { padding: 4px 0 8px; }

@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; }
  body { background: #0e1218; color: #e8edf5; }
  .lead, .muted, .empty, .sub, .hint, .tile p, .date, .note, .result ul, .person small,
  .role-link small, label.field, .group-label, .legend, .caption, .kpi-label, .figure small,
  h3 { color: #93a0b4; }
  .login-card, .panel, .tile, .ask, .result, .online, .person-list, .role-link, .widget,
  .proj-chip, .examples a, .savebar, pre, .add-panel, .heart { background: #1c2330; border-color: #2c3544; color: #e8edf5; }
  .sidebar nav a[aria-current="page"] { background: #243044; color: #f8fafc; }
  input[type="text"], input[type="email"], input[type="password"], input[type="search"],
  input[type="date"], input:not([type]), select, input[readonly] {
    background: #121820; border-color: #343d4e; color: #e8edf5;
  }
  .btn.ghost, .chips a, .chips button { background: #243044; color: #d5dce6; border-color: #343d4e; }
  .chips .on, .chips a.on { background: #4f46e5; color: #fff; border-color: #4f46e5; }
  .btn.dark, .tab.on { background: #e8edf5; color: #0e1218; }
  .banner.ok, .online.on, .proj.on { background: #143028; color: #a7f3d0; border-color: #1f6b4a; }
  .banner.err { background: #3f1d24; color: #fecaca; }
  .tag, .person.on, .role-link.on, .proj-chip.on { background: #241f4a; color: #c7d2fe; }
  .kpi-value { color: #f8fafc; }
  .kpi-value.good, td.good { color: #34d399; }
  .kpi-value.mid, td.mid { color: #fbbf24; }
  .kpi-value.bad, td.bad { color: #f87171; }
  .kpi-delta { background: #243044; color: #d5dce6; }
  .kpi-delta.good { background: #143028; color: #6ee7b7; }
  .kpi-delta.bad { background: #3f1d24; color: #fca5a5; }
  .zone { background: #171d27; border-color: #2c3544; color: #d5dce6; }
  .bar-track, code, .role-link code { background: #243044; }
  td, .invites li, .add-list li, .quiet, .mod, .widget-h { border-color: #2a3342; }
  table.grid th { background: #171d27; }
  table.grid a, .result .open, .tile span, .more summary, .widget-actions .open { color: #a5b4fc; }
  .chart { background: #1c2330; }
  .chart .grid-line { stroke: #2a3342; }
  .chart .grid-label, .chart text { fill: #93a0b4; }
  .heart.on { background: #3f1d24; border-color: #7f1d1d; color: #fb7185; }
  .add-tile { background: #171d27; border-color: #4338ca; color: #a5b4fc; }
  .issued { background: #3a2e14; border-color: #92400e; }
  .drag-gap { background: #241f4a; border-color: #4338ca; }
  .proj { border-color: #2c3544; }
  .mps label { color: #d5dce6; }
  .empty-side { color: #93a0b4; }
}

@media (max-width: 900px) {
  .app { display: block; }
  .sidebar { min-height: 0; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; }
  main { padding: 16px; }
  .split, .roles-layout, .role-new, .three { display: block; }
  .role-list, .person-list { position: static; max-height: 240px; margin-bottom: 12px; }
  .mod { grid-template-columns: 1fr; }
  .ask-row { display: block; }
  .ask-row input[type="search"] { width: 100%; display: block; }
  .date { display: block; margin-top: 8px; }
  .ask-row .btn { width: 100%; margin-top: 8px; height: auto; }
  .date input { width: 100%; }
  .mosaic { grid-template-columns: 1fr; }
  .proj-head { display: block; }
  .proj-head-actions { margin-top: 12px; }
  .period { flex-wrap: wrap; }
  .widget-h { display: block; }
  .widget-actions { margin-top: 12px; }
  .hide-sm { display: none; }
  .bar-row { grid-template-columns: 72px 1fr auto; }
}
