:root {
    --c-background: #f8f9fa;
    --c-surface: #ffffff;
    --c-border: #e9ecef;
    --c-text-primary: #1c2127;
    --c-text-secondary: #6c757d;
    --c-brand: #0056b3;
    --c-high-impact: #fc0504;
    --c-medium-impact: #f69738;
    --c-low-impact: #f8e22c;
    --c-holiday-impact: #adb5bd;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--c-background);
    color: var(--c-text-primary);
    margin: 0;
    line-height: 1.4;
    font-size: 14px; 
}

header {
    background-color: var(--c-surface);
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

#userInfo {
    text-align: left;
    font-size: 0.9em;
    color: var(--c-text-secondary);
    margin-right: 0.5rem;
    white-space: nowrap;
}
#userInfo p { margin: 0; line-height: 1.3; }
#currentTime { font-weight: 600; font-family: 'Roboto Mono', monospace; color: var(--c-text-primary); }

#timeZoneSelector, #refreshBtn {
    height: 32px;
    border: 1px solid var(--c-border);
    border-radius: 5px;
    background-color: var(--c-background);
    padding: 0 8px;
    font-family: inherit;
    font-size: 0.9em;
    cursor: pointer;
    transition: background-color 0.2s;
    color: #000;
    padding-right: 25px;
}
#timeZoneSelector:hover, #refreshBtn:hover { background-color: #e9ecef; }
#refreshBtn { display: flex; align-items: center; justify-content: center; width: 34px; padding: 0; }
#refreshBtn:disabled { cursor: not-allowed; opacity: 0.7; }
#refreshBtn.loading svg { animation: spin 1s linear infinite; }

.filter-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--c-border);
}

.filter-btn { padding: 4px 10px; font-size: 0.85em; font-weight: 600; border: 1px solid #ced4da; border-radius: 5px; background-color: transparent; color: #495057; cursor: pointer; transition: all 0.2s ease-in-out; }
.filter-btn:hover { background-color: #e9ecef; }
.filter-btn.active { color: #fff; border-color: transparent; }
.filter-btn[data-filter="high"].active { background-color: var(--c-high-impact); }
.filter-btn[data-filter="medium"].active { background-color: var(--c-medium-impact); color: var(--c-text-primary); }
.filter-btn[data-filter="low"].active { background-color: var(--c-low-impact); }

.reset-btn {
    border-color: #6c757d;
    color: #6c757d;
}
.reset-btn:hover {
    background-color: #6c757d;
    color: #fff;
}

main { padding: 1rem; margin: 0 auto; }

#calendarContainer .loader-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    color: var(--c-text-secondary);
}

.calendar-day-section {
    margin-bottom: 1.5rem;
    background-color: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 6px;
    overflow: hidden;
}
.calendar-day-section h2 {
    color: var(--c-brand);
    background-color: var(--c-background);
    padding: 0.5rem 1rem;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    border-bottom: 1px solid var(--c-border);
}

.no-events-message { padding: 1rem; text-align: center; }
.no-events-message p { margin: 0; color: var(--c-text-secondary); font-style: italic; font-size: 0.9em; }

.calendar-table { width: 100%; border-collapse: collapse; }
.calendar-table th, .calendar-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--c-border); vertical-align: middle; transition: color 0.3s, opacity 0.3s; }
.calendar-table th { font-size: 0.75rem; text-transform: uppercase; color: var(--c-text-secondary); letter-spacing: 0.5px; border-bottom: 2px solid var(--c-border); }
.calendar-table tr:last-child td { border-bottom: none; }
.calendar-table tr:hover { background-color: var(--c-background); }

.event-title-cell { font-weight: 600; color: var(--c-text-primary); }
.currency-cell { display: flex; align-items: center; gap: 8px; font-weight: 600; }

.fi { font-size: 1.1em; border-radius: 2px; }
.col-numeric { font-family: 'Roboto Mono', monospace; text-align: right; }
.impact-cell .impact-bar { display: inline-block; width: 14px; height: 14px; border-radius: 1px; margin-right: 8px; vertical-align: middle; }
.impact-high { background-color: var(--c-high-impact); }
.impact-medium { background-color: var(--c-medium-impact); }
.impact-low { background-color: var(--c-low-impact); }
.impact-holiday { background-color: var(--c-holiday-impact); }

.event-passed td {
    color: var(--c-text-secondary);
    opacity: 0.75;
}

