:root {
  --navy-950: #07182f;
  --navy-900: #0b2447;
  --navy-800: #153b67;
  --navy-700: #1f517f;
  --blue-100: #eaf2fb;
  --blue-50: #f5f8fc;
  --ink: #132238;
  --muted: #63738a;
  --line: #dce5ef;
  --white: #fff;
  --red: #a23b3b;
  --red-soft: #f4cccc;
  --green: #397052;
  --green-soft: #d9ead3;
  --amber: #9a6513;
  --amber-soft: #fff0c7;
  --violet: #66509a;
  --violet-soft: #ece5fb;
  --cyan: #24727a;
  --cyan-soft: #d8f0f1;
  --shadow: 0 18px 50px rgba(13, 42, 73, .10);
  --radius: 22px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(180deg, #eef4fa 0, #f8fafc 340px, #f8fafc 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
.skip-link { position: absolute; top: -80px; left: 16px; z-index: 100; padding: 10px 14px; background: var(--navy-900); color: white; border-radius: 8px; }
.skip-link:focus { top: 12px; }

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px max(24px, calc((100vw - 1260px) / 2));
  background: rgba(255,255,255,.9);
  border-bottom: 1px solid rgba(21,59,103,.10);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; background: var(--navy-900); color: white; border-radius: 15px; font-weight: 800; letter-spacing: -.04em; box-shadow: 0 8px 18px rgba(11,36,71,.2); }
.eyebrow { margin: 0 0 3px; color: var(--navy-700); font-size: .71rem; line-height: 1.2; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1rem, 2.5vw, 1.22rem); letter-spacing: -.02em; }
.sync-state { display: inline-flex; align-items: center; gap: 8px; min-width: max-content; color: var(--muted); font-size: .8rem; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #dca43d; box-shadow: 0 0 0 4px #f9edcf; }
.sync-state.ready .sync-dot { background: #4d956b; box-shadow: 0 0 0 4px #deefe4; }
.sync-state.error .sync-dot { background: #b94b4b; box-shadow: 0 0 0 4px #f7dddd; }

.shell { width: min(1260px, calc(100% - 40px)); margin: 28px auto 60px; }
.hero {
  background: var(--navy-900);
  color: white;
  border-radius: 28px;
  min-height: 184px;
  padding: clamp(26px, 5vw, 48px);
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow);
}
.hero::before, .hero::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.10); border-radius: 50%; }
.hero::before { width: 290px; height: 290px; right: -65px; top: -165px; }
.hero::after { width: 210px; height: 210px; right: 75px; top: -130px; }
.hero > * { position: relative; z-index: 1; }
.hero-kicker { margin: 0 0 9px; color: #b9cce1; font-size: .84rem; font-weight: 700; }
.hero h2 { margin: 0; font-size: clamp(1.75rem, 4vw, 3rem); letter-spacing: -.05em; }
.hero-copy { margin: 10px 0 0; max-width: 560px; color: #ccdae8; font-size: .94rem; }
.hero-stat { min-width: 142px; padding: 15px 18px; text-align: right; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); border-radius: 18px; backdrop-filter: blur(10px); }
.hero-stat span { display: block; font-size: 1.65rem; font-weight: 800; }
.hero-stat small { color: #c8d7e7; }

.controls { margin: 22px 0 14px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; }
.view-switch { justify-self: start; padding: 5px; display: inline-flex; gap: 3px; background: #e8eef5; border-radius: 13px; }
.view-switch button { border: 0; background: transparent; color: var(--muted); padding: 9px 16px; border-radius: 9px; font-size: .84rem; font-weight: 750; }
.view-switch button[aria-selected="true"] { background: white; color: var(--navy-900); box-shadow: 0 2px 8px rgba(14,39,69,.10); }
.date-nav { display: flex; align-items: center; justify-content: center; gap: 7px; }
.icon-button, .period-button, .filter-button { border: 1px solid var(--line); background: white; color: var(--navy-900); box-shadow: 0 3px 10px rgba(12,38,68,.04); }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; }
.icon-button svg, .filter-button svg, .search-field svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.period-button { min-width: 156px; height: 38px; border-radius: 11px; font-size: .88rem; font-weight: 800; }
.filter-button { justify-self: end; height: 40px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px; border-radius: 12px; font-size: .84rem; font-weight: 750; }
.filter-count { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--navy-900); color: white; font-size: .7rem; }

.filter-panel { margin: 0 0 16px; padding: 22px; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.filter-heading { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.filter-heading h3, .legend h3 { margin: 0; font-size: 1.15rem; }
.text-button { padding: 7px; border: 0; background: transparent; color: var(--navy-700); font-size: .78rem; font-weight: 750; }
.search-field { margin: 18px 0; max-width: 480px; height: 44px; padding: 0 13px; display: flex; align-items: center; gap: 10px; background: var(--blue-50); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); }
.search-field input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.filter-group + .filter-group { margin-top: 16px; }
.filter-label { display: block; margin-bottom: 9px; color: var(--muted); font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; border: 1px solid var(--line); background: white; border-radius: 999px; color: var(--muted); font-size: .78rem; font-weight: 750; transition: .15s ease; }
.chip[aria-pressed="true"] { color: white; background: var(--navy-900); border-color: var(--navy-900); }
.chips-status .chip[aria-pressed="true"] { color: var(--ink); background: var(--chip-bg); border-color: color-mix(in srgb, var(--chip-bg), #000 12%); }
.active-summary { margin: 0 0 12px; color: var(--muted); font-size: .78rem; }

.calendar-surface { min-height: 440px; background: white; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.month-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); background: var(--blue-50); }
.month-weekdays span { padding: 11px; color: var(--muted); font-size: .7rem; font-weight: 800; text-align: center; text-transform: uppercase; letter-spacing: .06em; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.day-cell { min-height: 134px; padding: 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: white; overflow: hidden; }
.day-cell:nth-child(7n) { border-right: 0; }
.day-cell.outside { background: #fafbfd; }
.day-cell.outside .day-number { color: #aeb9c7; }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 7px; }
.day-number { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: var(--ink); font-size: .8rem; font-weight: 800; }
.day-cell.today .day-number { color: white; background: var(--navy-900); }
.event-pill { display: block; margin-bottom: 5px; padding: 6px 7px; border-radius: 7px; background: var(--blue-100); color: var(--navy-800); font-size: .68rem; font-weight: 700; line-height: 1.25; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status-line { display: flex; flex-wrap: wrap; gap: 4px; }
.status-badge { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 4px 6px; border-radius: 6px; background: var(--badge-bg); color: var(--badge-ink); font-size: .63rem; font-weight: 800; line-height: 1; }
.status-badge b { font-size: .58rem; opacity: .66; }

.week-view { padding: 10px; }
.week-day { display: grid; grid-template-columns: 74px minmax(0,1fr); gap: 14px; padding: 15px 14px; border-bottom: 1px solid var(--line); border-radius: 14px; }
.week-day:last-child { border-bottom: 0; }
.week-day.today { background: var(--blue-50); }
.week-date { display: flex; flex-direction: column; align-items: center; justify-content: center; border-right: 1px solid var(--line); }
.week-date strong { font-size: 1.55rem; line-height: 1; color: var(--navy-900); }
.week-date span { margin-top: 5px; color: var(--muted); font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.week-content { min-width: 0; }
.week-event { margin: 0 0 9px; color: var(--ink); font-size: .88rem; font-weight: 750; }
.empty-note { margin: 4px 0 0; color: #94a0af; font-size: .76rem; }

.year-view { padding: 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.year-month { padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: white; text-align: left; }
.year-month:hover { border-color: #a9bdd2; box-shadow: 0 8px 22px rgba(13,42,73,.07); }
.year-month h4 { margin: 0 0 12px; color: var(--navy-900); font-size: .9rem; }
.mini-weekdays, .mini-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.mini-weekdays { margin-bottom: 5px; color: #9aa8b8; font-size: .5rem; font-weight: 800; text-align: center; }
.mini-day { aspect-ratio: 1; display: grid; place-items: center; position: relative; color: var(--muted); font-size: .56rem; border-radius: 50%; }
.mini-day.has-data { background: var(--blue-100); color: var(--navy-800); font-weight: 800; }
.mini-day.has-event::after { content: ""; width: 3px; height: 3px; position: absolute; bottom: 1px; border-radius: 50%; background: var(--red); }

.loading, .error-state, .empty-state { min-height: 440px; padding: 36px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.state-box { max-width: 430px; }
.state-icon { width: 58px; height: 58px; margin: 0 auto 15px; display: grid; place-items: center; border-radius: 17px; background: var(--blue-100); color: var(--navy-800); font-size: 1.5rem; }
.state-box h3 { margin: 0 0 8px; color: var(--ink); }
.state-box p { margin: 0; line-height: 1.55; font-size: .88rem; }
.spinner { width: 26px; height: 26px; margin: 0 auto 12px; border: 3px solid #dce6f0; border-top-color: var(--navy-700); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.legend { margin-top: 18px; padding: 22px; display: grid; grid-template-columns: 190px 1fr; gap: 24px; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.legend-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 9px; }
.legend-item { padding: 11px; background: var(--blue-50); border-radius: 12px; }
.legend-item strong { display: block; margin-bottom: 3px; color: var(--navy-900); font-size: .76rem; }
.legend-item span { color: var(--muted); font-size: .65rem; line-height: 1.25; }
footer { width: min(1260px, calc(100% - 40px)); margin: 0 auto 30px; display: flex; justify-content: space-between; gap: 16px; color: #7a899c; font-size: .72rem; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: 360px; padding: 12px 16px; background: var(--navy-950); color: white; border-radius: 12px; box-shadow: var(--shadow); font-size: .82rem; }

@media (max-width: 900px) {
  .shell { width: min(100% - 24px, 760px); margin-top: 16px; }
  .topbar { min-height: 72px; padding: 12px; }
  .brand-mark { width: 42px; height: 42px; border-radius: 13px; }
  .brand .eyebrow, .sync-state span:not(.sync-dot) { display: none; }
  .hero { min-height: 158px; border-radius: 22px; align-items: center; }
  .hero-stat { display: none; }
  .controls { grid-template-columns: 1fr auto; }
  .view-switch { grid-column: 1 / -1; justify-self: stretch; }
  .view-switch button { flex: 1; }
  .date-nav { justify-content: start; }
  .filter-button { justify-self: end; }
  .day-cell { min-height: 108px; padding: 7px; }
  .event-pill { padding: 5px; font-size: .6rem; }
  .status-badge { padding: 4px 5px; }
  .status-badge b { display: none; }
  .year-view { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .legend { grid-template-columns: 1fr; gap: 14px; }
  .legend-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 620px) {
  .shell { width: 100%; margin: 0 auto 34px; }
  .hero { margin: 0 12px; min-height: 142px; padding: 24px; border-radius: 0 0 22px 22px; }
  .hero h2 { font-size: 1.55rem; }
  .hero-copy { max-width: 280px; font-size: .79rem; }
  .controls { margin: 14px 12px 10px; }
  .filter-panel { margin: 0 12px 10px; padding: 18px; border-radius: 17px; }
  .active-summary { margin: 0 12px 10px; }
  .calendar-surface { min-height: 430px; border-left: 0; border-right: 0; border-radius: 0; box-shadow: none; }
  .month-weekdays span { padding: 9px 2px; font-size: .58rem; }
  .day-cell { min-height: 82px; padding: 4px; }
  .day-number { width: 24px; height: 24px; font-size: .7rem; }
  .event-pill { width: 7px; height: 7px; margin: 3px auto; padding: 0; border-radius: 50%; color: transparent; }
  .status-line { justify-content: center; gap: 2px; }
  .status-badge { width: 7px; height: 7px; padding: 0; border-radius: 50%; color: transparent; font-size: 0; }
  .week-view { padding: 4px 10px; }
  .week-day { grid-template-columns: 58px minmax(0,1fr); padding: 15px 5px; gap: 12px; }
  .week-date strong { font-size: 1.35rem; }
  .year-view { padding: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .year-month { padding: 10px; }
  .legend { margin: 14px 12px 0; padding: 18px; border-radius: 17px; }
  .legend-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  footer { width: calc(100% - 24px); flex-direction: column; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; animation-duration: .01ms !important; } }

.sync-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.sync-card { width: min(100%, 520px); padding: clamp(26px, 6vw, 44px); background: white; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.sync-card .back-link { display: inline-block; margin-bottom: 34px; color: var(--navy-700); font-size: .8rem; font-weight: 750; text-decoration: none; }
.sync-card h1 { margin: 0 0 10px; font-size: 2rem; color: var(--navy-900); }
.sync-card > p:not(.eyebrow) { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.sync-card form { display: grid; gap: 10px; }
.sync-card label { color: var(--ink); font-size: .78rem; font-weight: 800; }
.sync-card input { width: 100%; height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; outline: none; }
.sync-card input:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px var(--blue-100); }
.sync-submit { height: 46px; margin-top: 4px; border: 0; border-radius: 11px; background: var(--navy-900); color: white; font-weight: 800; }
.sync-submit:disabled { opacity: .6; cursor: wait; }
.sync-result { margin: 16px 0; padding: 12px; border-radius: 10px; font-size: .8rem; line-height: 1.4; }
.sync-result.success { color: var(--green); background: var(--green-soft); }
.sync-result.error { color: var(--red); background: var(--red-soft); }
.sync-card small { display: block; margin-top: 18px; color: var(--muted); line-height: 1.45; }
