:root {
  color-scheme: light;
  --brand: #a62c32;
  --brand-dark: #7e1f25;
  --brand-soft: #f7e9ea;
  --orange: #ff8c00;
  --green: #16815d;
  --green-soft: #e7f6f0;
  --amber: #c36a08;
  --amber-soft: #fff3dc;
  --red: #c33b46;
  --red-soft: #fdecef;
  --ink: #20232a;
  --muted: #69707d;
  --line: #e3e5e9;
  --surface: #ffffff;
  --surface-alt: #f6f7f9;
  --canvas: #eef0f3;
  --shadow: 0 12px 36px rgba(28, 31, 38, .08);
  --radius: 18px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --brand: #d45b62;
  --brand-dark: #f0868c;
  --brand-soft: #3c2024;
  --green: #55c59b;
  --green-soft: #18352c;
  --amber: #f2a746;
  --amber-soft: #3a2a17;
  --red: #ef747d;
  --red-soft: #412126;
  --ink: #f1f2f4;
  --muted: #adb3bf;
  --line: #343943;
  --surface: #242830;
  --surface-alt: #2b3039;
  --canvas: #191c22;
  --shadow: 0 14px 38px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: Aptos, "Segoe UI", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

button, input, select { font: inherit; }

button, .button { -webkit-tap-highlight-color: transparent; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 82px;
  padding: 1rem clamp(1rem, 3vw, 3rem);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand, .top-actions { display: flex; align-items: center; gap: .85rem; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--brand);
  color: white;
  font-weight: 800;
  letter-spacing: -.04em;
  box-shadow: 0 7px 18px color-mix(in srgb, var(--brand) 28%, transparent);
}

.eyebrow {
  margin: 0 0 .1rem;
  color: var(--brand);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 { margin-bottom: 0; font-size: clamp(1.15rem, 2vw, 1.45rem); line-height: 1.15; }
h2 { margin-bottom: .35rem; font-size: clamp(1.55rem, 3vw, 2.25rem); letter-spacing: -.035em; }
h3 { margin-bottom: 0; font-size: 1.08rem; letter-spacing: -.015em; }

.button, .icon-button, .text-button {
  border: 0;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, color .16s ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .65rem 1rem;
  border-radius: 11px;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.button:hover, .icon-button:hover { transform: translateY(-1px); }
.button:focus-visible, .icon-button:focus-visible, .text-button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 30%, transparent); outline-offset: 2px; }
.button-primary { background: var(--brand); color: #fff; }
.button-primary:hover { background: var(--brand-dark); }
.button-secondary { background: var(--surface-alt); color: var(--ink); border: 1px solid var(--line); }
.button-secondary:hover, .button-quiet:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.button-quiet { background: transparent; color: var(--brand); border: 1px solid var(--line); }

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 11px;
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--line);
}

.icon-button svg, .search-field svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }

main { width: min(1540px, 100%); margin: 0 auto; padding: clamp(1.25rem, 3vw, 2.5rem); }

.overview-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.35rem; }
.updated-text { margin-bottom: 0; color: var(--muted); }
.text-button { padding: .35rem 0; background: transparent; color: var(--brand); font-weight: 700; }
.text-button:hover { color: var(--brand-dark); }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: .9rem;
  min-height: 126px;
  padding: 1.2rem;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.kpi-card::after { content: ""; position: absolute; inset: auto -15px -22px auto; width: 74px; height: 74px; border-radius: 50%; background: currentColor; opacity: .055; }
.kpi-card p { margin-bottom: .15rem; color: var(--muted); font-size: .9rem; font-weight: 700; }
.kpi-card strong { display: block; font-size: 2rem; line-height: 1.1; letter-spacing: -.04em; }
.kpi-card span { color: var(--muted); font-size: .76rem; }
.kpi-icon { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 13px; font-size: 1.2rem; font-weight: 900; }
.total { color: var(--brand); } .total .kpi-icon { background: var(--brand-soft); }
.complete { color: var(--green); } .complete .kpi-icon { background: var(--green-soft); }
.progress { color: var(--amber); } .progress .kpi-icon { background: var(--amber-soft); }
.incomplete, .overdue { color: var(--red); } .incomplete .kpi-icon, .overdue .kpi-icon { background: var(--red-soft); }
.kpi-card p, .kpi-card strong, .kpi-card span { color: var(--ink); }
.kpi-card p, .kpi-card span { color: var(--muted); }

