* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #0066cc;
  --brand-dark: #0050a0;
  --critical: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --critical-bg: #fef2f2;
  --warn-bg: #fffbeb;
  --ok-bg: #f0fdf4;
}
html, body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1500px; margin: 0 auto; padding: 28px 24px 48px; }

.alert { padding: 14px 18px; border-radius: 10px; margin-bottom: 20px; font-size: 13px; }
.alert.error { background: var(--critical-bg); color: var(--critical); border: 1px solid #fecaca; }
.alert.danger { background: #fff1f2; color: #9f1239; border: 1px solid #fecdd3; }
.alert code { font-family: ui-monospace, "Cascadia Code", Menlo, monospace; background: rgba(0,0,0,.05); padding: 1px 6px; border-radius: 4px; }

.quick-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.quick {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--card); color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s; font-family: inherit;
}
.quick:hover { background: var(--bg); border-color: var(--border-strong); }
.quick.active { background: var(--text); color: white; border-color: var(--text); }
.quick.active .qcount { background: rgba(255,255,255,0.2); color: white; }
.quick.today.active { background: var(--brand); border-color: var(--brand); }
.quick.warn.active { background: var(--warn); border-color: var(--warn); }
.quick.danger.active { background: var(--critical); border-color: var(--critical); }
.qcount {
  background: rgba(0,0,0,0.08); color: var(--muted);
  border-radius: 999px; padding: 2px 9px; font-weight: 700; font-size: 11px;
  min-width: 22px; text-align: center;
}

header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--border);
}
header h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
header .sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
header .tag { background: var(--brand); color: white; padding: 1px 8px; border-radius: 5px; font-weight: 600; font-size: 11px; letter-spacing: 0.04em; }

.btn { background: var(--brand); color: white; padding: 10px 20px; border: 0; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; }
.btn:hover { background: var(--brand-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,102,204,0.25); }
.btn:active { transform: translateY(0); }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px;
  transition: border-color .15s;
}
.card:hover { border-color: var(--border-strong); }
.card .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.card .value { font-size: 30px; font-weight: 700; margin-top: 8px; letter-spacing: -0.02em; }
.card.critical .value { color: var(--critical); }
.card.warn .value { color: var(--warn); }
.card.brand .value { color: var(--brand); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
  display: inline-flex; align-items: center; background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 10px 6px 14px; font-size: 12px;
}
.chip-label { color: var(--muted); margin-right: 8px; }
.chip-count { background: var(--text); color: white; border-radius: 999px; padding: 1px 9px; font-weight: 600; font-size: 11px; min-width: 22px; text-align: center; }

.controls { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.controls input, .controls select {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
  background: var(--card); font-family: inherit;
}
.controls input { flex: 1; min-width: 200px; }
.controls input:focus, .controls select:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.controls select { cursor: pointer; }
.counter { font-size: 12px; color: var(--muted); white-space: nowrap; margin-left: 6px; }

.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.02); }
table { width: 100%; border-collapse: collapse; }
thead { background: #f9fafb; position: sticky; top: 0; z-index: 1; }
th {
  text-align: left; padding: 13px 16px; font-weight: 600; font-size: 11px;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap;
}
th:hover { color: var(--text); }
th.sorted-asc::after { content: " \25B2"; color: var(--brand); font-size: 9px; }
th.sorted-desc::after { content: " \25BC"; color: var(--brand); font-size: 9px; }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #f9fafb; }
td.amount { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
td.due { font-size: 12px; color: var(--muted); white-space: nowrap; }
.deal-cell { max-width: 460px; }
.deal-name { font-weight: 600; color: var(--text); margin-bottom: 3px; line-height: 1.3; }
.subject { font-size: 12px; color: var(--muted); line-height: 1.4; }
.muted { color: var(--muted); }

details { font-size: 12px; }
details summary { cursor: pointer; color: var(--brand); user-select: none; padding: 2px 0; }
details summary:hover { text-decoration: underline; }
details[open] summary { font-weight: 600; }
.task-body {
  margin-top: 8px; padding: 12px 14px; background: var(--bg); border-radius: 6px;
  color: var(--text); white-space: pre-wrap; max-width: 580px; font-size: 12px;
  line-height: 1.55; border-left: 3px solid var(--brand);
}

.badge {
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; white-space: nowrap;
}
.badge.pr-high { background: var(--critical-bg); color: var(--critical); }
.badge.pr-medium { background: var(--warn-bg); color: var(--warn); }
.badge.pr-low { background: var(--ok-bg); color: var(--ok); }
.badge.issue { background: #f1f5f9; color: #475569; }
.badge.iss-a_inactivity { background: #e0e7ff; color: #4338ca; }
.badge.iss-b_closesoonnotask { background: #fee2e2; color: #b91c1c; }
.badge.iss-c_stuckinstage { background: #fef3c7; color: #b45309; }
.badge.iss-d_nocontact { background: #ecfeff; color: #0e7490; }
.badge.iss-e_noowner { background: #fce7f3; color: #9d174d; }
.badge.iss-f_noamount { background: #f3e8ff; color: #6b21a8; }
.badge.attempt-esc { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; margin-left: 6px; }
.badge.attempt-failed { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; margin-left: 6px; font-weight: 700; }

footer { text-align: center; padding: 28px 0 0; color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .controls { flex-wrap: wrap; }
}
