/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Dark theme (default) ─────────────────────────────────────────────────── */
:root {
  --bg:         #0f1923;
  --bg2:        #162030;
  --bg3:        #1e2d40;
  --border:     #2a3f56;
  --accent:     #4A90D9;
  --accent2:    #2a6fad;
  --text:       #cfd8e3;
  --text-dim:   #7a8fa6;
  --text-bright:#f0f4f8;
  --red:        #E74C3C;
  --green:      #2ECC71;
  --orange:     #E67E22;
  --purple:     #9B59B6;
  --teal:       #1ABC9C;
  --shadow:     rgba(0,0,0,.5);
  --shadow-lg:  rgba(0,0,0,.7);
  /* Layout */
  --header-h:   56px;
  --toolbar-h:  38px;
  --time-col-w: 52px;
  --day-col-min: 120px;
  --radius:     6px;
  /* Size-small slot heights (default) */
  --slot-h-ten:     24px;
  --slot-h-quarter: 18px;
  --slot-h-hour:    40px;
  --slot-h-day:     80px;
  /* Font */
  --fs-base:    13px;
  --fs-sm:      11px;
  --fs-xs:      10px;
  --fs-lg:      15px;
  --fs-xl:      20px;
  --fs-2xl:     24px;
  /* Zoom — updated by JS on renderTimeline() */
  --ev-zoom-scale: 1;
}

