:root {
  color-scheme: dark;
  --bg: #101d30;
  --panel: #192a40;
  --line: #31455d;
  --ink: #f5f7fb;
  --muted: #acbed2;
  --accent: #ffc477;
  --blue: #83bcf0;
  --green: #93d8c0;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 16px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
a {
  color: inherit;
  text-decoration: none;
}
button,
.button {
  border: 0;
  background: var(--accent);
  color: #172338;
  padding: 12px 18px;
  border-radius: 7px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  display: inline-block;
}
button:hover,
.button:hover {
  filter: brightness(1.09);
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 10px 15px;
  border-radius: 7px;
  font-size: 0.9rem;
}
.danger {
  background: transparent;
  color: #ffb5b5;
  border: 1px solid #80535e;
  padding: 9px 12px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 34px;
  border-bottom: 1px solid var(--line);
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  font-size: 1.55rem;
  font-weight: 700;
}
.mark {
  font-size: 2.25rem;
  color: var(--bg);
  background: var(--accent);
  border-radius: 11px 11px 11px 0;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  line-height: 1;
}
.brand small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 3px;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.badge {
  display: inline-block;
  color: var(--green);
  font-size: 0.78rem;
  padding: 7px 10px;
  border-radius: 20px;
  background: #213c46;
}
.badge.warning {
  color: #ffce89;
  background: #57432c;
}
.clock {
  border-left: 1px solid var(--line);
  padding-left: 24px;
  text-align: right;
}
.clock strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.clock span {
  font-size: 0.78rem;
  color: var(--muted);
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 1.9rem;
  letter-spacing: -0.6px;
  margin-bottom: 8px;
}
h2 {
  font-size: 1.17rem;
  margin: 0;
}
h3 {
  font-size: 1.02rem;
  margin-bottom: 7px;
}
p {
  line-height: 1.55;
}
.muted,
small {
  color: var(--muted);
}
.tv #board {
  padding: 25px 34px;
}
.overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 22px;
}
.overview p {
  color: var(--muted);
  margin-bottom: 0;
}
.metrics {
  display: flex;
  gap: 30px;
}
.metrics > div {
  display: flex;
  flex-direction: column;
  padding-left: 24px;
  border-left: 1px solid var(--line);
}
.metrics strong {
  font-size: 2.1rem;
  font-weight: 600;
}
.metrics span {
  font-size: 0.85rem;
  color: var(--muted);
}
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(230px, 0.7fr);
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}
.section-head > span {
  color: var(--muted);
  font-size: 0.8rem;
}
.map-panel {
  grid-column: 1;
  grid-row: 1 / span 2;
}
.map-caption {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  margin-top: 12px;
}
.floorplan {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: repeat(12, minmax(0, 1fr));
  gap: 6px;
  height: 430px;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 34px,
      #23354b 35px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 34px,
      #23354b 35px
    );
  padding: 12px;
  border: 1px solid #496078;
  border-radius: 8px;
}
.room {
  border: 2px solid #6485a6;
  background: #263f58;
  padding: 12px;
  min-width: 0;
  overflow: auto;
  border-radius: 3px;
}
.room-1 {
  background: #2c464b;
  border-color: #648d88;
}
.room-2 {
  background: #464239;
  border-color: #958467;
}
.room-3 {
  background: #393d56;
  border-color: #7d81a1;
}
.room-title {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.9rem;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}
.room-title b {
  color: var(--accent);
}
.room-people {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.person {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #142437;
  padding: 5px 9px 5px 5px;
  font-size: 0.82rem;
  border-radius: 20px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.person i {
  font-style: normal;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--green);
  color: #14332c;
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  font-weight: bold;
}
.room .muted {
  font-size: 0.8rem;
}
.agenda-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
}
.event {
  display: flex;
  gap: 15px;
  border-top: 1px solid var(--line);
  padding: 18px 0;
}
.event:first-child {
  border-top: 0;
  padding-top: 0;
}
.event:last-child {
  padding-bottom: 0;
}
.event-date {
  flex: 0 0 45px;
  text-align: center;
  border-right: 1px solid var(--line);
  padding-right: 12px;
}
.event-date b {
  font-size: 1.65rem;
  font-weight: 600;
}
.event-date span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}
.event-detail {
  min-width: 0;
  flex: 1;
}
.event h3 {
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}
.event-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 7px;
  gap: 8px;
}
.stage {
  color: var(--accent);
}
.event p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 3px;
}
.event .responsible {
  color: var(--ink);
}
.event-notes {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.status {
  display: inline-block;
  background: #284239;
  color: #afdec1;
  padding: 4px 7px;
  font-size: 0.7rem;
  border-radius: 3px;
  margin-top: 8px;
}
.pagination {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 14px 0 0;
}
.calendar-panel {
  grid-column: 3;
}
.calendar-head h3 {
  text-transform: capitalize;
  margin-bottom: 4px;
}
.calendar-head > span {
  font-size: 0.75rem;
  color: var(--muted);
}
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-top: 16px;
  text-align: center;
  font-size: 0.8rem;
}
.calendar > b {
  color: var(--muted);
  font-size: 0.7rem;
  padding: 5px;
}
.day {
  min-height: 32px;
  padding: 7px 2px;
  position: relative;
}
.day.today {
  background: var(--accent);
  color: #172338;
  border-radius: 5px;
  font-weight: 700;
}
.day i {
  width: 4px;
  height: 4px;
  background: var(--blue);
  border-radius: 50%;
  position: absolute;
  bottom: 1px;
  left: calc(50% - 2px);
}
.legend {
  font-size: 0.68rem;
  color: var(--muted);
  margin: 14px 0 0;
}
.legend i {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--blue);
  border-radius: 50%;
  margin-right: 5px;
}
.cameras-panel {
  grid-column: 3;
}
.camera-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.camera-grid figure {
  margin: 0;
  min-width: 0;
}
.camera-feed {
  background: #0c1625;
  aspect-ratio: 16/10;
  display: grid;
  place-items: center;
  border-radius: 5px;
  overflow: hidden;
}
.camera-feed img,
.camera-feed video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.camera-feed [hidden] {
  display: none;
}
.camera-error {
  font-size: 0.7rem;
  padding: 10px;
  color: var(--muted);
}
figcaption {
  font-size: 0.72rem;
  padding: 7px 0;
  color: var(--muted);
}
.camera-empty {
  grid-column: 1/-1;
  display: flex;
  gap: 13px;
  align-items: center;
}
.camera-empty > span {
  font-size: 2rem;
  color: var(--muted);
}
.camera-empty p {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty h3 {
  color: var(--ink);
}
.empty p {
  max-width: 340px;
  margin: 10px auto;
  font-size: 0.85rem;
}
.empty-icon {
  font-size: 3rem;
  color: var(--accent);
}
.map-panel .empty {
  min-height: 430px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.welcome {
  max-width: 680px;
  margin: 9vh auto;
  text-align: center;
  padding: 30px;
}
.welcome p {
  color: var(--muted);
}
.welcome .button {
  margin: 10px 0 25px;
}
footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin: 0 34px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}
#notice {
  color: var(--accent);
  max-width: 75%;
  overflow-wrap: anywhere;
}
.admin #admin-root {
  max-width: 1240px;
  margin: 32px auto;
  padding: 0 24px;
}
.admin-intro {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 25px;
}
.admin-intro p {
  color: var(--muted);
  margin-bottom: 0;
}
.actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  overflow: auto;
}
.tabs button {
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}
.tabs button.active {
  color: var(--ink);
  background: #29405a;
}
.admin-content {
  min-height: 400px;
}
.section-head .muted {
  margin: 10px 0 0;
  max-width: 730px;
  font-size: 0.9rem;
}
.section-head > button {
  flex-shrink: 0;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}
