:root {
  --bg: #F5F6FA;
  --surface: #FFFFFF;
  --surface-2: #F8F9FC;
  --border: #E7E9F0;
  --grid: #EEF0F5;
  --text: #1A1D29;
  --text-2: #5E6478;
  --text-3: #9095A6;
  --accent: #4F5BEA;
  --accent-soft: #EEF0FE;
  --good: #1F9D60;
  --good-soft: #E8F6EE;
  --warning: #D9822B;
  --warning-soft: #FDF2E6;
  --critical: #E0384B;
  --critical-soft: #FDECEE;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 2px 8px rgba(20, 24, 40, .04);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  font-size: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; }

/* Layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.main { padding: 28px 32px 48px; min-width: 0; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #4F5BEA, #8B5CF6); display: grid; place-items: center; color: #fff; font-size: 15px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.sidebar .spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 10px; padding: 12px 10px 0; margin-top: 8px; border-top: 1px solid var(--border); }
.user .avatar { margin-left: 0; width: 32px; height: 32px; font-size: 11.5px; }
.user b { display: block; font-size: 13px; font-weight: 600; }
.user span { font-size: 12px; color: var(--text-3); }

/* Page header */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 6px 0 0; color: var(--text-2); }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back { display: inline-flex; gap: 6px; align-items: center; color: var(--text-2); font-size: 13px; margin-bottom: 10px; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 32px 0 14px; }
.section-head h2 { font-size: 17px; font-weight: 600; }
.link-more { font-size: 13px; font-weight: 500; }