/* ── Light theme ──────────────────────────────────────────────────────────── */
body.light-mode {
  --bg:         #f0f4f8;
  --bg2:        #ffffff;
  --bg3:        #e4eaf2;
  --border:     #c4d0de;
  --accent:     #2a6fad;
  --accent2:    #1a5490;
  --text:       #2c3e50;
  --text-dim:   #5f7a99;
  --text-bright:#0a1929;
  --shadow:     rgba(0,0,0,.15);
  --shadow-lg:  rgba(0,0,0,.25);
}
body.light-mode .tl-cell:hover        { background: rgba(42,111,173,.07); }
body.light-mode .tl-cell.locked       { background: repeating-linear-gradient(45deg,rgba(231,76,60,.06),rgba(231,76,60,.06) 4px,transparent 4px,transparent 10px); }
body.light-mode .tl-row-current       { background: rgba(42,111,173,.05) !important; }
body.light-mode .event-block          { box-shadow: 0 1px 4px rgba(0,0,0,.25); }
body.light-mode ::-webkit-scrollbar-track { background: var(--bg3); }
body.light-mode ::-webkit-scrollbar-thumb { background: #adb8c5; }

/* ── City Camouflage theme ─────────────────────────────────────────────────── */
/* Urban pattern: muted greens, grays, tans — like digital/urban camo */
body.city-camo {
  --bg:         #3a3d2e;
  --bg2:        #4a4d38;
  --bg3:        #555847;
  --border:     #6b6e58;
  --accent:     #8faa5a;
  --accent2:    #6d8440;
  --text:       #d4d8c4;
  --text-dim:   #9a9e8a;
  --text-bright:#eef0e0;
  --shadow:     rgba(0,0,0,.6);
  --shadow-lg:  rgba(0,0,0,.75);
  --red:        #c0392b;
  --green:      #7fb069;
  --orange:     #c68642;
  --purple:     #7b6fa0;
  --teal:       #4e8f7e;
}
/* Subtle camo texture on cells via repeating angular blocks */
body.city-camo .tl-cell {
  background-image:
    repeating-linear-gradient(45deg, rgba(0,0,0,.04) 0px, rgba(0,0,0,.04) 8px, transparent 8px, transparent 16px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.03) 0px, rgba(255,255,255,.03) 12px, transparent 12px, transparent 24px);
}
body.city-camo .tl-cell:hover        { background-color: rgba(143,170,90,.12); }
body.city-camo .tl-cell.locked       { background: repeating-linear-gradient(45deg,rgba(192,57,43,.1),rgba(192,57,43,.1) 4px,transparent 4px,transparent 10px); }
body.city-camo .tl-row-current       { background: rgba(143,170,90,.08) !important; }
body.city-camo #header               { background: #2e3022; border-bottom-color: #5a5d48; }
body.city-camo .sidebar              { background: #343628; }
body.city-camo ::-webkit-scrollbar-track { background: var(--bg3); }
body.city-camo ::-webkit-scrollbar-thumb { background: #7a7d6a; }

/* ── Urban Camouflage theme ────────────────────────────────────────────────── */
/* Urban warfare: steel blues, slate grays, muted blue-gray palette */
body.urban-camo {
  --bg:         #1a2233;
  --bg2:        #1e293b;
  --bg3:        #243044;
  --border:     #3a4a5c;
  --accent:     #4a90d9;
  --accent2:    #2e70b8;
  --text:       #c8d8e8;
  --text-dim:   #7a90a8;
  --text-bright:#e8f0f8;
  --shadow:     rgba(0,0,0,.65);
  --shadow-lg:  rgba(0,0,0,.8);
  --red:        #c0392b;
  --green:      #3aaa6e;
  --orange:     #c07830;
  --purple:     #6a5fa0;
  --teal:       #2a7fa8;
}
/* Urban pattern: diagonal blue-toned blocks */
body.urban-camo .tl-cell {
  background-image:
    repeating-linear-gradient(60deg, rgba(74,144,217,.04) 0px, rgba(74,144,217,.04) 6px, transparent 6px, transparent 14px),
    repeating-linear-gradient(-60deg, rgba(30,60,100,.05) 0px, rgba(30,60,100,.05) 10px, transparent 10px, transparent 20px);
}
body.urban-camo .tl-cell:hover        { background-color: rgba(74,144,217,.1); }
body.urban-camo .tl-cell.locked       { background: repeating-linear-gradient(45deg,rgba(192,57,43,.1),rgba(192,57,43,.1) 4px,transparent 4px,transparent 10px); }
body.urban-camo .tl-row-current       { background: rgba(74,144,217,.07) !important; }
body.urban-camo #header               { background: #111927; border-bottom-color: #2a3d54; }
body.urban-camo .sidebar              { background: #161e2e; }
body.urban-camo ::-webkit-scrollbar-track { background: var(--bg3); }
body.urban-camo ::-webkit-scrollbar-thumb { background: #3a5278; }

/* ── Size variants ────────────────────────────────────────────────────────── */
body.size-normal {
  --fs-base:    15px;  --fs-sm: 13px; --fs-xs: 11px; --fs-lg: 17px; --fs-xl: 26px; --fs-2xl: 30px;
  --slot-h-ten:     30px;
  --slot-h-quarter: 22px;
  --slot-h-hour:    52px;
  --slot-h-day:     100px;
  --day-col-min:    150px;
  --time-col-w:     60px;
}
body.size-large {
  --fs-base:    18px;  --fs-sm: 15px; --fs-xs: 13px; --fs-lg: 21px; --fs-xl: 32px; --fs-2xl: 38px;
  --header-h:   68px;
  --slot-h-ten:     40px;
  --slot-h-quarter: 30px;
  --slot-h-hour:    70px;
  --slot-h-day:     140px;
  --day-col-min:    190px;
  --time-col-w:     70px;
}
body.size-huge {
  --fs-base:    22px;  --fs-sm: 18px; --fs-xs: 15px; --fs-lg: 26px; --fs-xl: 42px; --fs-2xl: 50px;
  --header-h:   80px;
  --slot-h-ten:     56px;
  --slot-h-quarter: 42px;
  --slot-h-hour:    96px;
  --slot-h-day:     192px;
  --day-col-min:    250px;
  --time-col-w:     80px;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg);
  transition: background .2s, color .2s;
}
a  { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(ellipse at 30% 30%, var(--bg3) 0%, var(--bg) 70%);
}
.login-container {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 40px; width: 360px; text-align: center;
  box-shadow: 0 8px 32px var(--shadow-lg);
}
.login-logo { margin-bottom: 16px; }
.login-container h1 { font-size: var(--fs-2xl); color: var(--text-bright); font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--text-dim); margin-bottom: 28px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; }
.login-form .form-group { text-align: left; margin-bottom: 16px; }
.login-form label { display: block; margin-bottom: 6px; font-size: var(--fs-sm); color: var(--text-dim); font-weight: 500; }
.login-form input {
  width: 100%; padding: 10px 12px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-bright); outline: none; transition: border-color .15s;
}
.login-form input:focus { border-color: var(--accent); }
.error-msg { color: var(--red); font-size: var(--fs-sm); margin-bottom: 12px; padding: 8px; background: rgba(231,76,60,.1); border-radius: 4px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius); border: none;
  font-weight: 500; transition: background .15s, opacity .15s; white-space: nowrap;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger    { background: rgba(231,76,60,.15); color: var(--red); border: 1px solid rgba(231,76,60,.3); }
.btn-danger:hover { background: rgba(231,76,60,.28); }
.btn-ghost     { background: none; border: none; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-full { width: 100%; justify-content: center; padding: 11px; }
.btn-icon { padding: 5px 7px; border-radius: 4px; font-size: var(--fs-base); }
.btn-sm   { padding: 4px 10px; font-size: var(--fs-sm); }

/* ── App shell ────────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── Header ──────────────────────────────────────────────────────────────── */
#header {
  min-height: var(--header-h); background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 4px 12px; gap: 8px; flex-shrink: 0; z-index: 50;
  flex-wrap: wrap;
}
#header .logo { font-size: var(--fs-xl); font-weight: 700; color: var(--text-bright); letter-spacing: .02em; margin-right: 6px; white-space: nowrap; }
#header .logo span { color: var(--accent); }
.header-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; }
.control-group  { display: flex; align-items: center; gap: 4px; }
.control-label  { font-size: var(--fs-xs); color: var(--text-dim); white-space: nowrap; }
/* Toolbar groups: uniform height, consistent look */
.toolbar-group { display: flex; align-items: center; gap: 4px; }
.toolbar-btn {
  height: 30px; padding: 0 10px; font-size: var(--fs-sm);
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap;
}
.toolbar-btn.btn-icon { padding: 0 8px; }
select.ctrl-select {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text-bright);
  border-radius: var(--radius); padding: 4px 8px; outline: none; font-size: var(--fs-sm);
  height: 30px;
}
input.ctrl-select {
  height: 30px; box-sizing: border-box;
}
select.ctrl-select:focus { border-color: var(--accent); }
.toolbar-sep { width: 1px; height: 24px; background: var(--border); margin: 0 2px; flex-shrink: 0; }
/* Multi-select highlight for event blocks */
.event-block.event-selected {
  outline: 3px solid var(--accent) !important;
  outline-offset: 1px;
  box-shadow: 0 0 0 2px var(--accent), 0 2px 8px var(--shadow);
}
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.clock-area { display: flex; align-items: center; gap: 8px; }
.clock-add-btn { font-size: 18px; font-weight: 700; line-height: 1; padding: 2px 7px; opacity: .65; }
.clock-add-btn:hover { opacity: 1; }
.clock-extra {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 3px 6px; text-align: right;
}
.clock-extra-inner { text-align: right; }
.clock-extra-label { font-size: var(--fs-xs); color: var(--text-dim); line-height: 1.1; }
.clock-extra-time  { font-size: var(--fs-md); font-weight: 700; color: var(--text-bright); font-variant-numeric: tabular-nums; letter-spacing: .04em; line-height: 1.1; }
.clock-extra-tz    { font-size: 10px; color: var(--accent); font-weight: 600; letter-spacing: .05em; }
.clock-extra-remove { background: none; border: none; cursor: pointer; color: var(--text-dim); font-size: 14px; padding: 0 2px; line-height: 1; opacity: .5; }
.clock-extra-remove:hover { opacity: 1; color: var(--red); }
.clock-display { text-align: right; }
.clock-time {
  font-size: var(--fs-2xl); font-weight: 700; color: var(--text-bright);
  font-variant-numeric: tabular-nums; letter-spacing: .06em; line-height: 1;
  text-shadow: 0 0 12px rgba(74,144,217,.35);
}
.clock-date { font-size: var(--fs-sm); color: var(--text-dim); margin-top: 2px; }
.user-badge {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 12px; font-size: var(--fs-sm); color: var(--text); display: flex; align-items: center; gap: 6px;
}
.role-badge { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 2px 6px; border-radius: 10px; }
.role-read      { background: rgba(74,144,217,.15);  color: var(--accent); }
.role-readwrite { background: rgba(46,204,113,.15);  color: var(--green); }
.role-teamlead  { background: rgba(26,188,156,.15);  color: var(--teal); }
.role-oplead    { background: rgba(230,126,34,.15);  color: var(--orange); }
.role-admin     { background: rgba(155,89,182,.15);  color: var(--purple); }

/* ── Main layout ─────────────────────────────────────────────────────────── */
#main { display: flex; flex: 1; overflow: hidden; }
#timeline-container {
  flex: 1; overflow: auto; position: relative; background: var(--bg);
}
#list-view {
  flex: 1; overflow: auto; background: var(--bg);
}
#list-view-table th, #list-view-table td {
  border: 1px solid var(--border);
}
#list-view-table thead th { background: var(--bg2); font-weight: 600; }
#list-view-table tbody tr:hover { background: var(--bg3); }

