/* ── CSS VARIABLES ── */
:root {
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --border: #E4E2DB;
  --text-primary: #1A1916;
  --text-secondary: #6B6860;
  --text-muted: #A09E97;
  --accent: #1A3A5C;
  --accent-light: #E8EEF4;
  --accent-mid: #2E5F8A;
  --common: #2C5F8A;
  --common-bg: #EAF0F6;
  --finance: #2D6A4F;
  --finance-bg: #EAF3EE;
  --marketing: #7B3A2A;
  --marketing-bg: #F5EBE8;
  --supplychain: #5B3A8A;
  --supplychain-bg: #F0EBF8;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.13);
  --hour-height: 60px;
}

/* ── RESET ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text-primary); min-height: 100vh; }

/* ── PORTAL PAGE ── */
#portal-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; background: var(--accent); padding: 40px 20px; }
.portal-logo { font-size: 52px; margin-bottom: 20px; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
.portal-title { font-family: 'Playfair Display', serif; font-size: 44px; font-weight: 600; color: #fff; text-align: center; line-height: 1.2; margin-bottom: 8px; }
.portal-subtitle { font-size: 15px; color: rgba(255,255,255,0.5); text-align: center; margin-bottom: 60px; font-weight: 300; letter-spacing: 0.04em; }
.portal-cards { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; margin-bottom: 48px; }
.portal-card { width: 240px; padding: 36px 28px 32px; background: rgba(255,255,255,0.07); border: 1.5px solid rgba(255,255,255,0.14); border-radius: 20px; cursor: pointer; transition: all 0.25s ease; text-align: center; }
.portal-card:hover { background: rgba(255,255,255,0.13); border-color: rgba(255,255,255,0.35); transform: translateY(-6px); box-shadow: 0 24px 56px rgba(0,0,0,0.25); }
.portal-card:active { transform: translateY(-2px); }
.portal-card-icon { font-size: 40px; margin-bottom: 16px; display: block; animation: float 3s ease-in-out infinite; }
.portal-card:nth-child(2) .portal-card-icon { animation-delay: 0.5s; }
.portal-card-title { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 600; color: #fff; margin-bottom: 8px; display: block; }
.portal-card-desc { font-size: 12px; color: rgba(255,255,255,0.5); line-height: 1.6; margin-bottom: 24px; display: block; }
.portal-card-btn { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.13); color: #fff; padding: 8px 20px; border-radius: 20px; font-size: 12px; font-weight: 500; transition: background 0.2s; }
.portal-card:hover .portal-card-btn { background: rgba(255,255,255,0.24); }
.portal-footer { font-size: 12px; color: rgba(255,255,255,0.25); text-align: center; }

/* ── SECTION SELECTOR (Welcome Page) ── */
#welcome-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; background: var(--accent); padding: 40px 20px; position: relative; }
.welcome-logo { font-size: 52px; margin-bottom: 24px; animation: float 3s ease-in-out infinite; }
.welcome-title { font-family: 'Playfair Display', serif; font-size: 44px; font-weight: 600; color: #fff; text-align: center; line-height: 1.2; margin-bottom: 10px; }
.welcome-subtitle { font-size: 16px; color: rgba(255,255,255,0.55); text-align: center; margin-bottom: 56px; font-weight: 300; letter-spacing: 0.04em; }
.welcome-prompt { font-size: 11px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(255,255,255,0.4); margin-bottom: 22px; text-align: center; }
.section-cards { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; margin-bottom: 48px; }
.section-card { width: 210px; padding: 40px 28px 32px; background: rgba(255,255,255,0.07); border: 1.5px solid rgba(255,255,255,0.14); border-radius: 18px; cursor: pointer; transition: all 0.25s ease; text-align: center; }
.section-card:hover { background: rgba(255,255,255,0.13); border-color: rgba(255,255,255,0.35); transform: translateY(-5px); box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
.section-card:active { transform: translateY(-2px); }
.section-card-letter { font-family: 'Playfair Display', serif; font-size: 64px; font-weight: 600; color: #fff; line-height: 1; margin-bottom: 10px; display: block; }
.section-card-label { font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.6); letter-spacing: 0.08em; text-transform: uppercase; display: block; margin-bottom: 20px; }
.section-card-btn { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.13); color: #fff; padding: 8px 20px; border-radius: 20px; font-size: 12px; font-weight: 500; transition: background 0.2s; }
.section-card:hover .section-card-btn { background: rgba(255,255,255,0.22); }
.welcome-footer { font-size: 12px; color: rgba(255,255,255,0.28); text-align: center; }

/* ── CALENDAR APP ── */
#calendar-app { display: none; }

/* ── HEADER ── */
header { background: var(--accent); color: #fff; padding: 0 40px; display: flex; align-items: center; justify-content: space-between; height: 70px; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 16px rgba(0,0,0,0.15); }
.header-title { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 600; letter-spacing: 0.01em; }
.header-sub { font-size: 12px; opacity: 0.65; margin-top: 2px; font-weight: 300; }
.section-badge { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.12); padding: 5px 14px; border-radius: 20px; font-size: 12px; font-weight: 500; border: 1px solid rgba(255,255,255,0.2); cursor: pointer; transition: background 0.2s; position: relative; }
.section-badge:hover { background: rgba(255,255,255,0.22); }
.section-badge-dot { width: 6px; height: 6px; border-radius: 50%; background: #4CAF50; }
.sync-badge { display: flex; align-items: center; gap: 7px; background: rgba(255,255,255,0.12); padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 400; cursor: pointer; transition: background 0.2s; border: 1px solid rgba(255,255,255,0.2); }
.sync-badge:hover { background: rgba(255,255,255,0.2); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #4CAF50; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.sync-badge.syncing .sync-dot { background: #FFA726; animation: spin-dot 0.8s linear infinite; }
@keyframes spin-dot { 0%{opacity:1}50%{opacity:0.3}100%{opacity:1} }

/* ── CONTROLS BAR ── */
.controls { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 40px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; position: sticky; top: 70px; z-index: 99; }
.filter-group { display: flex; gap: 8px; align-items: center; }
.filter-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; margin-right: 4px; }
.pill { padding: 6px 16px; border-radius: 20px; font-size: 13px; font-weight: 500; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; transition: all 0.18s; color: var(--text-secondary); }
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active-all { background: var(--common); color: #fff; border-color: var(--common); }
.pill.active-finance { background: var(--finance); color: #fff; border-color: var(--finance); }
.pill.active-marketing { background: var(--marketing); color: #fff; border-color: var(--marketing); }
.pill.active-supplychain { background: var(--supplychain); color: #fff; border-color: var(--supplychain); }
.view-switcher { display: flex; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; margin-left: auto; }
.view-btn { padding: 6px 18px; font-size: 13px; font-weight: 500; background: none; border: none; cursor: pointer; color: var(--text-secondary); transition: all 0.18s; }
.view-btn.active { background: var(--accent); color: #fff; }
.nav-area { display: flex; align-items: center; gap: 12px; }
.nav-btn { width: 32px; height: 32px; border-radius: 8px; border: 1.5px solid var(--border); background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--text-secondary); transition: all 0.15s; }
.nav-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.current-period { font-family: 'Playfair Display', serif; font-size: 18px; font-weight: 600; min-width: 220px; }

/* ── MAIN ── */
main { padding: 28px 40px; max-width: 1300px; margin: 0 auto; }

/* ── MONTHLY VIEW ── */
#monthly-view { display: block; }
#weekly-view { display: none; }
.calendar-grid { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow-x: auto; box-shadow: var(--shadow); }
.day-headers { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); background: var(--accent); }
.day-header { padding: 11px 0; text-align: center; font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.75); text-transform: uppercase; letter-spacing: 0.08em; }
.grid-body { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); }
.grid-cell { min-height: 108px; min-width: 0; padding: 8px 7px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); transition: background 0.12s; overflow: hidden; }
.grid-cell:nth-child(7n) { border-right: none; }
.grid-cell.other-month { background: #FAFAF8; }
.grid-cell.today { background: var(--accent-light); }
.cell-date { font-size: 13px; font-weight: 500; color: var(--text-muted); min-width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 4px; margin-bottom: 4px; padding: 0 4px; }
.grid-cell.today .cell-date { background: var(--accent); color: #fff; border-radius: 6px; width: 100%; min-width: unset; height: 30px; font-size: 13px; font-weight: 600; justify-content: center; letter-spacing: 0.01em; }
.grid-cell.other-month .cell-date { color: #C9C7C0; }
.event-chip { font-size: 11px; font-weight: 500; padding: 2px 7px; border-radius: 4px; margin-bottom: 3px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity 0.15s; }
.event-chip:hover { opacity: 0.78; }
.chip-common { background: var(--common-bg); color: var(--common); }
.chip-finance { background: var(--finance-bg); color: var(--finance); }
.chip-marketing { background: var(--marketing-bg); color: var(--marketing); }
.chip-supplychain { background: var(--supplychain-bg); color: var(--supplychain); }
.chip-hidden { display: none !important; }
.more-events { font-size: 11px; color: var(--text-muted); cursor: pointer; padding: 1px 4px; }
.more-events:hover { color: var(--accent); }

/* ── WEEKLY VIEW ── */
.week-outer { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: visible; }
.week-container { position: relative; min-height: 100vh; }
.week-header-row { display: grid; grid-template-columns: 64px repeat(7, 1fr); background: var(--accent); }
.week-header-time-gutter { border-right: 1px solid rgba(255,255,255,0.15); }
.week-header-day { padding: 12px 4px; text-align: center; font-size: 11px; color: rgba(255,255,255,0.75); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 500; border-left: 1px solid rgba(255,255,255,0.1); }
.week-header-day.today-col { color: #fff; }
.week-header-date { font-size: 22px; font-family: 'Playfair Display', serif; display: block; color: rgba(255,255,255,0.9); line-height: 1.2; }
.week-header-day.today-col .week-header-date { background: rgba(255,255,255,0.25); border-radius: 50%; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; }
.week-sticky-header { position: sticky; top: 125px; z-index: 98; border-radius: 10px 10px 10px 10px; overflow: hidden; }
.week-body-grid { display: grid; grid-template-columns: 64px repeat(7, 1fr); position: relative; }
.week-time-col { display: flex; flex-direction: column; border-right: 1px solid var(--border); }
.week-time-slot { height: var(--hour-height); display: flex; align-items: flex-start; justify-content: flex-end; padding-right: 8px; padding-top: 4px; font-size: 10px; color: var(--text-muted); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.week-day-col-wrap { position: relative; border-left: 1px solid var(--border); }
.week-day-col-wrap.today-day { background: #FAFEF8; }
.week-hour-line { position: absolute; left: 0; right: 0; border-bottom: 1px solid var(--border); pointer-events: none; }
.week-half-line { position: absolute; left: 0; right: 0; border-bottom: 1px dashed rgba(0,0,0,0.06); pointer-events: none; }
.week-ev { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 4px 7px; font-size: 11px; font-weight: 500; cursor: pointer; overflow: hidden; transition: opacity 0.15s, box-shadow 0.15s; line-height: 1.35; border-left: 3px solid rgba(0,0,0,0.15); z-index: 1; }
.week-ev:hover { opacity: 0.85; box-shadow: 0 2px 8px rgba(0,0,0,0.15); z-index: 2; }
.week-ev.ev-common { background: var(--common-bg); color: var(--common); border-left-color: var(--common); }
.week-ev.ev-finance { background: var(--finance-bg); color: var(--finance); border-left-color: var(--finance); }
.week-ev.ev-marketing { background: var(--marketing-bg); color: var(--marketing); border-left-color: var(--marketing); }
.week-ev.ev-supplychain { background: var(--supplychain-bg); color: var(--supplychain); border-left-color: var(--supplychain); }
.week-ev-title { font-weight: 700; white-space: normal; overflow: hidden; line-height: 1.4; word-break: break-word; font-size: 11px; }
.week-ev-time { font-size: 11px; opacity: 1; white-space: nowrap; margin-top: 5px; }

/* ── LEGEND ── */
.legend { display: flex; gap: 20px; margin-bottom: 18px; align-items: center; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.dot-common { background: var(--common); }
.dot-finance { background: var(--finance); }
.dot-marketing { background: var(--marketing); }
.dot-supplychain { background: var(--supplychain); }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,20,18,0.45); display: none; align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(3px); }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: 14px; width: 420px; max-width: 94vw; box-shadow: var(--shadow-lg); overflow: hidden; animation: modal-in 0.2s ease; position: relative; }
@keyframes modal-in { from{transform:scale(0.94);opacity:0} to{transform:scale(1);opacity:1} }
.modal-header { padding: 22px 24px 16px; border-bottom: 1px solid var(--border); }
.modal-category { display: inline-block; font-size: 11px; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase; padding: 3px 10px; border-radius: 12px; margin-bottom: 10px; }
.modal-title { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 600; line-height: 1.3; }
.modal-body { padding: 20px 24px; }
.modal-row { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; font-size: 14px; }
.modal-icon { font-size: 16px; margin-top: 1px; flex-shrink: 0; }
.modal-row-label { font-weight: 500; color: var(--text-primary); }
.modal-row-sub { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.modal-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 8px 16px; background: var(--accent); color: #fff; border-radius: 7px; font-size: 13px; font-weight: 500; text-decoration: none; transition: background 0.15s; }
.modal-link:hover { background: var(--accent-mid); }
.modal-footer { padding: 0 24px 20px; }
.modal-close { position: absolute; top: 16px; right: 18px; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; }

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  header, .controls, main { padding-left: 16px; padding-right: 16px; }
  .current-period { font-size: 15px; min-width: 130px; }
  .grid-cell { min-height: 72px; padding: 5px 3px; }
  .event-chip { font-size: 10px; padding: 1px 4px; }
  .controls { gap: 10px; }
  .view-switcher { margin-left: 0; }
  .filter-group { flex-wrap: wrap; }
}
