:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --border: #e3e8f0;
  --text: #1b2333;
  --text-muted: #6b7588;
  --primary: #2e6df6;
  --primary-soft: #e4edff;
  --critical: #e23b3b;
  --major: #f08a2c;
  --normal: #2e6df6;
  --minor: #8a94a6;
  --success: #27a65a;
  --shadow: 0 4px 18px rgba(24, 39, 75, 0.06);
  --radius: 12px;
  --epic-01: #5b8def;
  --epic-02: #3ab795;
  --epic-03: #e8625b;
  --epic-04: #9665d8;
  --epic-05: #e39b2e;
  --epic-06: #2da1a8;
  --epic-07: #d65a95;
  --epic-08: #6b7a99;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; font-size: 14px; line-height: 1.5; }

a { color: var(--primary); text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* Topbar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow); }
.topbar-inner { max-width: 1600px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.brand-title { font-size: 15px; font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--text-muted); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { background: transparent; border: none; color: var(--text-muted); padding: 8px 14px; border-radius: 8px; font-weight: 500; transition: all .15s; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--primary); color: #fff; }

/* Main */
main { max-width: 1600px; margin: 0 auto; padding: 24px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 14px; font-size: 16px; }
.card h3 { margin: 0 0 10px; font-size: 14px; }

.grid { display: grid; gap: 16px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 20px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 960px) { .grid.two, .grid.three { grid-template-columns: 1fr; } }

/* KPI cards */
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.kpi-value.accent { color: var(--primary); }
.kpi-value.success { color: var(--success); }

/* Section title */
.section-title { font-size: 18px; font-weight: 600; margin: 6px 0 12px; }
.section-sub { color: var(--text-muted); margin-bottom: 16px; }

/* Charts */
.chart-wrap { width: 100%; height: 260px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.chart-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

/* Pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--text-muted); }
.pill.critical { background: #fde5e5; color: var(--critical); }
.pill.major    { background: #fdeeda; color: var(--major); }
.pill.normal   { background: #e4edff; color: var(--normal); }
.pill.minor    { background: #eef0f4; color: var(--minor); }
.pill.tag      { background: #eef6ff; color: #3a5a8f; margin-right: 4px; }

/* Epic badge */
.epic-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 6px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.epic-badge .epic-dot { width: 8px; height: 8px; border-radius: 50%; }

/* Gantt */
.gantt-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.gantt-table { border-collapse: collapse; width: 100%; min-width: 1100px; }
.gantt-table th, .gantt-table td { border-bottom: 1px solid var(--border); vertical-align: middle; }
.gantt-table thead th { position: sticky; top: 0; background: var(--surface); padding: 10px 8px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-align: center; border-bottom: 2px solid var(--border); }
.gantt-table thead th:first-child { text-align: left; }
.gantt-table tbody .epic-row td { background: var(--surface-2); font-weight: 600; font-size: 12px; padding: 8px 12px; color: var(--text); }
.gantt-table tbody .task-row td { padding: 4px 6px; font-size: 12px; }
.gantt-table tbody .task-row td:first-child { padding: 4px 12px; color: var(--text); }
.gantt-cell { position: relative; height: 28px; min-width: 70px; }
.gantt-block { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 3px 8px; border-radius: 6px; background: var(--epic-01); color: white; font-size: 11px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; transition: transform .12s; }
.gantt-block:hover { transform: scale(1.03); filter: brightness(1.08); }
.gantt-block .hrs { font-size: 10px; background: rgba(255,255,255,.25); padding: 1px 5px; border-radius: 4px; }

/* Task table */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.filters input, .filters select { font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); min-width: 140px; }
.filters input[type="search"] { min-width: 240px; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--primary); background: #fff; }
.filter-count { margin-left: auto; color: var(--text-muted); font-size: 12px; }

.task-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.task-table th, .task-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; vertical-align: top; }
.task-table th { background: var(--surface-2); font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 600; letter-spacing: .5px; cursor: pointer; user-select: none; }
.task-table th .arrow { font-size: 9px; opacity: .5; margin-left: 3px; }
.task-table tbody tr { cursor: pointer; transition: background .1s; }
.task-table tbody tr:hover { background: var(--primary-soft); }
.task-table tbody tr:last-child td { border-bottom: none; }
.task-table td.mono { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.task-table td.nowrap { white-space: nowrap; }

/* Sprint cards */
.sprint-card { display: grid; grid-template-columns: 80px 1fr; gap: 16px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
.sprint-num { background: linear-gradient(135deg, var(--primary), #5b8def); color: #fff; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px; }
.sprint-num .n { font-size: 28px; font-weight: 700; line-height: 1; }
.sprint-num .label { font-size: 10px; text-transform: uppercase; margin-top: 4px; letter-spacing: 1px; opacity: .9; }
.sprint-body .goal { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.sprint-body .meta { color: var(--text-muted); font-size: 12px; margin-bottom: 10px; }
.sprint-tasks { display: flex; flex-direction: column; gap: 6px; }
.sprint-task-row { display: flex; gap: 10px; align-items: center; padding: 7px 10px; background: var(--surface-2); border-radius: 8px; cursor: pointer; transition: background .1s; }
.sprint-task-row:hover { background: var(--primary-soft); }
.sprint-task-row .tid { font-family: "SF Mono", Menlo, monospace; font-size: 11px; color: var(--text-muted); min-width: 90px; }
.sprint-task-row .ttitle { flex: 1; font-size: 13px; }
.sprint-task-row .thours { font-size: 11px; color: var(--text-muted); font-weight: 600; }

/* Epic detail */
.epic-card { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.epic-card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.epic-color-bar { width: 6px; height: 40px; border-radius: 4px; }
.epic-head-info { flex: 1; }
.epic-card-head h2 { margin: 0; font-size: 17px; }
.epic-card-head .meta { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.epic-stats { display: flex; gap: 18px; }
.epic-stat { text-align: center; }
.epic-stat .v { font-size: 18px; font-weight: 700; color: var(--primary); }
.epic-stat .l { font-size: 10px; text-transform: uppercase; color: var(--text-muted); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 22, 38, .55); backdrop-filter: blur(2px); }
.modal-card { position: relative; background: var(--surface); border-radius: var(--radius); max-width: 780px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 28px; box-shadow: 0 24px 80px rgba(0,0,0,.25); }
.modal-close { position: absolute; top: 14px; right: 14px; background: var(--surface-2); border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 16px; color: var(--text-muted); }
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body h1 { margin: 0 0 6px; font-size: 20px; }
.modal-body .modal-meta { color: var(--text-muted); font-size: 12px; margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.modal-body h4 { margin: 18px 0 8px; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.modal-body p { margin: 0 0 12px; }
.modal-body ul { margin: 0; padding-left: 20px; }
.modal-body li { margin-bottom: 5px; }
.modal-body .tz-ref { font-size: 12px; color: var(--text-muted); font-style: italic; }
.modal-body .deps-list a { display: inline-block; padding: 3px 9px; background: var(--primary-soft); border-radius: 6px; font-size: 12px; margin: 0 6px 6px 0; font-family: "SF Mono", Menlo, monospace; }

/* Risks view */
.notes-col h3 { margin-top: 0; }
.notes-col ul { padding-left: 20px; }
.notes-col li { margin-bottom: 10px; font-size: 13px; }
.notes-col p { margin: 0 0 12px; font-size: 13px; }
.notes-col strong { color: var(--text); }

/* Utility */
.hidden { display: none !important; }
.small { font-size: 12px; color: var(--text-muted); }