/* ── Timeline grid ───────────────────────────────────────────────────────── */
#timeline { display: grid; position: relative; min-width: max-content; }

.tl-corner {
  position: sticky; left: 0; top: 0; z-index: 30;
  background: var(--bg2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  width: var(--time-col-w);
}
.tl-day-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg2); border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
  padding: 6px 8px; text-align: center; min-width: var(--day-col-min); user-select: none;
}
.tl-day-header.today { background: rgba(74,144,217,.08); border-bottom-color: var(--accent); }
.tl-day-date { font-size: var(--fs-sm); font-weight: 700; color: var(--text-bright); }
.tl-day-name { font-size: var(--fs-xs); color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.tl-day-header.today .tl-day-date { color: var(--accent); }

.tl-time-label {
  position: sticky; left: 0; z-index: 10;
  background: var(--bg2); border-right: 2px solid var(--border);
  width: var(--time-col-w); font-size: var(--fs-xs); color: var(--text-dim);
  display: flex; align-items: flex-start; padding: 2px 4px; justify-content: space-between;
  font-variant-numeric: tabular-nums; user-select: none;
  cursor: ns-resize; overflow: hidden;
}
.synth-inline {
  color: var(--orange); font-weight: 700; flex-shrink: 0; padding-right: 2px;
}
.tl-corner { cursor: ns-resize; }

.tl-cell {
  border-right: 1px solid var(--border); border-bottom: 1px solid rgba(42,63,86,.5);
  min-width: var(--day-col-min); position: relative; cursor: pointer; transition: background .1s;
}
.tl-cell:hover { background: rgba(74,144,217,.05); }
.tl-cell.half-hour { border-bottom-style: dashed; border-bottom-color: rgba(42,63,86,.3); }
.tl-cell.locked { background: repeating-linear-gradient(45deg,rgba(231,76,60,.04),rgba(231,76,60,.04) 4px,transparent 4px,transparent 10px); cursor: not-allowed; }
.tl-cell.locked:hover { background: repeating-linear-gradient(45deg,rgba(231,76,60,.08),rgba(231,76,60,.08) 4px,transparent 4px,transparent 10px); }
.tl-row-current { background: rgba(74,144,217,.04) !important; }

/* Event blocks */
.event-block {
  position: absolute; left: 2px; right: 2px; border-radius: 4px;
  padding: 2px 5px; font-size: calc(var(--fs-sm) * var(--ev-zoom-scale)); font-weight: 500; color: #fff;
  overflow: hidden; cursor: pointer; z-index: 5;
  box-shadow: 0 1px 4px var(--shadow);
  transition: transform .1s, box-shadow .1s;
  border-left: 3px solid rgba(255,255,255,.3);
  line-height: 1.3;
}
.event-block:hover { transform: translateX(1px); box-shadow: 0 2px 8px var(--shadow); z-index: 6; }
.event-block .ev-title  { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-block .ev-time   { font-size: var(--fs-xs); opacity: .8; white-space: nowrap; }
.event-block .ev-creator { font-size: var(--fs-xs); opacity: .65; }

/* Instant event type — narrow vertical marker with diamond */
.event-block.ev-type-instant {
  left: 4px; right: 4px; border-radius: 2px;
  min-height: 6px;
}
.event-block.ev-type-instant::before {
  content: '◆'; position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: inherit; opacity: .9;
}

/* Intern / Extern participant badges on event blocks */
.ev-participant {
  display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: .04em;
  padding: 0 4px; border-radius: 3px; vertical-align: middle; margin-left: 3px;
  text-transform: uppercase;
}
.ev-participant-intern { background: rgba(26,188,156,.35); color: #1abc9c; }
.ev-participant-extern { background: rgba(231,76,60,.3); color: #e74c3c; }

/* Current time line — uses CSS variables set by JS (--line-color, --line-width, --line-style) */
#current-time-line {
  --line-color: var(--red);
  --line-width: 2px;
  --line-style: solid;
  position: absolute; left: 0; right: 0;
  height: 0; border-top-width: var(--line-width); border-top-style: var(--line-style); border-top-color: var(--line-color);
  z-index: 15; pointer-events: none; background: none;
}
#current-time-line::before {
  content: ''; position: absolute; left: calc(var(--time-col-w) - 5px); top: calc(-1 * (var(--line-width) / 2) - 4px);
  width: 10px; height: 10px; border-radius: 50%; background: var(--line-color);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: 272px; background: var(--bg2); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0;
}
#sidebar.hidden { display: none; }
.sidebar-tabs {
  display: flex; overflow-x: auto; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-tab {
  flex-shrink: 0; padding: 8px 10px; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-dim); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  transition: all .15s; cursor: pointer; white-space: nowrap;
}
.sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.sidebar-content { flex: 1; overflow-y: auto; padding: 12px; }

/* Section headings */
.sidebar-section { margin-bottom: 16px; }
.sidebar-section-title {
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .07em; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between;
}

/* Legend */
.legend-list { display: flex; flex-direction: column; gap: 6px; }
.legend-item { display: flex; align-items: center; gap: 8px; cursor: pointer; border-radius: 4px; padding: 3px 4px; }
.legend-item:hover { background: var(--bg3); }
.legend-item.hidden-type { opacity: .4; }
.legend-swatch { width: 13px; height: 13px; border-radius: 3px; flex-shrink: 0; }
.legend-label      { font-size: var(--fs-sm); color: var(--text); flex: 1; }
.legend-eye        { font-size: var(--fs-xs); color: var(--text-dim); }
.legend-type-icon  { font-size: 13px; line-height: 1; flex-shrink: 0; }

/* Layer list */
.layer-list { display: flex; flex-direction: column; gap: 6px; }
.layer-item {
  display: flex; align-items: center; gap: 8px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 7px 8px; cursor: pointer;
}
.layer-item:hover { border-color: var(--accent); }
.layer-item.active { border-color: var(--accent); background: rgba(74,144,217,.1); }
.layer-swatch { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.layer-name   { font-size: var(--fs-sm); flex: 1; color: var(--text); }
.layer-vis    { font-size: var(--fs-xs); color: var(--text-dim); }

/* Alarm list */
.alarm-list { display: flex; flex-direction: column; gap: 8px; }
.alarm-item {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; display: flex; flex-direction: column; gap: 4px;
}
.alarm-item .alarm-title  { font-size: var(--fs-sm); font-weight: 600; color: var(--text-bright); }
.alarm-item .alarm-meta   { font-size: var(--fs-xs); color: var(--text-dim); }
.alarm-item .alarm-actions { display: flex; justify-content: flex-end; margin-top: 4px; }

/* User list */
.user-list { display: flex; flex-direction: column; gap: 6px; }
.user-item {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 10px; display: flex; align-items: center; gap: 8px;
}
.user-item .user-name { flex: 1; font-size: var(--fs-sm); }

/* Group list */
.group-list { display: flex; flex-direction: column; gap: 6px; }
.group-item {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 10px; display: flex; align-items: center; gap: 8px;
}
.group-item .group-name { flex: 1; font-size: var(--fs-sm); }

/* Member list */
.member-list { display: flex; flex-direction: column; gap: 6px; }
.member-item {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.member-name { flex: 1; font-size: var(--fs-sm); min-width: 80px; }

/* Search input in toolbar */
#searchInput::placeholder { color: var(--text-dim); }
#searchInput { min-width: 100px; }

/* Settings panel */
.setting-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.setting-label { font-size: var(--fs-sm); color: var(--text-dim); min-width: 90px; }
.setting-control { flex: 1; }
.toggle-btn-group { display: flex; gap: 4px; }
.toggle-btn {
  flex: 1; padding: 5px 8px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 4px; font-size: var(--fs-xs); color: var(--text-dim); cursor: pointer; text-align: center;
}
.toggle-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.hour-range { display: flex; align-items: center; gap: 6px; }
.hour-range input[type="number"] {
  width: 52px; padding: 5px 6px; text-align: center;
}

/* Event type admin list */
.etype-list { display: flex; flex-direction: column; gap: 5px; }
.etype-item {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: var(--bg3);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.etype-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.etype-label { flex: 1; font-size: var(--fs-sm); }
.etype-badge { font-size: var(--fs-xs); color: var(--text-dim); }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  width: 500px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 8px 40px var(--shadow-lg);
  transform: translateY(-12px); transition: transform .15s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-header h2 { font-size: var(--fs-lg); color: var(--text-bright); font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--bg3); color: var(--text); }
.modal-body   { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* Form elements */
.form-group   { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: var(--fs-sm); color: var(--text-dim); font-weight: 500; }
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
input[type="text"], input[type="password"], input[type="datetime-local"], input[type="color"],
input[type="number"], select, textarea {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text-bright);
  border-radius: var(--radius); padding: 8px 10px; width: 100%; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="color"] { padding: 3px; height: 36px; cursor: pointer; }
textarea { resize: vertical; min-height: 70px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); flex-shrink: 0; }

/* Attachment list */
.attachment-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.attachment-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
}
.attachment-icon { font-size: 16px; flex-shrink: 0; }
.attachment-name { flex: 1; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-size { font-size: var(--fs-xs); color: var(--text-dim); white-space: nowrap; }

/* ── Notifications ────────────────────────────────────────────────────────── */
#notification-area {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; width: 320px; pointer-events: none;
}
.notification {
  background: var(--bg2); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 12px 14px;
  box-shadow: 0 4px 16px var(--shadow);
  animation: notif-in .2s ease;
  pointer-events: auto;
}
.notification.alarm { border-left-color: var(--red); }
.notification-title { font-size: var(--fs-sm); font-weight: 600; color: var(--text-bright); margin-bottom: 3px; }
.notification-msg   { font-size: var(--fs-sm); color: var(--text); }
.notification-close {
  float: right; background: none; border: none; color: var(--text-dim);
  font-size: 16px; line-height: 1; margin-left: 8px; padding: 0; cursor: pointer;
}
@keyframes notif-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Today marker dot */
.today-marker { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--red); margin-left: 4px; vertical-align: middle; }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a5570; }