.filter-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1.9fr) repeat(5, minmax(130px, .75fr)) auto;
  gap: .75rem;
  align-items: end;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filter-panel label { display: grid; gap: .35rem; color: var(--muted); font-size: .78rem; font-weight: 800; }
.filter-panel input, .filter-panel select {
  width: 100%;
  min-height: 44px;
  padding: .65rem .75rem;
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.search-field { position: relative; align-self: end; }
.search-field svg { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-field input { padding-left: 2.6rem; }

.analytics-grid { display: grid; grid-template-columns: .85fr 1.2fr 1.25fr; gap: 1rem; margin-bottom: 1rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.25rem .8rem; }
.panel-note { color: var(--muted); font-size: .78rem; font-weight: 700; }

.donut-layout { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 1.15rem; padding: .6rem 1.25rem 1.45rem; }
.donut { display: grid; place-items: center; width: 150px; aspect-ratio: 1; border-radius: 50%; background: conic-gradient(var(--green) 0 0, var(--amber) 0 0, var(--red) 0 100%); position: relative; }
.donut::before { content: ""; position: absolute; width: 94px; aspect-ratio: 1; border-radius: 50%; background: var(--surface); }
.donut div { position: relative; z-index: 1; text-align: center; }
.donut strong { display: block; font-size: 1.7rem; line-height: 1; }
.donut span { color: var(--muted); font-size: .75rem; }
.legend { display: grid; gap: .7rem; }
.legend-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: .6rem; font-size: .84rem; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.legend-row span:nth-child(2) { color: var(--muted); }
.legend-row strong { font-size: .9rem; }

.bar-chart { display: grid; gap: .72rem; padding: .75rem 1.25rem 1.4rem; }
.bar-row { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(90px, 1.5fr) 28px; align-items: center; gap: .65rem; }
.bar-label { overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; overflow: hidden; background: var(--surface-alt); border-radius: 20px; }
.bar-fill { height: 100%; min-width: 3px; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--orange)); }
.bar-value { font-size: .78rem; font-weight: 800; text-align: right; }
.chart-empty { padding: 1rem 0 1.4rem; color: var(--muted); text-align: center; }

.month-chart { display: flex; align-items: end; gap: .7rem; min-height: 205px; padding: .8rem 1.25rem 1.3rem; overflow-x: auto; }
.month-column { display: grid; grid-template-rows: 24px 135px 22px; flex: 1 0 36px; min-width: 36px; align-items: end; justify-items: center; gap: .3rem; }
.month-column strong { font-size: .74rem; }
.month-bar-wrap { display: flex; align-items: flex-end; width: 100%; height: 135px; }
.month-bar { width: 100%; min-height: 3px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, var(--orange), var(--brand)); }
.month-column span { color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; }

