:root {
  color-scheme: dark;
  --bg: #080d14;
  --surface: #0e1621;
  --surface-2: #121d2a;
  --line: #223142;
  --text: #edf5fb;
  --muted: #8da1b4;
  --cyan: #20d2c1;
  --cyan-soft: rgba(32, 210, 193, .12);
  --red: #ff5e6c;
  --amber: #ffb649;
  --blue: #65a7ff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: radial-gradient(circle at 85% -20%, rgba(32,210,193,.12), transparent 34%), var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  min-height: 100vh;
}
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar {
  height: 68px;
  padding: 0 clamp(20px, 5vw, 76px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 36px;
  background: rgba(8,13,20,.88);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.15rem; margin-left: auto; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--cyan); color: #04100f; font-weight: 900; }
nav { display: flex; gap: 26px; }
nav a { color: var(--muted); text-decoration: none; font-size: .93rem; }
nav a.active { color: var(--text); }
.live-pill { display: flex; align-items: center; gap: 8px; color: #b9f8ef; border: 1px solid rgba(32,210,193,.34); background: var(--cyan-soft); padding: 8px 12px; border-radius: 999px; font-size: .82rem; }
.live-pill span, .ok { width: 8px; height: 8px; background: var(--cyan); border-radius: 50%; box-shadow: 0 0 0 5px rgba(32,210,193,.08); }

main { width: min(1450px, calc(100% - 36px)); margin: 0 auto; padding: 42px 0 70px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
.eyebrow { color: var(--cyan) !important; font-weight: 700; letter-spacing: .13em; font-size: .78rem !important; }
.page-head h1 { margin: 8px 0 7px; font-size: clamp(2rem, 4vw, 3.1rem); letter-spacing: -.04em; }
.page-head p { margin: 0; color: var(--muted); font-size: 1rem; }
.clock-card { min-width: 210px; text-align: left; border-right: 2px solid var(--cyan); padding-right: 18px; }
.clock-card span, .clock-card small { display: block; color: var(--muted); font-size: .78rem; }
.clock-card strong { display: block; font: 700 1.7rem/1.4 ui-monospace, Consolas, monospace; direction: ltr; }

.summary-bar { display: grid; grid-template-columns: repeat(3, minmax(110px, .7fr)) minmax(220px, 1.4fr); margin-bottom: 14px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: rgba(14,22,33,.9); }
.summary-bar article { min-width: 0; min-height: 76px; padding: 12px 16px; border-left: 1px solid var(--line); display: grid; align-content: center; gap: 5px; }
.summary-bar article:last-child { border-left: 0; }
.summary-bar span, .summary-bar small { color: var(--muted); font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-bar strong { font-size: 1.35rem; line-height: 1; }
.summary-bar .next-card { border-color: rgba(32,210,193,.25); background: var(--cyan-soft); grid-template-columns: auto 1fr; column-gap: 12px; }
.summary-bar .next-card span { grid-column: 1 / -1; }
.next-card strong { color: var(--cyan); direction: ltr; text-align: right; }
.next-card small { align-self: center; }

.workspace { display: block; }
.calendar-panel { background: rgba(14,22,33,.9); border: 1px solid var(--line); border-radius: 18px; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 20px 0 0; padding: 18px 0 0; }
legend { color: var(--muted); font-size: .78rem; padding: 0; }
fieldset > label { display: flex; align-items: center; gap: 9px; margin-top: 12px; font-size: .87rem; }
input[type="checkbox"] { accent-color: var(--cyan); width: 16px; height: 16px; }
.impact { display: inline-block; width: 7px; height: 18px; border-radius: 4px; background: var(--muted); }
.impact.high { background: var(--red); box-shadow: 0 0 9px rgba(255,94,108,.35); }
.impact.medium { background: var(--amber); }
.impact.low { background: var(--blue); }
.calendar-panel { overflow: hidden; }
.calendar-toolbar { min-height: 64px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.calendar-controls { display: flex; align-items: center; gap: 10px; }
.view-switcher { display: flex; direction: rtl; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #09111b; }
.view-switcher button { border: 0; color: var(--muted); background: transparent; padding: 7px 12px; border-radius: 7px; font-size: .78rem; }
.view-switcher button.active { color: #04100f; background: var(--cyan); font-weight: 700; }
.period-label { color: var(--text); font-size: .82rem; white-space: nowrap; }
.toolbar-actions, .quick-nav { display: flex; align-items: center; gap: 6px; }
.quick-nav { direction: rtl; }
.quick-nav button, .filter-button, .date-picker { min-height: 34px; border: 1px solid var(--line); background: #0a121c; color: var(--muted); padding: 7px 10px; border-radius: 8px; font-size: .74rem; }
.quick-nav button:hover, .filter-button:hover, .date-picker:hover { color: var(--text); border-color: #3a5068; }
.date-picker { position: relative; display: grid; place-items: center; width: 38px; padding: 0; color: var(--cyan); }
.date-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.filter-button { color: var(--cyan); border-color: rgba(32,210,193,.45); }
#filterCount { color: var(--red); }
.table-wrap { overflow-x: auto; min-height: 420px; }
table { width: 100%; border-collapse: collapse; min-width: 810px; }
th { color: #71889d; font-size: .72rem; font-weight: 600; padding: 13px 16px; text-align: right; background: #0a121c; }
td { padding: 16px; border-top: 1px solid rgba(34,49,66,.72); font-size: .88rem; }
tbody tr { transition: background .2s ease; }
tbody tr:hover { background: rgba(101,167,255,.045); }
tbody tr.released { background: rgba(32,210,193,.035); }
.event-card { cursor: pointer; }
.event-title-cell { position: relative; }
.next-news-badge { display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; padding: 4px 8px; border-radius: 999px; background: var(--cyan-soft); color: var(--cyan); font-size: .68rem; font-weight: 800; vertical-align: middle; }
.next-news-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 0 rgba(32,210,193,.55); animation: beacon 1.6s ease-out infinite; }
.event-card.next-upcoming { background: linear-gradient(90deg, rgba(32,210,193,.1), rgba(32,210,193,.025)); box-shadow: inset -3px 0 0 var(--cyan); }
.time { direction: ltr; text-align: right; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }
.currency { display: inline-grid; place-items: center; min-width: 46px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; font: 700 .76rem ui-monospace, Consolas, monospace; direction: ltr; }
.event-name { font-weight: 600; }
.event-link { border: 0; background: transparent; color: var(--text); font-weight: 700; padding: 0; text-align: right; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px; }
.event-link:hover, .event-link:focus-visible { color: var(--cyan); text-decoration-color: currentColor; }
.number { direction: ltr; text-align: right; color: #c5d2dd; font-family: ui-monospace, Consolas, monospace; }
.number.actual { font-weight: 800; color: var(--cyan); }
.number.pending { color: #526679; }
.empty { padding: 70px 20px; text-align: center; color: var(--muted); }
.holidays-section { margin-top: 46px; scroll-margin-top: 90px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading h2 { margin: 6px 0 0; font-size: 1.55rem; }
.weekly-badge { color: var(--cyan); border: 1px solid rgba(32,210,193,.35); background: var(--cyan-soft); border-radius: 999px; padding: 8px 12px; font-size: .78rem; }
.holidays-table-wrap { min-height: 260px; }
.holidays-table { min-width: 720px; }
.holiday-date { color: #c5d2dd; }
.country-code { display: inline-grid; place-items: center; min-width: 42px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; direction: ltr; font-weight: 700; font-size: .76rem; }
.market-state { display: inline-block; border-radius: 999px; padding: 5px 9px; font-size: .72rem; }
.market-state.closed { color: #ff9ba4; background: rgba(255,94,108,.1); }
.market-state.limited { color: #ffd28f; background: rgba(255,182,73,.1); }

.calendar-stage { min-height: 420px; transform-origin: center; }
.calendar-stage.zoom-in { animation: zoom-in .3s cubic-bezier(.2,.8,.2,1); }
.calendar-stage.zoom-out { animation: zoom-out .3s cubic-bezier(.2,.8,.2,1); }
@keyframes zoom-in { from { opacity: .35; transform: scale(.88); } to { opacity: 1; transform: scale(1); } }
@keyframes zoom-out { from { opacity: .35; transform: scale(1.08); } to { opacity: 1; transform: scale(1); } }
@keyframes today-focus { 50% { box-shadow: inset 0 0 0 2px var(--cyan), 0 0 18px rgba(32,210,193,.16); } }
@keyframes beacon { 65% { box-shadow: 0 0 0 7px rgba(32,210,193,0); } 100% { box-shadow: 0 0 0 0 rgba(32,210,193,0); } }
.calendar-grid { display: grid; direction: rtl; background: var(--line); gap: 1px; }
.week-grid, .month-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); overflow: hidden; }
.month-cell { min-width: 0; }
.month-cell.outside { opacity: .42; }
.calendar-day { position: relative; width: 100%; min-height: 170px; padding: 15px; border: 0; background: #0d1723; color: var(--text); text-align: right; display: flex; flex-direction: column; gap: 7px; transition: background .2s, box-shadow .2s; }
.month-grid .calendar-day { min-height: 125px; padding: 11px; }
.calendar-day:hover, .calendar-day:focus-visible { background: #142231; box-shadow: inset 0 0 0 1px rgba(32,210,193,.45); outline: 0; }
.calendar-day.is-today { z-index: 1; background: rgba(32,210,193,.1); box-shadow: inset 0 0 0 1px var(--cyan), 0 0 0 0 rgba(32,210,193,.3); animation: today-focus 2.4s ease-in-out infinite; }
.current-day-badge { align-self: flex-start; padding: 3px 7px; border-radius: 999px; background: var(--cyan); color: #04100f; font-size: .65rem; font-weight: 900; line-height: 1.2; }
.calendar-day.selected .day-number { color: var(--cyan); }
.day-number { font: 800 1.2rem ui-monospace, Consolas, monospace; direction: ltr; }
.day-name, .event-count { color: var(--muted); font-size: .74rem; }
.day-events { display: grid; gap: 6px; margin-top: 5px; }
.day-events i { position: relative; color: #c7d6e3; font-style: normal; font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 9px; }
.day-events i::before { content: ""; position: absolute; right: 0; top: .35em; width: 4px; height: 8px; border-radius: 3px; background: var(--blue); }
.day-events i.high::before { background: var(--red); }
.day-events i.medium::before { background: var(--amber); }

.event-dialog { width: min(920px, calc(100% - 28px)); max-height: 90vh; border: 1px solid var(--line); border-radius: 20px; background: #0d1723; color: var(--text); padding: 0; overflow: auto; box-shadow: 0 30px 100px rgba(0,0,0,.6); }
.event-dialog::backdrop { background: rgba(2,7,12,.78); backdrop-filter: blur(5px); }
.dialog-close { position: sticky; top: 14px; float: left; z-index: 2; margin: 14px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: #101c29; color: var(--text); font-size: 1.3rem; }
#eventDetails { padding: 30px; }
.detail-head { padding: 4px 0 22px; border-bottom: 1px solid var(--line); }
.detail-head > div { display: flex; align-items: center; gap: 12px; }
.detail-head h2 { margin: 16px 0 8px; font-size: 1.65rem; }
.detail-head p { margin: 0; color: var(--muted); line-height: 1.8; }
.release-now { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
.release-now div { padding: 15px; background: #09111b; border: 1px solid var(--line); border-radius: 12px; }
.release-now dt { color: var(--muted); font-size: .78rem; }
.release-now dd { margin: 8px 0 0; font: 800 1.25rem ui-monospace, Consolas, monospace; direction: ltr; text-align: right; }
.release-now dd.actual { color: var(--cyan); }
.detail-section { margin-top: 28px; }
.detail-section h3 { margin: 0 0 14px; }
.release-history { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.release-history article { display: grid; gap: 9px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(9,17,27,.7); }
.release-history time { color: var(--cyan); font-size: .78rem; }
.release-history span { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; }
.release-history b { color: var(--text); direction: ltr; }
.detail-title-row { display: flex; justify-content: space-between; color: var(--muted); }
.article-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.article-grid article { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #101c29; }
.article-grid article > span { color: var(--cyan); font-size: .7rem; }
.article-grid h4 { margin: 8px 0; }
.article-grid p { color: var(--muted); line-height: 1.65; font-size: .8rem; }
.article-grid button { border: 0; background: transparent; color: var(--muted); padding: 0; }
.trade-link { display: block; margin-top: 26px; padding: 14px 18px; border-radius: 11px; background: var(--cyan); color: #04100f; font-weight: 800; text-align: center; text-decoration: none; }

.filter-dialog { width: min(540px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 18px; background: #0d1723; color: var(--text); padding: 22px; box-shadow: 0 30px 100px rgba(0,0,0,.6); }
.filter-dialog::backdrop { background: rgba(2,7,12,.75); backdrop-filter: blur(5px); }
.filter-dialog-head { display: flex; justify-content: space-between; align-items: center; }
.filter-dialog-head h2 { margin: 0; font-size: 1.1rem; }
.filter-dialog-head button { border: 0; background: transparent; color: var(--muted); font-size: 1.4rem; }
.impact-options { display: flex; gap: 10px; margin-top: 12px; }
.impact-options label { flex: 1; display: flex; justify-content: center; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.country-filter { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.country-filter label { position: relative; }
.country-filter input { position: absolute; opacity: 0; }
.country-filter span { min-height: 48px; display: flex; align-items: center; gap: 9px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: .78rem; }
.country-filter b { direction: ltr; color: var(--text); }
.country-filter input:checked + span { border-color: var(--cyan); color: var(--text); background: var(--cyan-soft); }
.filter-dialog-actions { display: flex; gap: 9px; margin-top: 22px; }
.filter-dialog-actions button { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 11px; }
.filter-dialog-actions .secondary { background: transparent; color: var(--muted); }
.filter-dialog-actions .primary { background: var(--cyan); color: #04100f; border-color: var(--cyan); font-weight: 800; }

@media (max-width: 900px) {
  .topbar nav { display: none; }
  .calendar-toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { width: 100%; justify-content: space-between; }
}
@media (max-width: 600px) {
  main { width: min(100% - 22px, 1450px); padding-top: 26px; }
  .topbar { padding: 0 14px; gap: 12px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .clock-card { text-align: right; border-right: 0; border-left: 2px solid var(--cyan); padding-right: 0; padding-left: 16px; }
  .summary-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); border-radius: 11px; }
  .summary-bar article { min-height: 63px; padding: 8px 5px; text-align: center; border-left: 1px solid var(--line); display: grid; grid-template-columns: 1fr; }
  .summary-bar span { font-size: .58rem; }
  .summary-bar strong { font-size: 1rem; }
  .summary-bar .next-card { grid-template-columns: 1fr; gap: 4px; }
  .summary-bar .next-card span { grid-column: auto; }
  .summary-bar .next-card small { display: none; }
  .next-card strong { text-align: center; font-size: .78rem; }
  .calendar-toolbar { gap: 10px; }
  .section-heading { align-items: flex-start; }
  .calendar-controls { width: 100%; justify-content: space-between; }
  .view-switcher { flex: 1; justify-content: center; }
  .view-switcher button { flex: 1; }
  .period-label { max-width: 44%; overflow: hidden; text-overflow: ellipsis; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr auto; width: 100%; }
  .quick-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .quick-nav button { padding-inline: 5px; white-space: nowrap; }
  .date-picker { width: 100%; }
  .filter-button { width: auto; align-self: stretch; }
  .table-wrap { overflow-x: hidden; min-height: 340px; }
  #dayView table, #dayView tbody { display: block; width: 100%; min-width: 0; }
  #dayView thead { display: none; }
  #dayView .event-card { display: grid; grid-template-columns: auto auto 1fr; grid-template-areas: "time currency impact" "title title title" "previous forecast actual"; gap: 10px 12px; margin: 9px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #0d1723; }
  #dayView .event-card td { border: 0; padding: 0; min-width: 0; }
  #dayView .event-time { grid-area: time; }
  #dayView .event-currency { grid-area: currency; }
  #dayView .event-impact { grid-area: impact; justify-self: end; }
  #dayView .event-title-cell { grid-area: title; padding: 3px 0 7px; border-bottom: 1px solid var(--line); }
  #dayView .next-news-badge { margin: 0 0 8px; width: max-content; }
  #dayView .event-link { width: 100%; font-size: .9rem; }
  #dayView .metric { display: grid; gap: 5px; text-align: right; font-size: .8rem; }
  #dayView .metric::before { content: attr(data-label); color: var(--muted); font: .62rem "Segoe UI", Tahoma, Arial, sans-serif; }
  #dayView .metric:nth-last-child(3) { grid-area: previous; }
  #dayView .metric:nth-last-child(2) { grid-area: forecast; }
  #dayView .metric:nth-last-child(1) { grid-area: actual; }
  .week-grid, .month-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .calendar-day, .month-grid .calendar-day { min-height: 92px; padding: 7px 3px; gap: 4px; text-align: center; align-items: center; }
  .current-day-badge { align-self: center; padding: 2px 5px; font-size: .56rem; }
  .day-number { font-size: .9rem; }
  .day-name, .event-count { font-size: .56rem; line-height: 1.25; }
  .day-events { display: flex; gap: 3px; }
  .day-events i { width: 5px; height: 5px; padding: 0; border-radius: 50%; background: var(--blue); font-size: 0; }
  .day-events i::before { display: none; }
  .day-events i.high { background: var(--red); }
  .day-events i.medium { background: var(--amber); }
  .release-history, .article-grid { grid-template-columns: 1fr; }
  #eventDetails { padding: 22px 16px; }
  .country-filter { grid-template-columns: 1fr; }
  .impact-options { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .calendar-stage.zoom-in, .calendar-stage.zoom-out, .calendar-day.is-today, .next-news-badge::before { animation: none; }
}