/* ── File upload drop zone ────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 14px; text-align: center; cursor: pointer;
  color: var(--text-dim); font-size: var(--fs-sm); transition: border-color .15s, background .15s;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--accent); background: rgba(74,144,217,.06); color: var(--accent); }

/* ── Language flag buttons ────────────────────────────────────────────────── */
.lang-flags { display: flex; gap: 2px; align-items: center; }
.lang-flag-btn {
  background: none; border: 1px solid transparent; border-radius: 4px;
  padding: 1px 4px; font-size: 18px; line-height: 1; cursor: pointer;
  opacity: 0.45; transition: opacity .15s, border-color .15s;
}
.lang-flag-btn:hover { opacity: 0.75; }
.lang-flag-btn.active { opacity: 1; border-color: var(--accent); }

/* ── Layer quick-toggle popover ───────────────────────────────────────────── */
#layerPopover {
  position: fixed; z-index: 80; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; min-width: 210px;
  box-shadow: 0 4px 20px var(--shadow-lg);
}
.layer-pop-header {
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px;
}
.layer-pop-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 4px; cursor: pointer; font-size: var(--fs-sm); color: var(--text);
  transition: background .1s;
}
.layer-pop-item:hover  { background: var(--bg3); }
.layer-pop-item.active { background: rgba(74,144,217,.12); color: var(--text-bright); }
.layer-pop-swatch { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.layer-pop-check { margin-left: auto; color: var(--accent); font-weight: 700; min-width: 14px; text-align: right; }

/* ── Alarm escalation levels ──────────────────────────────────────────────── */
.notification.alarm-level-1 {
  border-left-color: var(--orange);
  box-shadow: 0 4px 20px rgba(230,126,34,.4);
}
.notification.alarm-level-2 {
  border-left-color: var(--red);
  box-shadow: 0 4px 24px rgba(231,76,60,.5);
  animation: alarm-pulse 1.2s ease-in-out infinite;
}
@keyframes alarm-pulse {
  0%,100% { box-shadow: 0 4px 24px rgba(231,76,60,.5); }
  50%      { box-shadow: 0 6px 32px rgba(231,76,60,.85); }
}

/* ── File input in event modal ────────────────────────────────────────────── */
.attach-file-input {
  padding: 6px 8px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); width: 100%;
}
.attach-file-input::-webkit-file-upload-button {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); padding: 3px 10px; cursor: pointer; font-size: var(--fs-sm);
}
.attach-file-input::-webkit-file-upload-button:hover { background: var(--border); }

/* ── Out-of-hours slots ───────────────────────────────────────────────────── */
.tl-cell.out-of-hours {
  background: repeating-linear-gradient(
    135deg,
    rgba(0,0,0,0) 0px, rgba(0,0,0,0) 8px,
    rgba(255,255,255,.025) 8px, rgba(255,255,255,.025) 9px
  );
  opacity: 0.55;
  cursor: default !important;
}
.tl-cell.out-of-hours:hover { background: rgba(255,255,255,.02) !important; }
.tl-time-label.out-of-hours { opacity: 0.45; }
body.light-mode .tl-cell.out-of-hours { background: repeating-linear-gradient(135deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 8px, rgba(0,0,0,.04) 8px, rgba(0,0,0,.04) 9px); }