.table-panel { overflow: hidden; }
.table-header { align-items: center; padding-bottom: 1.15rem; }
.result-count { margin: .2rem 0 0; color: var(--muted); font-size: .82rem; }
.table-wrap { width: 100%; overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; min-width: 1040px; border-collapse: collapse; }
th, td { padding: .9rem 1rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: var(--surface-alt); color: var(--muted); font-size: .76rem; letter-spacing: .03em; text-transform: uppercase; }
td { font-size: .86rem; }
tbody tr:hover { background: color-mix(in srgb, var(--brand-soft) 40%, transparent); }
.order-cell { color: var(--muted); font-variant-numeric: tabular-nums; }
.meeting-cell { white-space: nowrap; }
.action-title { display: block; max-width: 420px; overflow: hidden; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.action-subtitle { display: block; max-width: 420px; overflow: hidden; margin-top: .15rem; color: var(--muted); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.deadline { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; min-width: 150px; }
.deadline-flag { padding: .16rem .42rem; border-radius: 999px; font-size: .66rem; font-weight: 800; text-transform: uppercase; }
.flag-overdue { background: var(--red-soft); color: var(--red); }
.flag-soon { background: var(--amber-soft); color: var(--amber); }
.flag-none { background: var(--surface-alt); color: var(--muted); }
.status-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .32rem .58rem; border-radius: 999px; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-complete { background: var(--green-soft); color: var(--green); }
.status-progress { background: var(--amber-soft); color: var(--amber); }
.status-incomplete { background: var(--red-soft); color: var(--red); }
.details-button { padding: .35rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-alt); color: var(--ink); cursor: pointer; font-weight: 700; }
.details-button:hover { border-color: var(--brand); color: var(--brand); }
.empty-state { display: grid; justify-items: center; gap: .25rem; padding: 3rem 1rem; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); }

.pagination { display: flex; align-items: center; justify-content: center; gap: .35rem; padding: 1rem; }
.page-button { min-width: 38px; height: 38px; padding: 0 .6rem; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-alt); color: var(--ink); cursor: pointer; }
.page-button[aria-current="page"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.page-button:disabled { cursor: not-allowed; opacity: .42; }

.privacy-note { margin: 1rem 0 0; color: var(--muted); font-size: .78rem; text-align: center; }

dialog { width: min(720px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 0; overflow: auto; background: transparent; border: 0; color: var(--ink); }
dialog::backdrop { background: rgba(20, 22, 27, .6); backdrop-filter: blur(4px); }
.dialog-card { position: relative; padding: clamp(1.3rem, 4vw, 2.2rem); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 28px 70px rgba(0, 0, 0, .28); }
.dialog-close { position: absolute; top: .9rem; right: .9rem; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--surface-alt); color: var(--ink); cursor: pointer; font-size: 1.5rem; }
.dialog-card h2 { padding-right: 2.5rem; font-size: clamp(1.35rem, 4vw, 2rem); }
.dialog-card section { padding-top: 1.2rem; margin-top: 1.2rem; border-top: 1px solid var(--line); }
.dialog-card section h3 { margin-bottom: .45rem; }
.dialog-card section p { margin-bottom: 0; color: var(--muted); white-space: pre-line; }
.dialog-meta { display: flex; flex-wrap: wrap; gap: .5rem; }
.meta-chip { padding: .36rem .65rem; border-radius: 999px; background: var(--surface-alt); color: var(--muted); font-size: .78rem; font-weight: 700; }

.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 40; max-width: min(390px, calc(100% - 2.5rem)); padding: .85rem 1rem; background: #20232a; color: white; border-radius: 12px; box-shadow: 0 16px 38px rgba(0, 0, 0, .26); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #9f2730; }

@media (max-width: 1260px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .analytics-grid { grid-template-columns: 1fr 1fr; }
  .month-panel { grid-column: 1 / -1; }
  .filter-panel { grid-template-columns: minmax(260px, 2fr) repeat(3, 1fr); }
}

@media (max-width: 860px) {
  .topbar { align-items: flex-start; }
  .top-actions { justify-content: flex-end; flex-wrap: wrap; }
  .top-actions .button-secondary { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-panel, .analytics-grid { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .month-panel { grid-column: auto; }
  .status-panel, .owner-panel, .month-panel { grid-column: 1 / -1; }
}

@media (max-width: 580px) {
  .topbar { position: static; display: grid; }
  .top-actions { justify-content: flex-start; }
  .top-actions .button { flex: 1; }
  main { padding: 1rem; }
  .overview-heading { align-items: flex-start; flex-direction: column; }
  .kpi-grid, .filter-panel { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .kpi-card { min-height: 104px; }
  .donut-layout { grid-template-columns: 125px 1fr; }
  .donut { width: 125px; }
  .donut::before { width: 78px; }
  .table-header { align-items: flex-start; flex-direction: column; }
  .table-header .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