th,
td {
  padding: 16px 12px;
  border-bottom: 1px solid var(--line);
}
td {
  font-size: 0.9rem;
}
td small {
  display: block;
  margin-top: 7px;
}
.row-actions {
  white-space: nowrap;
}
.row-actions button {
  margin-right: 6px;
}
.presence-present {
  color: var(--green);
}
.presence-external {
  color: var(--accent);
}
.login {
  max-width: 440px;
  margin: 65px auto;
  padding: 35px;
}
.login h1 {
  font-size: 1.7rem;
  margin-top: 28px;
}
.login p {
  color: var(--muted);
}
.login label {
  margin-bottom: 20px;
}
.login button {
  width: 100%;
}
.login small {
  display: block;
  margin-top: 20px;
  line-height: 1.6;
}
label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
input,
select,
textarea {
  width: 100%;
  padding: 12px;
  background: #101e30;
  color: var(--ink);
  font: inherit;
  border: 1px solid #4d627a;
  border-radius: 6px;
}
textarea {
  min-height: 100px;
  resize: vertical;
}
.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.wide {
  grid-column: 1/-1;
}
.check {
  flex-direction: row;
  align-items: center;
}
.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}
dialog {
  width: min(720px, 94vw);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid #58708b;
  border-radius: 14px;
  padding: 28px;
}
dialog::backdrop {
  background: #030b17c9;
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}
.form-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}
#form-error,
#login-error {
  color: #ffb7b7;
  margin-top: 16px;
}
#message:empty {
  display: none;
}
#message {
  position: fixed;
  z-index: 5;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 15px 24px;
  border-radius: 8px;
  box-shadow: 0 5px 30px #0008;
  background: #345646;
  color: #edfff2;
}
#message.error {
  background: #713b42;
  color: #fff;
}
.map-preview {
  max-width: 700px;
  margin-top: 20px;
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 30px 0;
}
.admin-content > h2 {
  margin: 15px 0;
}
.admin-content > #revoke {
  margin-top: 24px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}