/* ── Weekend column styling ───────────────────────────────────────────────── */
.tl-day-header.weekend { background: rgba(255,255,255,.03); }
.tl-cell.weekend { background: rgba(255,255,255,.015); }
.tl-day-header.weekend-excluded { background: rgba(128,128,128,.08); opacity: 0.7; }
.tl-cell.weekend-excluded {
  background: repeating-linear-gradient(
    135deg,
    rgba(0,0,0,0) 0px, rgba(0,0,0,0) 6px,
    rgba(128,128,128,.06) 6px, rgba(128,128,128,.06) 7px
  );
  opacity: 0.6;
  cursor: default !important;
}
.tl-cell.weekend-excluded:hover { background: rgba(128,128,128,.04) !important; }
body.light-mode .tl-day-header.weekend { background: rgba(0,0,0,.03); }
body.light-mode .tl-day-header.weekend-excluded { background: rgba(0,0,0,.06); opacity: 0.7; }
body.light-mode .tl-cell.weekend-excluded { background: repeating-linear-gradient(135deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 6px, rgba(0,0,0,.04) 6px, rgba(0,0,0,.04) 7px); }

/* ── Event block icons ────────────────────────────────────────────────────── */
.ev-icon {
  display: inline-block; font-style: normal; font-size: 10px;
  margin-left: 3px; opacity: 0.85; vertical-align: middle; line-height: 1;
}
.icon-pick-btn {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; font-size: 1.1em; padding: 3px 6px; line-height: 1;
  transition: background .15s, border-color .15s;
}
.icon-pick-btn:hover, .icon-pick-btn.selected { background: var(--accent); border-color: var(--accent); }
.ev-type-icon { opacity: 1 !important; margin-left: 0; margin-right: 2px; font-size: 11px; }
.ev-left-icon { opacity: 1 !important; margin-left: 0; margin-right: 2px; font-size: 10px; }

/* ── Event status badges ──────────────────────────────────────────────────── */
.status-badge {
  display: inline-block; font-size: var(--fs-xs); font-weight: 600;
  padding: 2px 7px; border-radius: 10px; text-transform: uppercase;
  letter-spacing: .04em; vertical-align: middle;
}
.status-planned   { background: rgba(74,144,217,.18);  color: var(--accent); }
.status-active    { background: rgba(46,204,113,.18);  color: var(--green); }
.status-completed { background: rgba(122,143,166,.18); color: var(--text-dim); }
.status-submitted { background: rgba(155,89,182,.18);  color: var(--purple); }
.status-verified  { background: rgba(46,204,113,.22);  color: var(--green); border: 1px solid var(--green); }
.status-rejected  { background: rgba(231,76,60,.18);   color: var(--red); border: 1px solid var(--red); }
.status-cancelled { background: rgba(122,143,166,.12); color: var(--text-dim); text-decoration: line-through; }

/* Status dot on event blocks */
.ev-status-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  vertical-align: middle; margin-right: 3px; flex-shrink: 0;
}
.ev-status-active    { background: var(--green); }
.ev-status-completed { background: var(--text-dim); }
.ev-status-submitted { background: var(--purple); }
.ev-status-verified  { background: var(--green); box-shadow: 0 0 0 2px rgba(46,204,113,.35); }
.ev-status-rejected  { background: var(--red); }
.ev-status-cancelled { background: var(--text-dim); opacity: .6; }

/* ── Audit log ────────────────────────────────────────────────────────────── */
.audit-list { display: flex; flex-direction: column; gap: 4px; }
.audit-item {
  padding: 7px 10px; border-radius: var(--radius); background: var(--bg3);
  font-size: var(--fs-xs); border-left: 3px solid var(--border);
  display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: start;
}
.audit-ts   { color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; grid-row: 1; }
.audit-user { color: var(--accent); font-weight: 600; grid-row: 1; }
.audit-action { color: var(--text); grid-column: 1 / -1; }
.audit-action-created  { border-left-color: var(--green); }
.audit-action-updated  { border-left-color: var(--accent); }
.audit-action-deleted  { border-left-color: var(--red); }
.audit-action-verified { border-left-color: var(--green); }
.audit-action-rejected { border-left-color: var(--red); }
.audit-action-status_changed { border-left-color: var(--purple); }

/* ── Exercise badge ───────────────────────────────────────────────────────── */
.exercise-badge {
  background: linear-gradient(90deg, var(--orange), var(--red));
  color: #fff; font-size: var(--fs-xs); font-weight: 700;
  padding: 3px 10px; border-radius: 12px; letter-spacing: .05em;
  text-transform: uppercase; white-space: nowrap;
}

/* ── Drag-to-reschedule ───────────────────────────────────────────────────── */
.event-block.dragging {
  cursor: grabbing !important;
  box-shadow: 0 6px 24px rgba(0,0,0,.6) !important;
}
.tl-cell.drag-target {
  background: rgba(74,144,217,.18) !important;
  outline: 2px dashed var(--accent);
}

/* ── Help modal ───────────────────────────────────────────────────────────── */
.modal-wide { max-width: 860px; width: 95vw; }
.modal-xl   { max-width: 1200px; width: 98vw; }
.help-body  { display: flex; gap: 20px; max-height: 70vh; overflow: hidden; padding: 0; }
.help-toc {
  width: 140px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px; border-right: 1px solid var(--border); overflow-y: auto;
}
.help-toc a {
  font-size: var(--fs-sm); color: var(--text-dim); text-decoration: none; padding: 3px 6px;
  border-radius: 4px; transition: background .1s, color .1s;
}
.help-toc a:hover { background: var(--bg3); color: var(--text); }
.help-content {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  font-size: var(--fs-sm); line-height: 1.6;
}
.help-content h3 { font-size: var(--fs-base); color: var(--accent); margin: 20px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.help-content h3:first-child { margin-top: 0; }
.help-content p  { margin: 6px 0; color: var(--text); }
.help-content ul { margin: 6px 0 6px 16px; }
.help-content li { margin: 3px 0; }
.help-content code { background: var(--bg3); border-radius: 3px; padding: 1px 5px; font-size: var(--fs-xs); font-family: monospace; }
.help-table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: var(--fs-sm); }
.help-table th { text-align: left; color: var(--text-dim); font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--border); font-size: var(--fs-xs); text-transform: uppercase; }
.help-table td { padding: 5px 8px; border-bottom: 1px solid rgba(42,63,86,.3); vertical-align: top; }
.help-table tr:last-child td { border-bottom: none; }

