:root {
  --canvas: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #1d2321;
  --muted: #65706b;
  --line: #d8ded8;
  --line-strong: #aeb9b2;
  --blue: #2457a6;
  --green: #3f7057;
  --mustard: #b58114;
  --brick: #b04a3a;
  --shadow: 0 14px 36px rgba(29, 35, 33, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.brand,
.auth-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: Archivo, "IBM Plex Sans", sans-serif;
  font-weight: 900;
  letter-spacing: 0;
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: inline-grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-family: Archivo, "IBM Plex Sans", sans-serif;
  font-weight: 900;
}

.mark.large {
  width: 48px;
  height: 48px;
  font-size: 26px;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-nav a,
.nav-button,
.segmented a,
.segmented button {
  height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.app-nav a.active,
.nav-button:hover,
.segmented a.selected,
.segmented button.selected {
  background: var(--surface-2);
  color: var(--ink);
}

.user-menu {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
}

.button.primary {
  background: var(--ink);
  color: #fff;
}

.button.secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.button.compact {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.button.full {
  width: 100%;
}

.button-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.app-main {
  flex: 1;
  width: 100%;
}

.auth-page {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

.auth-shell {
  width: min(100%, 420px);
}

.auth-lockup {
  margin-bottom: 28px;
}

.auth-lockup h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1;
}

.auth-lockup p,
.auth-panel p,
.error-shell p {
  margin: 6px 0 0;
  color: var(--muted);
}

.auth-panel {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel h2,
.error-shell h1 {
  margin: 0;
  font-size: 22px;
}

.auth-panel .button {
  margin-top: 22px;
}

.error-shell {
  margin: 15vh auto 0;
  padding: 24px;
  text-align: center;
}

.error-shell .mark {
  margin: 0 auto 16px;
}

.error-shell .button {
  margin-top: 20px;
}

.schedule-page {
  padding: 24px;
}

.schedule-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.schedule-toolbar h1 {
  margin: 4px 0 0;
  font-family: Archivo, "IBM Plex Sans", sans-serif;
  font-size: 34px;
  line-height: 1.05;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.grid-controls {
  justify-content: flex-start;
  margin-top: 18px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.schedule-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0;
}

.schedule-meta span {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.category-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: -6px 0 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.category-legend button,
.category-legend a {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.category-legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.category-legend a {
  color: var(--ink);
}

.category-legend button.selected {
  border-color: var(--ink);
  color: var(--ink);
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.quick-add {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(160px, 1fr) repeat(4, minmax(120px, 0.8fr)) auto;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filter-bar label,
.quick-add label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filter-bar select,
.filter-bar input,
.quick-add select,
.quick-add input,
.detail-form select,
.detail-form input,
.detail-form textarea {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

.detail-form textarea {
  padding: 10px;
  resize: vertical;
}

.search-field {
  min-width: 220px;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 220px minmax(640px, 1fr);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.grid-left,
.grid-track {
  min-height: 54px;
  border-bottom: 1px solid var(--line);
}

.grid-left {
  position: sticky;
  left: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.grid-head {
  min-height: 42px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.grid-track {
  position: relative;
  min-width: calc(var(--day-w) * var(--days));
  background-image:
    linear-gradient(to right, rgba(36, 87, 166, 0.13) 1px, transparent 1px),
    repeating-linear-gradient(to right, transparent 0, transparent calc(var(--day-w) * 5), rgba(63, 112, 87, 0.08) calc(var(--day-w) * 5), rgba(63, 112, 87, 0.08) calc(var(--day-w) * 7));
  background-size: var(--day-w) 100%, calc(var(--day-w) * 7) 100%;
}

.grid-track.grid-head {
  display: grid;
  grid-template-columns: repeat(var(--days), var(--day-w));
  align-items: center;
  background-color: #fafafa;
}

.month-head {
  min-height: 34px;
}

.day-head {
  min-height: 50px;
}

.subhead {
  min-height: 50px;
}

.month-label {
  min-width: 0;
  overflow: visible;
  padding-left: 6px;
  color: transparent;
  white-space: nowrap;
}

.month-label.visible {
  color: var(--muted);
}

.day-label {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.day-label.weekend {
  background: rgba(63, 112, 87, 0.08);
}

.day-label.today {
  outline: 2px solid rgba(176, 74, 58, 0.55);
  outline-offset: -2px;
}

.day-label strong {
  color: var(--ink);
  font-size: 13px;
}

.day-label em {
  color: var(--muted);
  font-style: normal;
  font-size: 10px;
}

.lane-cell strong {
  font-size: 14px;
}

.lane-cell span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.lane-track {
  height: 60px;
  content-visibility: auto;
  contain-intrinsic-size: 60px;
}

.schedule-bar {
  position: absolute;
  top: 14px;
  height: 32px;
  display: flex;
  min-width: 18px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(36, 87, 166, 0.18);
  touch-action: none;
  cursor: grab;
  transform-origin: left center;
  will-change: transform;
}

.schedule-bar:hover {
  outline: 2px solid rgba(255, 255, 255, 0.78);
  outline-offset: -2px;
}

.schedule-bar:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.schedule-bar.dragging {
  z-index: 4;
  cursor: grabbing;
  box-shadow: 0 12px 28px rgba(29, 35, 33, 0.22);
}

.schedule-bar.selected {
  outline: 2px solid var(--mustard);
  outline-offset: 2px;
}

.schedule-bar.has-conflict {
  box-shadow: 0 0 0 2px rgba(176, 74, 58, 0.95), 0 8px 18px rgba(176, 74, 58, 0.24);
}

.lane-track.drop-target {
  background-color: rgba(36, 87, 166, 0.08);
}

.schedule-bar strong,
.schedule-bar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.schedule-bar .category-chip {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 700;
}

.schedule-bar .conflict-chip {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--brick);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  opacity: 1;
}

.schedule-bar span {
  opacity: 0.84;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
}

.schedule-bar .category-chip {
  opacity: 1;
}

.schedule-bar.status-tentative {
  border: 1px dashed rgba(255, 255, 255, 0.8);
}

.schedule-bar.status-done {
  opacity: 0.74;
}

.schedule-bar.dimmed {
  opacity: 0.28;
}

.empty-track {
  display: flex;
  align-items: center;
  padding-left: 14px;
  color: var(--muted);
  font-size: 13px;
}

.rubber-band {
  position: absolute;
  top: 14px;
  height: 32px;
  border: 2px dashed var(--blue);
  border-radius: 6px;
  background: rgba(36, 87, 166, 0.12);
  pointer-events: none;
}

.selection-marquee {
  position: fixed;
  z-index: 40;
  border: 1px solid var(--blue);
  background: rgba(36, 87, 166, 0.12);
  pointer-events: none;
}

.quick-create-panel {
  position: fixed;
  z-index: 45;
  width: min(360px, calc(100vw - 32px));
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.quick-create-panel form {
  display: grid;
  gap: 10px;
}

.quick-create-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quick-create-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.quick-create-panel input,
.quick-create-panel select {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

.quick-create-dates {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.review-page {
  padding: 24px;
}

.review-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.category-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.admin-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.admin-create {
  display: grid;
  grid-template-columns: minmax(120px, 0.6fr) minmax(220px, 1.3fr) minmax(160px, 1fr) repeat(2, minmax(100px, 0.7fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.review-row,
.review-empty,
.category-row,
.admin-row {
  display: grid;
  grid-template-columns: minmax(220px, 360px) 1fr;
  gap: 18px;
  align-items: start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.category-row {
  grid-template-columns: minmax(240px, 1.4fr) minmax(140px, 0.8fr) 90px 110px 130px auto;
  align-items: end;
}

.job-row {
  grid-template-columns: minmax(120px, 0.7fr) minmax(220px, 1.3fr) minmax(140px, 0.9fr) repeat(2, minmax(80px, 0.55fr)) repeat(2, minmax(120px, 0.8fr)) repeat(3, minmax(110px, 0.75fr)) auto;
}

.resource-row {
  grid-template-columns: minmax(220px, 1.3fr) minmax(90px, 0.5fr) minmax(120px, 0.7fr) minmax(90px, 0.5fr) minmax(100px, 0.6fr) repeat(2, minmax(110px, 0.65fr)) auto;
}

.category-row label,
.category-row-name label,
.admin-create label,
.admin-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.category-row input,
.category-row select,
.admin-create input,
.admin-create select,
.admin-row input,
.admin-row select {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

.category-row-name {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: end;
}

.category-swatch {
  width: 26px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid rgba(29, 35, 33, 0.12);
}

.check-row {
  min-height: 34px;
  display: flex !important;
  grid-template-columns: auto;
  align-items: center;
  gap: 8px !important;
}

.check-row input {
  width: auto;
  min-height: 0;
}

.category-count {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.admin-row .eyebrow {
  margin-bottom: 8px;
  white-space: nowrap;
}

.review-row h2,
.review-empty h2 {
  margin: 4px 0;
  font-size: 16px;
}

.review-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.review-row pre {
  max-height: 180px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 6px;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.detail-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: min(420px, calc(100vw - 36px));
}

.detail-card,
.detail-status {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.detail-card {
  padding: 16px;
}

.detail-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-card h2 {
  margin: 4px 0 0;
  font-size: 18px;
}

.category-dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: 1px;
}

.detail-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-notes,
.detail-updated,
.detail-actions {
  grid-column: 1 / -1;
}

.detail-updated {
  margin: 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.detail-status {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.toast-tray {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast-error {
  background: var(--brick);
}

.toast-exit {
  opacity: 0;
  transform: translateY(6px);
}

@media (max-width: 760px) {
  .app-header {
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .user-menu {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
  }

  .schedule-page {
    padding: 16px;
  }

  .schedule-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-controls {
    justify-content: flex-start;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .quick-add {
    grid-template-columns: 1fr;
  }

  .schedule-grid {
    grid-template-columns: 160px minmax(640px, 1fr);
  }

  .review-page {
    padding: 16px;
  }

  .review-row,
  .review-empty,
  .category-row,
  .admin-create,
  .admin-row,
  .job-row,
  .resource-row {
    grid-template-columns: 1fr;
  }
}