.live-timer-widget {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 8px;
    padding: 1px 6px;
    font-size: 0.85em;
    font-weight: 600;
    font-family: 'Roboto Mono', monospace;
    color: var(--c-high-impact);
    background-color: rgba(220, 53, 69, 0.1);
    border-radius: 3px;
    vertical-align: middle;
}
.live-dot {
    width: 6px;
    height: 6px;
    background-color: var(--c-high-impact);
    border-radius: 50%;
    animation: blink 1.5s infinite ease-in-out;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

.loader { border: 4px solid #e9ecef; border-top: 4px solid var(--c-text-secondary); border-radius: 50%; width: 30px; height: 30px; animation: spin 1s linear infinite; margin-bottom: 0.5rem; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@media (max-width: 768px) {
    header { padding: 0.5rem; }
    .header-controls { gap: 0.5rem; }
    .filter-controls { margin-left: 0; padding-left: 0; border-left: none; width: 100%; }
    main { padding: 0.5rem; }
    html { font-size: 12px; }

    /* Keep the desktop-style tabular layout, just tighter spacing */
    .calendar-day-section h2 { font-size: 0.95rem; padding: 0.4rem 0.75rem; }

    .calendar-table { table-layout: fixed; }
    .calendar-table th, .calendar-table td { padding: 6px 8px; }
    .calendar-table th { font-size: 0.7rem; letter-spacing: 0.3px; }

    /* Compact column widths to fit small screens while preserving desktop structure */
    .calendar-table th:nth-child(1), .calendar-table td:nth-child(1) { width: 64px; white-space: nowrap; }   /* Time */
    .calendar-table th:nth-child(2), .calendar-table td:nth-child(2) { width: 74px; white-space: nowrap; }   /* Currency */
    .calendar-table th:nth-child(3), .calendar-table td:nth-child(3) { width: 58px; white-space: nowrap; }   /* Impact */
    .calendar-table th:nth-child(5), .calendar-table td:nth-child(5) { width: 70px; white-space: nowrap; }   /* Forecast */
    .calendar-table th:nth-child(6), .calendar-table td:nth-child(6) { width: 70px; white-space: nowrap; }   /* Previous */

    .event-time-cell, .currency-cell, .col-numeric { white-space: nowrap; }
    .event-title-cell { font-size: 0.95em; overflow: hidden; text-overflow: ellipsis; }

    .currency-cell { gap: 6px; }
    .fi { font-size: 0.9em; }
    .impact-cell .impact-bar { width: 10px; height: 10px; margin-right: 6px; }

    .live-timer-widget { font-size: 0.75em; gap: 4px; padding: 1px 4px; }
}

/* Extra-tight layout for very small phones */
@media (max-width: 480px) {
    html { font-size: 11px; }
    .calendar-day-section h2 { font-size: 0.9rem; padding: 0.35rem 0.6rem; }
    .calendar-table th, .calendar-table td { padding: 5px 6px; }
    .calendar-table th { font-size: 0.65rem; letter-spacing: 0.25px; }

    .calendar-table th:nth-child(1), .calendar-table td:nth-child(1) { width: 56px; }  /* Time */
    .calendar-table th:nth-child(2), .calendar-table td:nth-child(2) { width: 68px; }  /* Currency */
    .calendar-table th:nth-child(3), .calendar-table td:nth-child(3) { width: 52px; }  /* Impact */
    .calendar-table th:nth-child(5), .calendar-table td:nth-child(5) { width: 64px; }  /* Forecast */
    .calendar-table th:nth-child(6), .calendar-table td:nth-child(6) { width: 64px; }  /* Previous */

    .fi { font-size: 0.8em; }
    .impact-cell .impact-bar { width: 8px; height: 8px; margin-right: 5px; }
    .live-timer-widget { font-size: 0.7em; gap: 3px; padding: 1px 3px; }
}

[data-theme='dark'], .light-scheme, body.your-theme-dark-mode-class {
    --c-background: #121212;
    --c-surface: #1e1e1e;
    --c-border: #333333;
    --c-text-primary: #e0e0e0;
    --c-text-secondary: #888888;
    --c-brand: #5a9ae2;
}
[data-theme='dark'] header,
.light-scheme header,
body.your-theme-dark-mode-class header,
[data-theme='dark'] .calendar-day-section,
.light-scheme .calendar-day-section,
body.your-theme-dark-mode-class .calendar-day-section,
[data-theme='dark'] .calendar-table tr:hover,
.light-scheme .calendar-table tr:hover,
body.your-theme-dark-mode-class .calendar-table tr:hover {
    background-color: var(--c-surface);
}
[data-theme='dark'] .calendar-day-section h2,
.light-scheme .calendar-day-section h2,
body.your-theme-dark-mode-class .calendar-day-section h2 { background-color: #181818; }
[data-theme='dark'] #timeZoneSelector,
.light-scheme #timeZoneSelector,
body.your-theme-dark-mode-class #timeZoneSelector,
[data-theme='dark'] #refreshBtn,
.light-scheme #refreshBtn,
body.your-theme-dark-mode-class #refreshBtn { background-color: #2c2c2c; border-color: #444; color: var(--c-text-primary); }
[data-theme='dark'] .filter-btn,
.light-scheme .filter-btn,
body.your-theme-dark-mode-class .filter-btn { background-color: transparent; border-color: #444; color: var(--c-text-secondary); }
[data-theme='dark'] .filter-btn:hover,
.light-scheme .filter-btn:hover,
body.your-theme-dark-mode-class .filter-btn:hover { background-color: #333; }
[data-theme='dark'] .filter-btn[data-filter="medium"].active,
.light-scheme .filter-btn[data-filter="medium"].active,
body.your-theme-dark-mode-class .filter-btn[data-filter="medium"].active { color: #121212; }
[data-theme='dark'] .reset-btn,
.light-scheme .reset-btn,
body.your-theme-dark-mode-class .reset-btn { border-color: var(--c-text-secondary); color: var(--c-text-secondary); }
[data-theme='dark'] .reset-btn:hover,
.light-scheme .reset-btn:hover,
body.your-theme-dark-mode-class .reset-btn:hover { background-color: var(--c-text-secondary); color: var(--c-surface); }
[data-theme='dark'] .live-timer-widget,
.light-scheme .live-timer-widget,
body.your-theme-dark-mode-class .live-timer-widget { background-color: rgba(220, 53, 69, 0.2); }
/* Upcoming events subtle pulse animation */
@keyframes pulseUpcoming { 0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); } 50% { box-shadow: 0 0 0 8px rgba(220, 53, 69, 0.12); } 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); } }
.calendar-table tr.event-upcoming { animation: pulseUpcoming 2s ease-in-out infinite; }

/* Data-centric UI enhancements rolled back per request */
/* Tiny inline date for Today/Tomorrow headings */
.calendar-day-section h2 .day-date {
  font-size: 0.8em;
  font-weight: 500;
  color: var(--c-text-secondary, #6b7280);
  margin-left: 0.5rem;
}
/* Responsive refinements to match desktop-style list on mobile and add a tiny pointer to the next upcoming item */

/* Zebra striping for better scanability */
.calendar-table tbody tr:nth-child(odd) {
  background-color: rgba(0,0,0,0.02);
}
[data-theme='dark'] .calendar-table tbody tr:nth-child(odd),
.light-scheme .calendar-table tbody tr:nth-child(odd),
body.your-theme-dark-mode-class .calendar-table tbody tr:nth-child(odd) {
  background-color: rgba(255,255,255,0.03);
}

/* Tiny pointer for next upcoming event row */
.calendar-table tr.next-event {
  position: relative;
  box-shadow: inset 3px 0 0 0 var(--c-brand);
}
.calendar-table tr.next-event td:first-child {
  color: var(--c-brand);
  font-weight: 700;
}
.calendar-table tr.next-event td:first-child::before {
  content: '';
  display: inline-block;
  width: 0; height: 0;
  margin-right: 6px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid var(--c-brand);
  vertical-align: middle;
}

/* Hide less-critical numeric columns on small screens to preserve desktop table layout */
@media (max-width: 640px) {
  .calendar-table { table-layout: fixed; }

  /* Hide Forecast and Previous columns to fit */
  .calendar-table th:nth-child(5), .calendar-table td:nth-child(5),
  .calendar-table th:nth-child(6), .calendar-table td:nth-child(6) {
    display: none;
  }

  /* Tighten key columns to preserve structure */
  .calendar-table th:nth-child(1), .calendar-table td:nth-child(1) { /* Time */
    width: 56px; white-space: nowrap;
  }
  .calendar-table th:nth-child(2), .calendar-table td:nth-child(2) { /* Currency */
    width: 64px; white-space: nowrap;
  }
  .calendar-table th:nth-child(3), .calendar-table td:nth-child(3) { /* Impact */
    width: 44px; white-space: nowrap;
  }

  .event-time-cell, .currency-cell, .col-numeric { white-space: nowrap; }
  .event-title-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
/* Mobile overrides to match desktop-style layout while fitting small screens */
@media (max-width: 768px) {
  /* Keep table layout but hide less-critical numeric columns to fit */
  .calendar-table { table-layout: fixed; }
  .calendar-table th:nth-child(5), .calendar-table td:nth-child(5),
  .calendar-table th:nth-child(6), .calendar-table td:nth-child(6) {
    display: none;
  }

  /* Tighten key columns and preserve structure */
  .calendar-table th:nth-child(1), .calendar-table td:nth-child(1) { /* Time */
    width: 56px; white-space: nowrap;
  }
  .calendar-table th:nth-child(2), .calendar-table td:nth-child(2) { /* Currency */
    width: 64px; white-space: nowrap;
  }
  .calendar-table th:nth-child(3), .calendar-table td:nth-child(3) { /* Impact */
    width: 44px; white-space: nowrap;
  }

  /* Let titles wrap to preserve content similar to desktop */
  .event-title-cell {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.3;
  }
  .event-title-cell a { display: inline-block; }

  /* Compact visuals */
  .calendar-day-section h2 { font-size: 0.92rem; padding: 0.35rem 0.6rem; }
  .calendar-table th, .calendar-table td { padding: 5px 6px; }
  .calendar-table th { font-size: 0.68rem; letter-spacing: 0.3px; }
  .fi { font-size: 0.85em; }
  .impact-cell .impact-bar { width: 8px; height: 8px; margin-right: 4px; }

  /* Ensure the tiny pointer stands out but remains subtle on mobile */
  .calendar-table tr.next-event {
    box-shadow: inset 2px 0 0 0 var(--c-brand);
  }
  .calendar-table tr.next-event td:first-child::before {
    border-left-color: var(--c-brand);
    margin-right: 4px;
    border-top-width: 5px;
    border-bottom-width: 5px;
    border-left-width: 5px;
  }
}
/* Preserve desktop-style columns on mobile with horizontal scroll; override any prior column-hiding rules */
@media (max-width: 768px) {
  /* Allow horizontal scroll within each day section */
  .calendar-day-section { overflow-x: auto; }

  /* Keep full desktop columns by ensuring table is wider than viewport */
  .calendar-table { min-width: 820px; table-layout: fixed; }

  /* Re-enable Forecast and Previous columns if previously hidden */
  .calendar-table th:nth-child(5), .calendar-table td:nth-child(5),
  .calendar-table th:nth-child(6), .calendar-table td:nth-child(6) {
    display: table-cell;
  }

  /* Compact visuals to reduce overflow */
  .calendar-day-section h2 { font-size: 0.92rem; padding: 0.35rem 0.6rem; }
  .calendar-table th, .calendar-table td { padding: 6px 8px; }
  .calendar-table th { font-size: 0.7rem; letter-spacing: 0.3px; }

  /* Tighten key columns */
  .calendar-table th:nth-child(1), .calendar-table td:nth-child(1) { /* Time */
    width: 64px; white-space: nowrap;
  }
  .calendar-table th:nth-child(2), .calendar-table td:nth-child(2) { /* Currency */
    width: 74px; white-space: nowrap;
  }
  .calendar-table th:nth-child(3), .calendar-table td:nth-child(3) { /* Impact */
    width: 58px; white-space: nowrap;
  }

  .event-time-cell, .currency-cell, .col-numeric { white-space: nowrap; }
  .event-title-cell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .fi { font-size: 0.9em; }
  .impact-cell .impact-bar { width: 10px; height: 10px; margin-right: 6px; }

  /* Ensure the tiny pointer remains subtle on mobile */
  .calendar-table tr.next-event { box-shadow: inset 2px 0 0 0 var(--c-brand); }
  .calendar-table tr.next-event td:first-child::before {
    margin-right: 4px; border-top-width: 5px; border-bottom-width: 5px; border-left-width: 5px;
  }
}

/* Extra-tight layout for very small phones */
@media (max-width: 480px) {
  .calendar-table { min-width: 760px; }
  html { font-size: 11px; }
  .calendar-day-section h2 { font-size: 0.88rem; padding: 0.3rem 0.55rem; }
  .calendar-table th, .calendar-table td { padding: 5px 6px; }
  .calendar-table th { font-size: 0.65rem; letter-spacing: 0.25px; }

  .calendar-table th:nth-child(1), .calendar-table td:nth-child(1) { width: 56px; }  /* Time */
  .calendar-table th:nth-child(2), .calendar-table td:nth-child(2) { width: 68px; }  /* Currency */
  .calendar-table th:nth-child(3), .calendar-table td:nth-child(3) { width: 52px; }  /* Impact */

  .fi { font-size: 0.8em; }
  .impact-cell .impact-bar { width: 8px; height: 8px; margin-right: 5px; }
}

/* Desktop fit improvements: constrain max width and center for readability while keeping data-centric layout */
@media (min-width: 769px) {
  main { }
}
/* Mobile-only: show only Time, Currency, Event; ensure Time fits; refine spacing for compact, data-centric layout */
@media (max-width: 768px) {
  /* Fit to viewport: no horizontal scroll, fixed layout */
  .calendar-table { min-width: 0 !important; width: 100% !important; table-layout: fixed; }

  /* Hide Impact, Forecast, Previous columns entirely */
  .calendar-table th:nth-child(3), .calendar-table td:nth-child(3),
  .calendar-table th:nth-child(5), .calendar-table td:nth-child(5),
  .calendar-table th:nth-child(6), .calendar-table td:nth-child(6) {
    display: none !important;
  }

  /* Tight, readable column widths */
  .calendar-table th:nth-child(1), .calendar-table td:nth-child(1) { /* Time */
    width: 104px; white-space: nowrap;
  }
  .calendar-table th:nth-child(2), .calendar-table td:nth-child(2) { /* Currency */
    width: 72px; white-space: nowrap;
  }
  .calendar-table th:nth-child(4), .calendar-table td:nth-child(4) { /* Event */
    width: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* Compact cell paddings and font sizes */
  .calendar-table th, .calendar-table td { padding: 5px 6px; }
  .calendar-table th { font-size: 0.7rem; letter-spacing: 0.25px; }
  .event-time-cell { font-size: 1em; }

  /* Save space in Currency: hide flag on mobile */
  .currency-cell { gap: 4px; }
  .currency-cell .fi { display: none; }

  /* Remove space after event name: hide live timer widget on mobile */
  .live-timer-widget { display: none !important; }
  .impact-cell .impact-bar { display: none; } /* Ensure no residual impact spacer appears */

  /* Keep tiny pointer subtle on mobile */
  .calendar-table tr.next-event { box-shadow: inset 2px 0 0 0 var(--c-brand); }
  .calendar-table tr.next-event td:first-child { color: var(--c-brand); font-weight: 700; }
  .calendar-table tr.next-event td:first-child::before {
    content: '';
    display: inline-block;
    width: 0; height: 0;
    margin-right: 4px;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 5px solid var(--c-brand);
    vertical-align: middle;
  }
}

/* Ultra-compact for very small phones */
@media (max-width: 480px) {
  .calendar-table th, .calendar-table td { padding: 4px 6px; }
  .calendar-table th:nth-child(1), .calendar-table td:nth-child(1) { width: 96px; }  /* Time wider to prevent truncation */
  .currency-cell { gap: 3px; }
  .currency-cell .fi { display: none; }
  .live-timer-widget { display: none !important; }
}
/* Final mobile fit overrides: preserve desktop columns with horizontal scroll; compact sizing */
@media (max-width: 768px) {
  /* Keep table header for desktop-like appearance */
  .calendar-table thead { display: table-header-group !important; }

  /* Preserve all columns; enable horizontal scroll inside day section */
  .calendar-day-section { overflow-x: auto; }
  .calendar-table { width: 100% !important; min-width: 900px; table-layout: fixed; }

  /* Ensure Impact, Forecast, Previous remain visible */
  .calendar-table th:nth-child(3), .calendar-table td:nth-child(3),
  .calendar-table th:nth-child(5), .calendar-table td:nth-child(5),
  .calendar-table th:nth-child(6), .calendar-table td:nth-child(6) {
    display: table-cell !important;
  }

  /* Tight spacing and smaller text for compact fit */
  .calendar-table th, .calendar-table td { padding: 4px 6px !important; }
  .calendar-table th { text-transform: none !important; letter-spacing: 0 !important; }
  .calendar-table td { font-size: 0.9em; }

  /* Column widths: Time, Currency, Impact compact; Event truncates on one line */
  .calendar-table th:nth-child(1), .calendar-table td:nth-child(1) { /* Time */
    width: 92px !important; white-space: nowrap;
  }
  .calendar-table th:nth-child(2), .calendar-table td:nth-child(2) { /* Currency */
    width: 56px !important; white-space: nowrap;
  }
  .calendar-table th:nth-child(3), .calendar-table td:nth-child(3) { /* Impact */
    width: 38px !important; text-align: center; white-space: nowrap;
  }
  .calendar-table th:nth-child(4), .calendar-table td:nth-child(4) { /* Event */
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* Visual trims: hide flags and live timer on mobile; keep a tiny impact dot */
  .currency-cell .fi, .live-timer-widget { display: none !important; }
  .impact-cell .impact-bar { width: 10px; height: 10px; margin: 0; display: inline-block; }
}

/* Ultra-compact for very small phones */
@media (max-width: 480px) {
  .calendar-table thead { display: table-header-group !important; }

  /* Let content drive widths; keep viewport-fit */
  .calendar-table { width: 100% !important; table-layout: auto; }

  .calendar-table th, .calendar-table td { padding: 3px 4px !important; }
  .calendar-table td { font-size: 0.85em; }

  .calendar-table th:nth-child(1), .calendar-table td:nth-child(1) { width: 84px !important; }  /* Time */
  .calendar-table th:nth-child(2), .calendar-table td:nth-child(2) { width: 50px !important; }  /* Currency */
  .calendar-table th:nth-child(3), .calendar-table td:nth-child(3) { width: 30px !important; }  /* Impact */
  .event-title-cell { font-size: 0.85em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .impact-cell .impact-bar { width: 7px; height: 7px; }
}
/* Mobile: remove Forecast and Previous to maximize Event width and fit all key columns cleanly */
@media (max-width: 768px) {
  /* Ensure table fits viewport (no forced horizontal scroll) */
  .calendar-table { min-width: 0 !important; width: 100% !important; table-layout: fixed; }

  /* Hide Forecast (5) and Previous (6) columns on mobile */
  .calendar-table th:nth-child(5), .calendar-table td:nth-child(5),
  .calendar-table th:nth-child(6), .calendar-table td:nth-child(6) {
    display: none !important;
  }

  /* Single-line, truncated Event for clean alignment */
  .calendar-table th:nth-child(4), .calendar-table td:nth-child(4) {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
}
/* Final mobile width overrides: minimize Time/Currency/Impact to free space for Event; keep desktop-style header; hide Forecast/Previous */
@media (max-width: 768px) {
  /* Desktop-like header visible */
  .calendar-table thead { display: table-header-group !important; }

  /* Fit to viewport; let columns size to content */
  .calendar-table { width: 100% !important; table-layout: auto !important; }

  /* Remove Forecast and Previous to maximize Event width */
  .calendar-table th:nth-child(5), .calendar-table td:nth-child(5),
  .calendar-table th:nth-child(6), .calendar-table td:nth-child(6) {
    display: none !important;
  }

  /* Compact spacing and text */
  .calendar-table th, .calendar-table td { padding: 3px 4px !important; }
  .calendar-table td { font-size: 0.86em; }

  /* Shrink Time/Currency/Impact; free remaining width for Event */
  .event-time-cell { text-align: left !important; }
  .calendar-table th:nth-child(1), .calendar-table td:nth-child(1) { /* Time */
    width: 82px !important; white-space: nowrap;
  }
  .calendar-table th:nth-child(2), .calendar-table td:nth-child(2) { /* Currency */
    width: 52px !important; white-space: nowrap;
  }
  .calendar-table th:nth-child(3), .calendar-table td:nth-child(3) { /* Impact */
    width: 30px !important; text-align: center; white-space: nowrap;
  }
  .calendar-table th:nth-child(4), .calendar-table td:nth-child(4) { /* Event */
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* Optional: hide flags and timers to reclaim horizontal space */
  .currency-cell .fi, .live-timer-widget { display: none !important; }

  /* Tiny impact dot for compact visual */
  .impact-cell .impact-bar { width: 8px; height: 8px; margin: 0; display: inline-block; }
}

/* Ultra-compact phones */
@media (max-width: 480px) {
  .calendar-table th, .calendar-table td { padding: 2px 3px !important; }
  .calendar-table td { font-size: 0.84em; }

  .calendar-table th:nth-child(1), .calendar-table td:nth-child(1) { width: 78px !important; }  /* Time */
  .calendar-table th:nth-child(2), .calendar-table td:nth-child(2) { width: 48px !important; }  /* Currency */
  .calendar-table th:nth-child(3), .calendar-table td:nth-child(3) { width: 28px !important; }  /* Impact */
}