/* ── Responsive / mobile ──────────────────────────────────────────────────── */

/* Tablet (≤ 1024px): collapsible sidebar overlay */
@media (max-width: 1024px) {
  #sidebar {
    position: fixed; right: 0; top: var(--header-h); bottom: 0;
    width: 280px; z-index: 100;
    box-shadow: -4px 0 24px var(--shadow-lg);
    transform: translateX(100%); transition: transform .25s ease;
  }
  #sidebar.visible { transform: translateX(0); }
  #main { flex-direction: column; }
  #timeline-container { flex: 1; min-height: 0; }
  .toolbar { gap: 3px; }
}

/* Phone (≤ 768px): hide header clutter, show mobile nav */
@media (max-width: 768px) {
  :root {
    --header-h: 48px;
    --toolbar-h: 36px;
    --time-col-w: 38px;
    --day-col-min: 80px;
    --fs-base: 12px; --fs-sm: 10px; --fs-xs: 9px;
  }
  #header { padding: 0 8px; gap: 4px; }
  #header .logo { font-size: var(--fs-lg); }
  .header-controls { gap: 3px; }
  .control-label { display: none; }
  .lang-flags { display: none; }
  #btnExportICS { display: none; }
  #btnAddLock { display: none; }
  .clock-display { display: none; }
  .user-badge .role-badge { display: none; }
  .header-right { gap: 5px; }
  #appVersionLink { display: none; }

  .toolbar { padding: 3px 4px; gap: 3px; height: var(--toolbar-h); flex-wrap: nowrap; overflow-x: auto; }
  .toolbar-sep { display: none; }
  .tl-corner, .tl-time-label { font-size: var(--fs-xs); }
  .event-block { font-size: 9px; padding: 1px 3px; }

  /* Bottom navigation bar */
  .mobile-nav { display: flex !important; }
  /* Shrink main to leave room for mobile nav */
  #app { padding-bottom: 56px; }
  #sidebar { bottom: 56px; }

  /* Modals become full-screen on phones */
  .modal-box {
    width: 100vw !important; max-width: 100vw !important;
    max-height: 90vh !important;
    border-radius: 16px 16px 0 0; margin: 0 !important;
    position: fixed; bottom: 56px; left: 0;
  }
  .modal-overlay { align-items: flex-end; padding: 0; }
}

/* Small phone (≤ 480px) */
@media (max-width: 480px) {
  :root {
    --slot-h-ten: 20px;
    --slot-h-quarter: 15px;
    --slot-h-hour: 36px;
  }
  .toolbar select.ctrl-select { max-width: 70px; font-size: 9px; }
}

/* ── Mobile navigation bar ────────────────────────────────────────────────── */
.mobile-nav {
  display: none; /* shown via media query */
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 56px; background: var(--bg2); border-top: 1px solid var(--border);
  z-index: 200; align-items: stretch;
}
.mobile-nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; background: none; border: none;
  color: var(--text-dim); font-size: 18px; cursor: pointer;
  transition: color .15s; padding: 4px 0;
}
.mobile-nav-btn span { font-size: 9px; font-weight: 600; letter-spacing: .02em; }
.mobile-nav-btn.active { color: var(--accent); }
.mobile-nav-btn:hover  { color: var(--text); }
/* Mobile sidebar drawer overlay backdrop */
#sidebarBackdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 99;
}
#sidebarBackdrop.visible { display: block; }

/* ── v3.0 additions ───────────────────────────────────────────────────────── */

/* Status: responded_to */
.status-responded_to { background: rgba(26,188,156,.18); color: var(--teal); }
.ev-status-responded_to { background: var(--teal); }

/* Role: reporter */
.role-reporter { background: rgba(26,188,156,.2); color: var(--teal); }

/* Out-of-hours ghosted area — strong contrast */
.tl-cell.out-of-hours {
  background: repeating-linear-gradient(
    135deg,
    rgba(0,0,0,.18) 0px,
    rgba(0,0,0,.18) 4px,
    rgba(255,255,255,.02) 4px,
    rgba(255,255,255,.02) 10px
  ) !important;
  opacity: .75;
  cursor: default !important;
}
.tl-time-label.out-of-hours { opacity: .38; color: var(--text-dim) !important; }
body.light-mode .tl-cell.out-of-hours {
  background: repeating-linear-gradient(
    135deg,
    rgba(0,0,0,.10) 0px,
    rgba(0,0,0,.10) 4px,
    rgba(0,0,0,.02) 4px,
    rgba(0,0,0,.02) 10px
  ) !important;
  opacity: .80;
}

/* Hide out-of-hours if preference set */
body.hide-out-of-hours .tl-cell.out-of-hours,
body.hide-out-of-hours .tl-time-label.out-of-hours {
  display: none;
}

/* Exercise phase overlay */
.phase-overlay {
  position: absolute; pointer-events: none; z-index: 3; opacity: .22;
  border-left: 3px solid; border-right: 3px solid;
}
.phase-label {
  position: absolute; z-index: 4; font-size: var(--fs-xs); font-weight: 700;
  padding: 1px 6px; border-radius: 0 0 4px 0; pointer-events: none;
  text-transform: uppercase; letter-spacing: .06em; opacity: .9;
}

/* All-day event strip */
.allday-strip {
  position: absolute; pointer-events: auto; z-index: 5; cursor: pointer;
  border-radius: 3px; border-left: 3px solid rgba(255,255,255,.4);
  display: flex; align-items: center; padding: 0 6px;
  font-size: var(--fs-xs); font-weight: 600; color: #fff; opacity: .9;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.allday-row {
  position: sticky; top: 44px; z-index: 10; display: flex;
  background: var(--bg); border-bottom: 1px solid var(--border);
  min-height: 28px;
}
.allday-corner { flex-shrink: 0; border-right: 1px solid var(--border); }
.allday-day    { flex: 1; position: relative; min-height: 28px; }

/* Comment thread */
.comment-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.comment-item {
  background: var(--bg3); border-radius: var(--radius);
  padding: 8px 10px; font-size: var(--fs-sm); position: relative;
}
.comment-item.pending { border-left: 3px solid var(--orange); }
.comment-author { font-weight: 600; color: var(--accent); font-size: var(--fs-xs); }
.comment-ts     { color: var(--text-dim); font-size: var(--fs-xs); margin-left: 8px; }
.comment-text   { margin-top: 4px; color: var(--text); white-space: pre-wrap; }
.comment-pending-badge {
  font-size: var(--fs-xs); color: var(--orange); font-style: italic; margin-top: 2px;
}
.comment-input-row { display: flex; gap: 6px; margin-top: 8px; }
.comment-input-row textarea {
  flex: 1; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 6px 8px; font-size: var(--fs-sm); resize: vertical; min-height: 48px;
  font-family: inherit;
}