@media (min-width: 1800px) {
  :root {
    font-size: 20px;
  }
  .floorplan {
    height: 520px;
  }
  .map-panel .empty {
    min-height: 520px;
  }
  .topbar {
    padding: 28px 40px;
  }
  .tv #board {
    padding: 30px 40px;
  }
  .panel {
    padding: 25px;
  }
}
@media (max-width: 1150px) {
  .dashboard-grid {
    grid-template-columns: 1.1fr 1fr;
  }
  .map-panel {
    grid-column: 1;
    grid-row: 1;
  }
  .agenda-panel {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
  .calendar-panel {
    grid-column: 1;
  }
  .cameras-panel {
    grid-column: 1 / -1;
  }
  .metrics {
    gap: 14px;
  }
  .metrics > div {
    padding-left: 14px;
  }
  .overview h1 {
    font-size: 1.5rem;
  }
  .top-actions .badge {
    display: none;
  }
}
@media (max-width: 720px) {
  .topbar {
    padding: 16px;
    align-items: flex-start;
  }
  .brand {
    font-size: 1.15rem;
  }
  .mark {
    width: 38px;
    height: 38px;
    font-size: 1.9rem;
  }
  .top-actions {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .clock {
    display: none;
  }
  .top-actions .ghost {
    font-size: 0.7rem;
    padding: 8px;
  }
  .tv #board {
    padding: 20px 14px;
  }
  .overview {
    align-items: flex-start;
    flex-direction: column;
    gap: 20px;
  }
  .metrics {
    width: 100%;
    justify-content: space-between;
  }
  .metrics > div:first-child {
    padding-left: 0;
    border: 0;
  }
  .metrics span {
    font-size: 0.7rem;
  }
  .dashboard-grid {
    display: flex;
    flex-direction: column;
  }
  .panel {
    width: 100%;
    padding: 18px;
  }
  .floorplan {
    height: 380px;
    padding: 6px;
    gap: 4px;
  }
  .room {
    padding: 7px;
  }
  .room-title {
    font-size: 0.75rem;
  }
  .person {
    font-size: 0.65rem;
  }
  .room-people {
    gap: 5px;
  }
  .map-panel .empty {
    min-height: 230px;
  }
  .calendar-panel {
    order: 3;
  }
  .cameras-panel {
    order: 4;
  }
  footer {
    margin: 0 16px;
    flex-direction: column;
    gap: 10px;
  }
  #notice {
    max-width: 100%;
  }
  .admin #admin-root {
    padding: 0 14px;
    margin: 22px auto;
  }
  .admin-intro {
    align-items: flex-start;
    flex-direction: column;
  }
  .admin-intro h1 {
    font-size: 1.6rem;
  }
  .section-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .fields {
    grid-template-columns: 1fr;
  }
  .fields .wide {
    grid-column: auto;
  }
  .login {
    margin: 30px auto;
    padding: 25px;
  }
  .tabs button {
    padding: 10px 12px;
  }
  dialog {
    padding: 20px;
  }
  .row-actions button {
    display: block;
    margin: 6px 0;
  }
  .admin .topbar > .ghost {
    font-size: 0.7rem;
  }
  .camera-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}