/* Controls */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; font-weight: 500;
}
.btn:hover { border-color: #D3D6E0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #4350D8; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.select {
  height: 34px; padding: 0 30px 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  font: inherit; font-size: 13px; font-weight: 500; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%239095A6' stroke-width='2'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: #EDEFF5; }
.seg button { border: 0; background: none; height: 28px; padding: 0 12px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); margin: 4px 0 20px; }
.tabs button { border: 0; background: none; padding: 10px 0; font-size: 13.5px; font-weight: 500; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-color: var(--accent); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
a.card { color: inherit; }
.card h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-5 { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.span-2 { grid-column: span 2; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); font-size: 12px; }

/* Alerts */
.alert { display: block; border-radius: var(--radius); padding: 16px 18px; border: 1px solid; color: var(--text); transition: transform .12s; }
.alert:hover { transform: translateY(-1px); }
.alert.critical { background: var(--critical-soft); border-color: #F7CDD3; }
.alert.warning { background: var(--warning-soft); border-color: #F5DCC0; }
.alert.info { background: var(--accent-soft); border-color: #D9DCFB; }
.alert-top { display: flex; align-items: center; gap: 10px; }
.alert-num { font-size: 26px; font-weight: 700; }
.alert.critical .alert-num { color: var(--critical); }
.alert.warning .alert-num { color: var(--warning); }
.alert.info .alert-num { color: var(--accent); }
.alert-title { font-weight: 600; }
.alert ul { margin: 10px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--text-2); display: grid; gap: 4px; }

/* Team cards */
.team-card { display: flex; flex-direction: column; gap: 12px; color: var(--text); transition: border-color .12s; }
.team-card:hover { border-color: #CDD1F7; }
.team-title { display: flex; align-items: center; gap: 10px; }
.team-title b { display: block; font-weight: 600; }
.team-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 13px; flex: none; }
.team-icon.lg { width: 44px; height: 44px; border-radius: 11px; font-size: 18px; }
.ai { font-size: 12.5px; color: var(--text-2); line-height: 1.45; padding: 10px; border-radius: 8px; background: var(--surface-2); }
.ai b { color: var(--accent); font-weight: 600; }

.progress { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-2); }
.progress-bar { flex: 1; height: 6px; border-radius: 3px; background: #EDEFF5; overflow: hidden; }
.progress-bar i { display: block; height: 100%; border-radius: 3px; background: var(--c, var(--accent)); }

.avatars { display: flex; align-items: center; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 10.5px; font-weight: 600; border: 2px solid var(--surface); margin-left: -6px; flex: none; }
.avatars .avatar:first-child { margin-left: 0; }
.avatars .more { margin-left: 6px; font-size: 12px; color: var(--text-3); }

/* Goals */
.goal-card { display: flex; flex-direction: column; gap: 6px; }
.goal-top { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text-2); font-size: 13px; }
.goal-icon { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.goal-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.good { color: var(--good); }
.warning { color: var(--warning); }
.critical { color: var(--critical); }
.goal-icon.good { background: var(--good-soft); }
.goal-icon.warning { background: var(--warning-soft); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.work { background: var(--accent-soft); color: var(--accent); }
.pill.open { background: #F0F1F5; color: var(--text-2); }
.pill.done { background: var(--good-soft); color: var(--good); }
.pill.risk { background: var(--critical-soft); color: var(--critical); }
.pill.plain::before { display: none; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); padding: 0 12px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: center; font-variant-numeric: tabular-nums; }
.table a.row-link { color: var(--text); font-weight: 500; display: inline-flex; align-items: center; gap: 10px; }
.key { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.score { display: flex; align-items: center; gap: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score .progress-bar { max-width: 80px; }

/* Gantt */
.gantt { --lw: 220px; --cols: 13; position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.g-head, .g-lane { display: grid; grid-template-columns: var(--lw) 1fr; }
.g-head { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.g-head .g-label { font-size: 12px; color: var(--text-3); padding: 10px 16px; align-self: end; }
.g-scale { display: grid; grid-template-columns: repeat(var(--cols), 1fr); }
.g-month { font-size: 12px; font-weight: 600; text-align: center; padding: 8px 0 4px; border-left: 1px solid var(--border); }
.g-week { font-size: 11px; color: var(--text-3); text-align: center; padding: 4px 0 8px; border-left: 1px solid var(--grid); }
.g-week span { position: relative; z-index: 4; background: var(--surface-2); padding: 0 2px; }
.g-lane { border-bottom: 1px solid var(--grid); }
.g-lane:last-child { border-bottom: 0; }
.g-lane > .g-label { padding: 10px 16px; display: flex; align-items: center; gap: 10px; min-width: 0; border-right: 1px solid var(--border); }
.g-label .name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-label .key { display: block; }
.g-area {
  position: relative; padding: 8px 0;
  background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px);
  background-size: calc(100% / var(--cols)) 100%;
}
.g-track { position: relative; height: 34px; }
.bar {
  position: absolute; top: 5px; height: 24px; border-radius: 7px; border: 1px solid var(--c);
  background: color-mix(in srgb, var(--c) 18%, white); padding: 0 8px; overflow: hidden;
  display: flex; align-items: center; font-size: 12px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis;
  color: color-mix(in srgb, var(--c) 70%, black); z-index: 2; transition: box-shadow .12s;
}
.bar .fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--c) 30%, white); z-index: -1; }
.bar:hover, .bar.sel { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
.bar.conflict { border-color: var(--critical); }
.bar .dot { position: absolute; right: 4px; top: 50%; translate: 0 -50%; width: 14px; height: 14px; border-radius: 50%; background: var(--critical); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.g-today { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1.5px dashed var(--critical); left: calc(var(--lw) + (100% - var(--lw)) * var(--t) / var(--cols)); z-index: 3; pointer-events: none; }
.g-today span { position: absolute; top: 2px; left: 4px; font-size: 10.5px; font-weight: 600; color: var(--critical); background: var(--surface-2); padding: 0 3px; }
.g-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--text-2); margin-top: 12px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 18px; vertical-align: middle; margin-right: 6px; border-top: 1.5px solid var(--text-3); }
.legend i.c { border-color: var(--critical); }
.legend i.t { border-top-style: dashed; border-color: var(--critical); }

/* Detail panel */
.detail { margin-top: 20px; }
.detail-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-head h3 { margin: 0; font-size: 16px; }
.detail-head .progress { width: 220px; }

/* Metric block */
.big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.ice-parts { display: flex; gap: 14px; color: var(--text-2); font-size: 12.5px; margin: 6px 0 14px; flex-wrap: wrap; }
.ice-parts b { color: var(--text); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.kv .faint { display: block; margin-bottom: 4px; }
.kv .val { font-size: 20px; font-weight: 700; }
.list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.list li .grow { flex: 1; min-width: 0; }

/* Banner */
.banner { display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 14px 18px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid #D9DCFB; }
.banner .grow { flex: 1; }
.banner b { display: block; }
.banner .sparkle { font-size: 20px; }

/* Connect */
.tracker { display: flex; flex-direction: column; gap: 10px; }
.tracker-logo { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; }
.tracker p { margin: 0; font-size: 12.5px; color: var(--text-2); flex: 1; }
.tracker .btn { align-self: flex-start; }
.tracker.connected { border-color: #BFE6CF; }

/* Modal, toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 24, 40, .35); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(440px, 100%); background: var(--surface); border-radius: 16px; padding: 22px; box-shadow: 0 20px 60px rgba(20, 24, 40, .25); }
.modal h3 { font-size: 17px; margin-bottom: 4px; }
.slider { display: grid; grid-template-columns: 110px 1fr 28px; align-items: center; gap: 12px; margin: 14px 0; }
.slider input { accent-color: var(--accent); }
.slider output { font-weight: 700; text-align: right; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.toast { position: fixed; bottom: 24px; left: 50%; translate: -50% 0; background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 60; }
.toast[hidden] { display: none; }

.placeholder { text-align: center; padding: 40px 20px; color: var(--text-2); }
.placeholder b { display: block; color: var(--text); font-size: 15px; margin-bottom: 6px; }

@media (max-width: 1100px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px 16px; }
  .sidebar .logo { padding: 4px 10px 4px 0; }
  .sidebar .spacer, .sidebar .user, .nav-item span { display: none; }
  .main { padding: 20px 16px 40px; }
  .cols-2, .cols-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .gantt { --lw: 120px; overflow-x: auto; }
  .page-head { flex-direction: column; }
}