/* Password change form */
.password-form { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.password-form input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 6px 8px; font-size: var(--fs-sm);
}

/* Keyboard shortcut table */
.kbd-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.kbd-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); }
.kbd-table td:first-child { color: var(--text-dim); white-space: nowrap; }
kbd {
  display: inline-block; padding: 1px 5px; border: 1px solid var(--border);
  border-radius: 3px; background: var(--bg3); font-size: var(--fs-xs);
  font-family: monospace; color: var(--text-bright);
}

/* Current time line dot color update (handled by the main rule above) */
.tl-synth-label {
  position: absolute; left: 54px; font-size: var(--fs-xs); font-weight: 700;
  background: var(--red); color: #fff; padding: 0 5px; border-radius: 3px;
  pointer-events: none; z-index: 20; transform: translateY(-50%);
  white-space: nowrap;
}

/* Phase management form */
.phase-form-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.phase-swatch { width: 16px; height: 16px; border-radius: 3px; flex-shrink: 0; }

/* Freeze indicator */
.freeze-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(231,76,60,.18); color: var(--red);
  border: 1px solid rgba(231,76,60,.4); border-radius: 12px;
  font-size: var(--fs-xs); padding: 2px 10px; font-weight: 700; white-space: nowrap;
}

/* Size variants: also scale border-radius and padding */
body.size-normal {
  --radius: 8px;
}
body.size-large {
  --radius: 10px;
}
body.size-huge {
  --radius: 12px;
}

/* Icon scaling with display size */
.ev-icon { font-size: calc(.85em * var(--ev-zoom-scale)); }
body.size-normal .ev-icon { font-size: calc(.9em * var(--ev-zoom-scale)); }
body.size-large  .ev-icon { font-size: calc(1em * var(--ev-zoom-scale)); }
body.size-huge   .ev-icon { font-size: calc(1.1em * var(--ev-zoom-scale)); }


/* Print styles for reports */
@media print {
  #sidebar, .toolbar, header, #notification-area { display: none !important; }
  #timeline-container { overflow: visible !important; height: auto !important; }
  .event-block { box-shadow: none !important; }
}

/* Report page */
.report-container { max-width: 900px; margin: 0 auto; padding: 20px; }
.report-header { border-bottom: 2px solid var(--accent); padding-bottom: 12px; margin-bottom: 20px; }
.report-section { margin-bottom: 24px; }
.report-section h3 { font-size: var(--fs-base); color: var(--accent); margin-bottom: 10px; }
.report-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.report-table th { background: var(--bg3); text-align: left; padding: 6px 10px; font-size: var(--fs-xs); text-transform: uppercase; color: var(--text-dim); }
.report-table td { padding: 5px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }

/* User group picker in user modal */
.group-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.group-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 12px; font-size: var(--fs-xs);
  background: var(--bg3); border: 1px solid var(--border); cursor: pointer;
  transition: background .15s, border-color .15s;
}
.group-chip.selected { background: rgba(74,144,217,.25); border-color: var(--accent); color: var(--accent); }

/* ── Inline alarm section in event modal ─────────────────────────────────── */
.inline-alarm-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--bg3);
}
#inlineAlarmOptions { padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }

/* ── Nav jump dropdown ───────────────────────────────────────────────────── */
.nav-jump-menu {
  position: fixed; z-index: 3000;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 20px var(--shadow-lg);
  min-width: 120px; overflow: hidden;
}
.nav-jump-item {
  padding: 8px 16px; cursor: pointer; font-size: var(--fs-sm);
  transition: background .12s;
}
.nav-jump-item:hover { background: var(--bg3); color: var(--accent); }