/* Visual floorplan editor: pointer and keyboard alternatives. */
.map-workspace {
  margin: 24px 0 32px;
  max-width: 850px;
}
.map-toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
}
.map-toolbar button {
  flex-shrink: 0;
}
.map-toolbar p {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}
.map-toolbar [aria-pressed="true"] {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}
.map-canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 1.5;
  border: 1px solid #5b7591;
  background-color: #112337;
  background-image:
    linear-gradient(to right, #3b5067 1px, transparent 1px),
    linear-gradient(to bottom, #3b5067 1px, transparent 1px);
  background-size: calc(100% / 12) calc(100% / 12);
  touch-action: none;
  user-select: none;
  overflow: hidden;
  cursor: crosshair;
}
.map-sector {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 5px;
  border: 3px solid #8cafcb;
  border-radius: 2px;
  background: #28435b;
  color: var(--ink);
  padding: 12px;
  cursor: grab;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  font-size: 1rem;
}
.map-sector > span:first-child {
  overflow-wrap: anywhere;
  max-width: 100%;
}
.map-sector small {
  font-weight: 400;
}
.map-sector.moving {
  opacity: 0.3;
}
.map-sector:focus-visible {
  outline-offset: -5px;
}
.map-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #172338;
  cursor: nwse-resize;
  touch-action: none;
}
.map-ghost {
  position: absolute;
  pointer-events: none;
  border: 2px dashed var(--accent);
  background: #ffc47733;
  color: var(--accent);
  padding: 8px;
  font-weight: 700;
  z-index: 2;
}
.map-ghost[hidden] {
  display: none;
}
.map-canvas.drawing .map-sector {
  cursor: crosshair;
}
.map-workspace > p {
  font-size: 0.8rem;
  margin: 12px 0 0;
}
@media (max-width: 720px) {
  .map-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .map-canvas {
    aspect-ratio: 1;
  }
  .map-sector {
    padding: 5px;
    font-size: 0.75rem;
    border-width: 2px;
  }
  .map-sector small {
    font-size: 0.65rem;
  }
}

