:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #eef3f1;
  --ink: #17201d;
  --muted: #66736f;
  --line: #dbe3e1;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #c2410c;
  --green: #15803d;
  --purple: #7c3aed;
  --shadow: 0 16px 40px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.month-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.command-button,
.segment {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-weight: 800;
}

.command-button {
  padding: 0 14px;
  font-weight: 700;
}

.icon-button:hover,
.command-button:hover,
.segment:hover {
  border-color: #aebbb7;
  background: #f8faf9;
}

input[type="month"] {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 0 10px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 340px;
  gap: 18px;
  padding: 18px;
}

.sidebar,
.agenda,
.calendar-area {
  min-width: 0;
}

.sidebar,
.agenda {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.summary-panel,
.filter-section,
.status-panel,
.calendar-area,
.agenda {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.summary-panel > div {
  padding: 14px 12px;
  background: var(--panel);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.filter-section {
  padding: 16px;
}

.filter-section h2 {
  margin-bottom: 12px;
  font-size: 14px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.segment {
  padding: 0 8px;
  font-weight: 700;
}

.segment.active {
  border-color: var(--teal);
  background: #e5f4f1;
  color: #075e58;
}

.check-list,
.filter-section {
  display: flex;
  flex-direction: column;
}

.check-list {
  gap: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  color: #31413c;
  font-size: 14px;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.status-panel {
  padding: 14px 16px;
  color: var(--muted);
  font-size: 13px;
}

.status-panel span {
  display: block;
}

.status-panel span + span {
  margin-top: 4px;
}

.calendar-area {
  overflow: hidden;
}

.calendar-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.source-counts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekdays {
  border-bottom: 1px solid var(--line);
  background: #fafbfb;
}

.weekdays span {
  padding: 10px 8px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.calendar-grid {
  min-height: 660px;
}

.day-cell {
  position: relative;
  min-height: 132px;
  padding: 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.day-cell:nth-child(7n) {
  border-right: 0;
}

.day-cell.muted {
  background: #f8faf9;
  color: #9aa6a2;
}

.day-cell.today {
  box-shadow: inset 0 0 0 2px #6bb7ad;
}

.day-cell.selected {
  background: #eef7f5;
}

.day-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
}

.day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.today .day-number {
  background: var(--teal);
  color: white;
}

.event-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 8px;
}

.event-chip {
  display: block;
  width: 100%;
  min-height: 24px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  color: #1f2937;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.event-chip.stock {
  background: #edf4ff;
  border-color: #cfe0ff;
}

.event-chip.crypto {
  background: #eaf7ef;
  border-color: #cbe9d4;
}

a.event-chip.crypto:hover,
a.event-chip.crypto:focus-visible {
  border-color: #70b88d;
  background: #dcf3e7;
  outline: none;
}

.event-chip.market_holiday {
  background: #fff3d6;
  border-color: #f3d18b;
}

.event-chip.economic_indicator {
  background: #f1f5f9;
  border-color: #d9e1ea;
}

.event-chip.deposit_withdrawal {
  background: #e8f7f1;
  border-color: #b9e1cf;
}

.event-chip.listing {
  background: #eef2ff;
  border-color: #ccd5ff;
}

.more-chip {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.agenda {
  padding: 18px;
}

.agenda-header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.agenda-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 160px;
}

.event-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.event-card.clickable {
  cursor: pointer;
}

.event-card.clickable:hover,
.event-card.clickable:focus-visible {
  border-color: #9fcab1;
  background: #fbfefd;
  outline: none;
}

.event-card.crypto {
  border-left-color: var(--green);
}

.event-card.stock {
  border-left-color: var(--blue);
}

.event-card.market_holiday {
  border-left-color: var(--amber);
}

.event-card h3 {
  margin: 6px 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: #42524d;
  font-size: 11px;
  font-weight: 800;
}

.event-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.event-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.event-link:hover {
  text-decoration: underline;
}

.empty-state,
.error-state {
  padding: 18px 0;
  color: var(--muted);
  font-size: 14px;
}

.error-state {
  color: var(--red);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .agenda {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .month-controls {
    flex-wrap: wrap;
  }

  .month-controls input[type="month"] {
    flex: 1 1 160px;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .calendar-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .calendar-grid {
    min-height: auto;
  }

  .day-cell {
    min-height: 102px;
    padding: 6px;
  }

  .event-chip {
    min-height: 22px;
    padding: 3px 5px;
    font-size: 11px;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 22px;
  }

  .summary-panel {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .calendar-area {
    overflow-x: auto;
  }

  .weekdays,
  .calendar-grid {
    min-width: 720px;
  }
}