/* ── Prettier help modal ─────────────────────────────────────────────────── */
.help-modal { max-width: 1100px; width: 96vw; }
.help-modal .modal-header { padding: 0; border-bottom: none; }
.help-modal-header {
  background: linear-gradient(135deg, var(--bg3) 0%, var(--bg2) 100%);
  border-bottom: 2px solid var(--accent) !important;
  padding: 16px 20px !important;
  display: flex; align-items: center; justify-content: space-between;
}
.help-modal-title { display: flex; flex-direction: column; gap: 2px; }
.help-modal-logo { font-size: var(--fs-xl); font-weight: 700; color: var(--text-bright); letter-spacing: -0.5px; }
.help-modal-logo span { color: var(--accent); }
.help-modal-subtitle { font-size: var(--fs-xs); color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

/* Help modal body: taller and two-column for wider screens */
.help-body { max-height: 78vh; }

/* Left-pane navigation for help modal (overrides the basic block above) */
.help-toc {
  width: 180px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px;
  padding: 12px 10px; border-right: 1px solid var(--border); overflow-y: auto;
  border-bottom: none; flex-wrap: nowrap; margin-bottom: 0;
}
.help-toc-link {
  display: block; font-size: var(--fs-sm); text-decoration: none; color: var(--text-dim);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  padding: 5px 10px; transition: all .15s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.help-toc-link:hover { color: var(--text); background: var(--bg3); border-color: var(--border); }
.help-toc-link.active { color: var(--accent); background: rgba(74,144,217,.12); border-color: var(--accent); font-weight: 600; }

/* Right-pane content: two-column layout on wide screens */
.help-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
@media (min-width: 860px) {
  .help-content {
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
  }
  .help-section.help-full-width { grid-column: 1 / -1; }
}

.help-section {
  display: flex; gap: 14px; margin-bottom: 16px;
  padding: 14px 16px; background: var(--bg3); border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  scroll-margin-top: 8px;
  break-inside: avoid;
}
.help-section-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.help-section-body { flex: 1; min-width: 0; }
.help-section-body h3 { font-size: var(--fs-base); color: var(--text-bright); margin-bottom: 8px; }
.help-section-body h4 { font-size: var(--fs-sm); color: var(--text-dim); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .04em; }
.help-section-body p { font-size: var(--fs-sm); color: var(--text); line-height: 1.5; margin-bottom: 6px; }
.help-section-body ol { font-size: var(--fs-sm); color: var(--text); line-height: 1.6; padding-left: 18px; margin: 4px 0 6px; }
.help-list { font-size: var(--fs-sm); color: var(--text); line-height: 1.5; padding-left: 18px; }
.help-list li { margin-bottom: 3px; }
.help-badge { font-size: var(--fs-xs); background: var(--bg2); border: 1px solid var(--border); border-radius: 3px; padding: 0 3px; }
.help-kbd {
  display: inline-block; background: var(--bg2); border: 1px solid var(--border); border-radius: 3px;
  padding: 1px 6px; font-size: var(--fs-xs); font-family: monospace; color: var(--text-bright);
}
.help-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); margin-top: 4px; }
.help-table th { font-size: var(--fs-xs); text-transform: uppercase; color: var(--text-dim); padding: 4px 8px; text-align: left; background: var(--bg2); }
.help-table td { padding: 5px 8px; border-bottom: 1px solid rgba(42,63,86,.4); vertical-align: top; }
.help-table td:first-child { white-space: nowrap; color: var(--accent); min-width: 100px; }
.help-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* ── Templates modal ─────────────────────────────────────────────────────── */
.tmpl-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
}
.tmpl-card-info { flex: 1; min-width: 0; }
.tmpl-card-name { font-weight: 600; font-size: var(--fs-base); color: var(--text-bright); }
.tmpl-card-meta { font-size: var(--fs-xs); color: var(--text-dim); margin-top: 2px; }
.tmpl-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Danger variable for error modal ─────────────────────────────────────── */
:root { --danger: #C0392B; }
body.light-mode { --danger: #c0392b; }

/* ── Synthetic time button active state ──────────────────────────────────── */
#btnSyntheticTime.active {
  background: var(--orange) !important;
  color: #fff !important;
  border-color: var(--orange) !important;
  box-shadow: 0 0 0 2px rgba(230,126,34,.35);
  font-weight: 700;
}
#btnSyntheticTime.active:hover { background: #d35400 !important; }

/* ── Layer-locked cell (scope=layer) ─────────────────────────────────────── */
.tl-cell.locked-layer {
  background: repeating-linear-gradient(
    45deg,
    rgba(74,144,217,.08),
    rgba(74,144,217,.08) 4px,
    transparent 4px,
    transparent 10px
  ) !important;
  cursor: default;
}

/* ── Invited filter buttons ──────────────────────────────────────────────── */
.inv-filter-btns .inv-filter-btn {
  font-size: var(--fs-xs); padding: 2px 8px; border-radius: 20px;
  background: var(--bg3); border: 1px solid var(--border); color: var(--text-dim);
  cursor: pointer; transition: all .15s;
}
.inv-filter-btns .inv-filter-btn.active {
  background: rgba(74,144,217,.2); border-color: var(--accent); color: var(--accent);
}

/* ── Sidebar Resize Handle ──────────────────────────────────────────────── */
.sidebar-resize-handle {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  transition: background .15s;
  z-index: 20;
}
.sidebar-resize-handle:hover {
  background: var(--accent);
  opacity: 0.5;
}

/* ── Event Resize Handle ────────────────────────────────────────────────── */
.ev-resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
  background: transparent;
  border-radius: 0 0 var(--radius) var(--radius);
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ev-resize-handle::after {
  content: '';
  display: block;
  width: 24px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,.35);
  transition: background .15s, width .15s;
}
.ev-resize-handle:hover {
  background: rgba(255,255,255,.15);
}
.ev-resize-handle:hover::after {
  background: rgba(255,255,255,.7);
  width: 36px;
}
.event-block { position: absolute; }

/* ── Filter Popover ──────────────────────────────────────────────────────── */
.filter-popover {
  position: fixed;
  z-index: 100;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  min-width: 220px;
  max-width: 320px;
}
.filter-popover-header {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.filter-section {
  margin-bottom: 8px;
}
.filter-label {
  font-size: var(--fs-xs);
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
}
.filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.filter-cb-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  color: var(--text);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius);
  background: var(--bg3);
}
.btn-active-filter {
  background: rgba(74,144,217,.25) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* ── Context Menu ──────────────────────────────────────────────────────── */
.context-menu {
  position: fixed;
  z-index: 200;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  min-width: 160px;
}
.context-menu-item {
  padding: 6px 16px;
  font-size: var(--fs-sm);
  color: var(--text);
  cursor: pointer;
  transition: background .1s;
}
.context-menu-item:hover {
  background: var(--accent);
  color: #fff;
}
.context-menu-item.ctx-danger { color: var(--danger, #c0392b); }
.context-menu-item.ctx-danger:hover { background: var(--danger, #c0392b); color: #fff; }
.context-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Activity Feed ──────────────────────────────────────────────────────── */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.activity-item {
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  gap: 6px;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
}
.activity-ts { color: var(--text-dim); white-space: nowrap; }
.activity-user { color: var(--accent); font-weight: 600; }
.activity-summary { color: var(--text); }

/* ── Print Styles ──────────────────────────────────────────────────────── */
@media print {
  #header, #sidebar, #sidebarResizeHandle, #sidebarBackdrop,
  #layerPopover, #filterPopover, #contextMenu, #slotContextMenu,
  .mobile-nav, #notification-area, #freezeBadge, #navJumpMenu {
    display: none !important;
  }
  #app {
    display: block !important;
  }
  #timeline-container {
    overflow: visible !important;
    width: 100% !important;
    max-height: none !important;
    height: auto !important;
  }
  body {
    background: #fff !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .event-block {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }
  .tl-cell {
    border-color: #ddd !important;
  }
  @page {
    margin: 1cm;
    size: landscape;
  }
}

/* ── Warning notification ──────────────────────────────────────────────── */
.notification.warning {
  background: rgba(243, 156, 18, .15);
  border-left: 4px solid #F39C12;
}

/* ── Map Modal ──────────────────────────────────────────────────────────── */
#mapContainer {
  height: 400px;
  width: 100%;
  border-radius: 0;
}
#mapContainer .leaflet-container {
  font-family: inherit;
}

/* ── Collaborative Editing Indicator ───────────────────────────────────── */
#editingLockIndicator {
  font-size: var(--fs-xs);
  color: var(--warning, #f39c12);
  padding: 4px 8px;
  border-radius: var(--radius);
  background: rgba(243, 156, 18, 0.1);
  border: 1px solid rgba(243, 156, 18, 0.3);
  display: inline-block;
  vertical-align: middle;
}

/* ── Event History Modal ────────────────────────────────────────────────── */
#eventHistoryList .version-entry {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg2);
}

/* ── Dependency Search Results ──────────────────────────────────────────── */
#depSearchResults div,
#dependencyList div {
  transition: background 0.1s;
}
#depSearchResults div:hover {
  background: var(--bg4, var(--bg3)) !important;
}

/* ── Planned vs Actual Modal ────────────────────────────────────────────── */
#pvaContent table {
  width: 100%;
  border-collapse: collapse;
}
#pvaContent td, #pvaContent th {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
}