/* Event-color tracks with phase markers, readable without color alone. */
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.calendar-head span {
  color: var(--muted);
  font-size: 0.72rem;
}
.month-nav {
  display: flex;
  gap: 4px;
}
.month-nav button {
  padding: 2px 9px;
  font-size: 1.25rem;
}
.calendar-phases {
  gap: 3px;
  margin-top: 12px;
}
.calendar-phases .day {
  padding: 3px 2px;
  min-height: 50px;
  border: 1px solid #30445a;
  border-radius: 3px;
}
.calendar-phases .day.today {
  background: transparent;
  color: var(--ink);
  border-color: var(--accent);
}
.day-number {
  display: inline-grid;
  place-items: center;
  height: 20px;
  min-width: 20px;
  font-size: 0.73rem;
}
.today .day-number {
  background: var(--accent);
  border-radius: 50%;
  color: #172338;
  font-weight: 700;
}
.day-tracks {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 3px;
}
.event-track {
  height: 10px;
  background: var(--event-color);
  display: flex;
  gap: 1px;
  border-radius: 2px;
  overflow: hidden;
}
.phase-mark {
  height: 10px;
  min-width: 10px;
  display: inline-grid;
  place-items: center;
  color: #172338;
  font-weight: 800;
  font-size: 8px;
  line-height: 1;
  border-right: 1px solid #172338;
}
.track-spacer {
  height: 10px;
}
.phase-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.phase-legend > span {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.65rem;
  color: var(--muted);
}
.phase-legend b {
  display: inline-grid;
  place-items: center;
  color: #172338;
  font-size: 0.6rem;
  width: 15px;
  height: 13px;
  border-radius: 2px;
}
.event-color-legend {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}
.event-color-legend > div {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.68rem;
  min-width: 0;
}
.event-color-legend > div > span:first-child {
  width: 22px;
  height: 5px;
  border-radius: 2px;
  flex-shrink: 0;
}
.event-color-legend > div > span:last-child {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.event-color-legend p {
  font-size: 0.75rem;
  margin: 0;
}
.calendar-note {
  font-size: 0.6rem;
  color: var(--muted);
  margin: 10px 0 0;
}
.calendar-panel .pagination {
  font-size: 0.6rem;
  margin: 8px 0 0;
}

@media (min-width: 1151px) {
  .map-panel {
    grid-row: 1;
  }
  .cameras-panel {
    grid-column: 1;
    grid-row: 2;
  }
  .calendar-panel {
    grid-column: 3;
    grid-row: 1 / span 2;
  }
  .map-panel .floorplan {
    height: 340px;
  }
  .map-panel .empty {
    min-height: 340px;
  }
  .camera-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Selectable days, contextual details and full-viewport calendar. */
.calendar-phases .day[role="button"] {
  cursor: pointer;
}
.calendar-phases .day[role="button"]:hover {
  background: #2a4059;
}
.calendar-phases .day.selected-day {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  background: #25455f;
}
.calendar-phases .day:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}
.agenda-panel.day-selected {
  max-height: calc(100vh - 360px);
  overflow: auto;
}
.day-details > .section-head {
  align-items: flex-start;
  flex-wrap: wrap;
}
.day-details > .section-head button {
  font-size: 0.72rem;
  padding: 8px 10px;
}
.day-details > p {
  font-size: 0.8rem;
}
.day-event {
  border-left: 5px solid var(--event-color);
  padding: 4px 0 16px 16px;
  margin: 0 0 22px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.day-event h3 {
  font-size: 1.05rem;
}
.day-phase-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.day-phase-labels span {
  border-left: 5px solid;
  padding: 3px 8px;
  background: #0d2033;
  font-size: 0.76rem;
}
.day-event dl {
  display: grid;
  grid-template-columns: minmax(95px, 0.8fr) minmax(0, 1.5fr);
  gap: 7px 12px;
  font-size: 0.77rem;
  margin-bottom: 10px;
}
.day-event dt {
  color: var(--muted);
}
.day-event dd {
  margin: 0;
}
.day-notes {
  white-space: pre-wrap;
  font-size: 0.8rem;
  margin: 14px 0 0;
  color: var(--ink);
}
#calendar-tooltip {
  position: fixed;
  z-index: 10000;
  width: max-content;
  max-width: min(360px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow: hidden;
  background: #f1f5fa;
  color: #13283e;
  border: 1px solid #b3c6db;
  border-radius: 8px;
  padding: 13px 16px;
  box-shadow: 0 8px 30px #0007;
  pointer-events: none;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
#calendar-tooltip[hidden] {
  display: none;
}
#calendar-tooltip ul {
  padding-left: 18px;
  margin: 9px 0;
}
#calendar-tooltip li {
  margin: 5px 0;
}
#calendar-tooltip p {
  margin: 8px 0;
}
#calendar-tooltip small {
  color: #425a74;
  font-size: 12px;
}
#calendar-expanded {
  position: fixed;
  inset: 0;
  margin: 0;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  border: 0;
  border-radius: 0;
  padding: 24px;
  background: var(--bg);
  overflow: hidden;
}
#calendar-expanded[open] {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
body:has(#calendar-expanded[open]) {
  overflow: hidden;
}
.expanded-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-shrink: 0;
}
.expanded-header h2 {
  font-size: 1.4rem;
}
.expanded-header p {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 6px 0 0;
}
.expanded-header > button {
  flex-shrink: 0;
}
.expanded-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr);
  gap: 20px;
  flex: 1;
  min-height: 0;
}
.expanded-grid > .panel {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
#expanded-month .calendar-phases .day {
  min-height: 70px;
}
#expanded-month .day-number {
  font-size: 0.9rem;
  height: 25px;
}
#expanded-month .event-track,
#expanded-month .track-spacer {
  height: 12px;
}
#expanded-month .phase-mark {
  height: 12px;
  min-width: 14px;
  font-size: 9px;
}
#expanded-month .phase-legend {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
#expanded-month .event-color-legend {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.expanded-grid .day-details .empty {
  padding: 30px 10px;
}
@media (max-width: 720px) {
  .agenda-panel.day-selected {
    max-height: none;
  }
  .expanded-header {
    align-items: flex-start;
  }
  .expanded-header h2 {
    font-size: 1.1rem;
  }
  .expanded-header p {
    font-size: 0.7rem;
  }
  .expanded-header > button {
    font-size: 0.7rem;
    padding: 8px;
  }
  #calendar-expanded {
    padding: 12px;
    overflow: auto;
  }
  #calendar-expanded[open] {
    gap: 12px;
  }
  .expanded-grid {
    display: flex;
    flex-direction: column;
    flex: none;
    min-height: auto;
    gap: 12px;
  }
  .expanded-grid > .panel {
    overflow: visible;
    flex-shrink: 0;
  }
  #expanded-month .phase-legend {
    grid-template-columns: 1fr 1fr;
  }
  #expanded-month .event-color-legend {
    grid-template-columns: 1fr;
  }
  #expanded-month .calendar-phases .day {
    min-height: 50px;
  }
  #expanded-month .phase-mark {
    min-width: 10px;
    font-size: 8px;
  }
  .day-event dl {
    grid-template-columns: 90px minmax(0, 1fr);
  }
}
