:root {
  --xr-black: #111111;
  --xr-white: #ffffff;
  --xr-green: #21a73f;
  --xr-lime: #c9ff19;
  --xr-yellow: #ffc827;
  --xr-blue: #70c9ec;
  --xr-pink: #ed9bc4;
  --xr-red: #c94700;
  --surface: #f4f5f2;
  --panel: #ffffff;
  --border: #d8dcd4;
  --muted: #647066;
  --sidebar-width: 248px;
  --header-height: 68px;
  --bs-primary: #126b2c;
  --bs-primary-rgb: 18, 107, 44;
}

[data-bs-theme="dark"] {
  --surface: #141713;
  --panel: #1d211c;
  --border: #3d443b;
  --muted: #adb7ab;
  --bs-body-bg: #141713;
  --bs-body-color: #f3f5f1;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { min-width: 320px; overflow-x: hidden; background: var(--surface); }
a { text-underline-offset: .18em; }
:focus-visible { outline: 3px solid var(--xr-yellow) !important; outline-offset: 3px; box-shadow: 0 0 0 6px var(--xr-black); }
#main-content:focus { outline: 0 !important; box-shadow: none; }
.skip-link { position: fixed; top: .75rem; left: .75rem; z-index: 1100; transform: translateY(-180%); padding: .65rem .8rem; background: var(--xr-black); color: var(--xr-white); font-weight: 700; }
.skip-link:focus { transform: translateY(0); }

.app-header { height: var(--header-height); background: var(--panel); position: sticky; top: 0; z-index: 1030; }
.brand { color: inherit; font-size: 1.2rem; font-weight: 900; text-decoration: none; text-transform: uppercase; letter-spacing: 0; }
.brand span { display: block; color: var(--muted); font-size: .65rem; font-weight: 700; }
.user-name { font-weight: 700; }
.icon-button { width: 42px; height: 42px; align-items: center; justify-content: center; }
.app-shell { min-height: calc(100vh - var(--header-height)); }
.app-sidebar { width: var(--sidebar-width) !important; background: var(--panel); border-right: 1px solid var(--border); }
.app-sidebar .nav-link { display: flex; align-items: center; gap: .7rem; min-height: 44px; padding: .65rem .75rem; color: inherit; border-radius: 4px; font-weight: 650; }
.app-sidebar .nav-link i { width: 1.2rem; color: var(--muted); font-size: 1.05rem; }
.app-sidebar .nav-link:hover { background: color-mix(in srgb, var(--xr-green) 10%, transparent); }
.app-sidebar .nav-link.active { background: var(--xr-lime); color: var(--xr-black); }
.app-sidebar .nav-link.active i { color: var(--xr-black); }
.app-main { min-width: 0; }

h1, h2, h3 { letter-spacing: 0; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.25rem); font-weight: 850; }
h2 { font-size: 1.15rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 800; }
.eyebrow { margin: 0 0 .35rem; color: #157c35; font-size: .78rem; font-weight: 850; text-transform: uppercase; }
[data-bs-theme="dark"] .eyebrow { color: #8fe2a2; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.75rem; }
.page-heading p:last-child { margin: .55rem 0 0; color: var(--muted); }

.btn { border-radius: 4px; font-weight: 700; }
.btn-primary { --bs-btn-bg: #126b2c; --bs-btn-border-color: #126b2c; --bs-btn-hover-bg: #0d5422; --bs-btn-hover-border-color: #0d5422; }
.form-control, .form-select, .input-group-text { min-height: 44px; border-color: var(--border); border-radius: 4px; }
.form-label { font-weight: 700; }
.panel { padding: 1.25rem; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.panel-heading h2, .panel-heading p { margin: 0; }
.panel-heading a { font-size: .9rem; font-weight: 700; }
.empty-state { margin: 0; padding: 1rem 0; color: var(--muted); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.metric { min-height: 116px; padding: 1rem; background: var(--panel); border: 1px solid var(--border); border-top: 6px solid var(--xr-pink); border-radius: 6px; }
.metric.accent-yellow { border-top-color: var(--xr-yellow); }
.metric.accent-blue { border-top-color: var(--xr-blue); }
.metric.accent-green { border-top-color: var(--xr-green); }
.metric span { display: block; color: var(--muted); font-size: .85rem; font-weight: 700; }
.metric strong { display: block; margin-top: .35rem; font-size: 2.25rem; line-height: 1; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.list-group-item { background: transparent; color: inherit; border-color: var(--border); }
.list-group-item small, .task-body small { display: block; margin-top: .35rem; color: var(--muted); }
.strike-date { margin: 0; color: var(--xr-red); font-size: 2.25rem; font-weight: 900; }
.timeline { display: grid; gap: .25rem; }
.timeline a { display: grid; grid-template-columns: 105px 1fr; gap: .75rem; padding: .65rem 0; color: inherit; text-decoration: none; border-bottom: 1px solid var(--border); }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline span { font-weight: 700; }
.activity-list > div { display: grid; grid-template-columns: 12px 1fr; gap: .7rem; }
.activity-dot { width: 10px; height: 10px; margin-top: .4rem; background: var(--xr-green); border-radius: 50%; }
.activity-list p { margin: 0 0 .9rem; }
.activity-list small { display: block; color: var(--muted); }

.item-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.item-card { min-width: 0; padding: 1.25rem; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; }
.item-card h2 { margin: 1rem 0 .5rem; }
.item-icon { display: grid; place-items: center; width: 42px; height: 42px; background: var(--xr-blue); color: var(--xr-black); border-radius: 4px; font-size: 1.2rem; }
.metadata { display: flex; flex-wrap: wrap; gap: .5rem 1rem; color: var(--muted); font-size: .85rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-full { grid-column: 1 / -1; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.source-link { display: inline-block; margin-top: .4rem; font-size: .82rem; font-weight: 700; }
.meeting-task { grid-template-columns: minmax(0, 1fr) auto; padding: .8rem 0; }
.meeting-task + .meeting-task { border-top: 1px solid var(--border); }

.note-textarea { min-height: 220px; resize: vertical; }
.note-file-field { padding-top: 1rem; border-top: 1px solid var(--border); }
.note-list { display: grid; }
.note-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 20px; gap: 1rem; align-items: center; min-height: 64px; padding: .75rem 0; color: inherit; border-top: 1px solid var(--border); text-decoration: none; }
.note-row:first-child { border-top: 0; }
.note-row:hover strong { text-decoration: underline; text-underline-offset: .18em; }
.note-row small { display: block; margin-top: .25rem; color: var(--muted); }
.note-content { max-height: 65vh; margin: 1rem 0 0; padding: 1rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.note-suggestions > div { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: .75rem; align-items: start; padding: .8rem 0; border-top: 1px solid var(--border); }
.note-suggestions > div:first-child { border-top: 0; }
.note-suggestions small { display: block; margin-top: .25rem; color: var(--muted); }
.suggestion-list { display: grid; gap: 1rem; }
.suggestion-editor { padding: 1.25rem; background: var(--panel); border: 1px solid var(--border); border-left: 6px solid var(--xr-green); border-radius: 6px; }
.suggestion-editor.rejected { border-left-color: var(--border); opacity: .72; }
.suggestion-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: center; }
.suggestion-editor blockquote { margin: 1rem 0; padding: .75rem 1rem; color: var(--muted); background: var(--surface); border-left: 4px solid var(--xr-blue); }
.review-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; padding: 1rem 0; }
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-list article { padding: .8rem 0; border-top: 1px solid var(--border); }
.comment-list article:first-child { border-top: 0; }
.comment-list time, .history-list time { display: block; color: var(--muted); font-size: .82rem; }
.comment-list p { margin: .4rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.history-list { display: grid; gap: .5rem; margin: 0; padding-left: 1.25rem; }
.notification-list form { margin: 0; }
.notification-list button { display: grid; grid-template-columns: 20px minmax(0, 1fr) 18px; gap: .75rem; align-items: center; width: 100%; padding: .8rem 0; background: transparent; color: inherit; border: 0; border-top: 1px solid var(--border); text-align: left; }
.notification-list form:first-child button { border-top: 0; }
.notification-list small { display: block; color: var(--muted); }
.selection-list { display: grid; gap: .35rem; max-height: 240px; padding: .75rem; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.member-list > div { display: flex; gap: .65rem; align-items: start; padding: .55rem 0; border-top: 1px solid var(--border); }
.member-list > div:first-child { border-top: 0; }
.member-list small { display: block; color: var(--muted); }

.task-list .task-row + .task-row { border-top: 1px solid var(--border); }
.task-row { display: grid; grid-template-columns: 5px minmax(0, 1fr) minmax(150px, auto); gap: 1rem; align-items: center; padding: 1rem 1.25rem; }
.task-row h2, .task-row p { margin: 0 0 .4rem; }
.task-priority { align-self: stretch; min-height: 58px; background: var(--xr-blue); border-radius: 3px; }
.priority-high { background: var(--xr-yellow); }
.priority-urgent { background: var(--xr-red); }
.priority-low { background: var(--border); }
.status { display: inline-block; width: fit-content; padding: .3rem .45rem; border-radius: 3px; background: var(--border); color: var(--xr-black); font-size: .72rem; font-weight: 850; text-transform: uppercase; }
.status-open { background: var(--xr-blue); }
.status-in_progress { background: var(--xr-yellow); }
.status-blocked { background: var(--xr-pink); }
.status-completed { background: #91d69c; }

.strike-list { display: grid; gap: .65rem; }
.strike-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) minmax(160px, 240px) 24px; gap: 1rem; align-items: center; padding: 1rem; background: var(--panel); color: inherit; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; }
.strike-row:hover { border-color: var(--xr-green); }
.strike-row time { display: grid; place-items: center; padding: .45rem; background: var(--xr-yellow); color: var(--xr-black); border-radius: 4px; }
.strike-row time strong { font-size: 1.55rem; line-height: 1; }
.strike-row h2, .strike-row p { margin: 0; }
.strike-row p { color: var(--muted); }
.progress { height: 9px; background: var(--border); }
.progress-bar { background: var(--xr-green); }
.strike-progress > span { display: block; margin-bottom: .35rem; text-align: right; font-size: .8rem; font-weight: 700; }
.checklist { display: grid; gap: .5rem; }
.checklist form { margin: 0; }
.checklist-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; }
.checklist-item { display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 48px; padding: .7rem .8rem; background: var(--surface); color: inherit; border: 1px solid var(--border); border-radius: 4px; text-align: left; }
.checklist-item:hover { border-color: var(--xr-green); }
.checklist-item.done span:not(.visually-hidden) { color: var(--muted); text-decoration: line-through; }
.checklist-item.done i { color: #157c35; }
.search-form { max-width: 720px; }
.document-preview { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 4; white-space: pre-wrap; }
.calendar-title { margin-bottom: 1rem; text-transform: capitalize; }
.calendar-scroll { overflow-x: auto; }
.calendar-grid { min-width: 760px; background: var(--panel); border: 1px solid var(--border); }
.calendar-weekdays, .calendar-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays > div { padding: .6rem; background: var(--surface); border-right: 1px solid var(--border); font-weight: 800; text-align: center; }
.calendar-day { min-height: 125px; padding: .55rem; border-top: 1px solid var(--border); border-right: 1px solid var(--border); }
.calendar-day.outside { background: var(--surface); }
.calendar-events { display: grid; gap: .3rem; margin-top: .4rem; }
.calendar-event { padding: .3rem .4rem; overflow: hidden; background: var(--xr-blue); color: var(--xr-black); border-radius: 3px; font-size: .75rem; font-weight: 700; text-decoration: none; text-overflow: ellipsis; }
.calendar-event time { margin-right: .3rem; }
.calendar-event.event-strike { background: var(--xr-yellow); }
.calendar-event.event-task { background: var(--xr-pink); }
.search-results { display: grid; }
.search-results > a { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: .25rem 1rem; padding: .8rem 0; color: inherit; border-top: 1px solid var(--border); text-decoration: none; }
.search-results > a:first-child { border-top: 0; }
.search-results small { grid-column: 2; color: var(--muted); }
.error-page { max-width: 640px; margin: 12vh auto; text-align: center; }

.event-heading { padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.event-nav { position: sticky; z-index: 5; top: var(--header-height); display: flex; gap: .25rem; margin: 0 -1rem 2rem; padding: .75rem 1rem; overflow-x: auto; background: color-mix(in srgb, var(--surface) 94%, transparent); border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.event-nav a { flex: 0 0 auto; padding: .45rem .65rem; color: inherit; border-radius: 3px; font-size: .86rem; font-weight: 800; text-decoration: none; }
.event-nav a:hover, .event-nav a:focus-visible { background: var(--xr-yellow); color: var(--xr-black); }
.section-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.section-heading h2, .panel-heading h2 { margin-bottom: 0; }
.event-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.event-metrics .metric { color: inherit; text-decoration: none; }
.event-metrics .metric:hover { border-color: var(--xr-black); }
.event-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 1.5rem 0 0; }
.event-facts div { padding-top: .75rem; border-top: 1px solid var(--border); }
.event-facts dt { color: var(--muted); font-size: .8rem; }
.event-facts dd { margin: .25rem 0 0; font-weight: 800; }
.production-list { border-top: 1px solid var(--border); }
.production-row { border-bottom: 1px solid var(--border); }
.production-row summary { display: grid; grid-template-columns: 76px minmax(150px, .7fr) minmax(180px, 1fr) 20px; gap: 1rem; align-items: center; min-height: 58px; padding: .75rem .25rem; cursor: pointer; list-style: none; }
.production-row summary::-webkit-details-marker, .production-card summary::-webkit-details-marker, .role-item summary::-webkit-details-marker, .add-panel > summary::-webkit-details-marker { display: none; }
.production-row summary time { color: var(--xr-red); font-size: 1.05rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.production-row summary span { color: var(--muted); }
details[open] > summary > .bi-chevron-down { transform: rotate(180deg); }
.production-editor { padding: 1rem; background: var(--surface); border-top: 1px solid var(--border); }
.form-grid.compact { gap: .75rem; }
.editor-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .75rem; }
.production-add { display: grid; grid-template-columns: 110px minmax(180px, 1fr) minmax(180px, 1fr) 42px; gap: .75rem; align-items: end; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.production-add .btn { width: 42px; height: 42px; padding: 0; }
.production-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.production-card { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; }
.production-card > summary { display: grid; grid-template-columns: minmax(0, 1fr) 20px; gap: .75rem; align-items: center; min-height: 110px; padding: 1rem; cursor: pointer; list-style: none; }
.production-card h3 { margin: .65rem 0 .25rem; font-size: 1.05rem; }
.production-card p { margin: 0; color: var(--muted); }
.production-card-body { padding: 0 1rem 1rem; }
.add-panel { background: var(--surface); border: 1px dashed var(--border); border-radius: 5px; }
.add-panel > summary { padding: .85rem 1rem; cursor: pointer; font-weight: 800; list-style: none; }
.add-panel > form { padding: 0 1rem 1rem; }
.role-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.role-item { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; }
.role-item.unfilled { border-left: 6px solid var(--xr-yellow); }
.role-item > summary { display: grid; grid-template-columns: 38px minmax(0, 1fr) 18px; gap: .65rem; align-items: center; padding: .85rem; cursor: pointer; list-style: none; }
.role-item small { display: block; margin-top: .2rem; color: var(--muted); }
.role-state { display: grid; place-items: center; width: 36px; height: 36px; background: var(--xr-blue); color: var(--xr-black); border-radius: 4px; }
.role-item.unfilled .role-state { background: var(--xr-yellow); }
.role-add { grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) minmax(150px, 1fr) auto 42px; }
.production-table { min-width: 720px; margin-bottom: 0; color: inherit; }
.table-responsive { max-width: 100%; overflow-x: auto; }
.production-table td { vertical-align: middle; }
.production-table td small { display: block; color: var(--muted); }
.task-links { display: grid; }
.task-links > a { display: grid; grid-template-columns: 5px minmax(0, 1fr) auto; gap: .8rem; align-items: center; min-height: 62px; padding: .65rem 0; color: inherit; border-top: 1px solid var(--border); text-decoration: none; }
.task-links > a:first-child { border-top: 0; }
.task-links .task-priority { min-height: 42px; }
.task-links small { display: block; margin-top: .2rem; color: var(--muted); }
.status-confirmed, .status-performed, .status-ready, .status-returned { background: #91d69c; }
.status-invited, .status-waiting, .status-arranged, .status-needed { background: var(--xr-yellow); }
.status-cancelled, .status-not_needed { background: var(--border); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(140deg, var(--xr-yellow), var(--xr-blue)); }
.login-panel { width: min(100%, 430px); padding: clamp(1.5rem, 5vw, 2.5rem); background: var(--panel); border: 4px solid var(--xr-black); border-radius: 6px; box-shadow: 10px 10px 0 var(--xr-black); }
.login-panel h1 { margin-top: 2rem; font-size: 2.4rem; }
.login-brand { font-size: 1.45rem; font-weight: 900; text-transform: uppercase; }
.login-brand span { display: block; color: var(--muted); font-size: .75rem; }

@media (min-width: 992px) {
  .app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
  .app-sidebar { position: sticky; top: var(--header-height); height: calc(100vh - var(--header-height)); }
}
@media (max-width: 991.98px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .role-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .btn { width: 100%; }
  .dashboard-grid, .item-grid, .form-grid { grid-template-columns: 1fr; }
  .grid-full { grid-column: auto; }
  .task-row { grid-template-columns: 5px minmax(0, 1fr); }
  .task-row form { grid-column: 2; }
  .strike-row { grid-template-columns: 58px minmax(0, 1fr) 20px; }
  .strike-progress { grid-column: 2; }
  .note-row { grid-template-columns: minmax(0, 1fr) 20px; }
  .note-row .status { grid-column: 1; grid-row: 2; }
  .note-row > i { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .review-actions { align-items: stretch; flex-direction: column-reverse; }
  .review-actions .btn { width: 100%; }
  .event-metrics, .production-cards, .role-grid { grid-template-columns: 1fr; }
  .production-row summary { grid-template-columns: 62px minmax(0, 1fr) 20px; gap: .65rem; }
  .production-row summary span { grid-column: 2; }
  .production-row summary > .bi { grid-column: 3; grid-row: 1 / span 2; }
  .production-add, .role-add { grid-template-columns: 1fr; }
  .production-add .btn, .role-add .btn { width: 100%; }
  .event-facts { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .metric-grid { grid-template-columns: 1fr; }
  .brand { font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
