:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --text: #e8eef6;
  --muted: #8b9bb4;
  --accent: #3d9cf0;
  --accent-hover: #2b87d9;
  --danger: #e85d5d;
  --ok: #3cb371;
  --border: #2a3648;
  --input: #121a24;
  --font: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(ellipse at top, #1c2a3d 0%, transparent 55%),
    linear-gradient(160deg, #0b1016 0%, #121a24 50%, #0f1419 100%);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.brand {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 650;
}

.sub {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

label {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 1rem;
}

input:focus {
  outline: 2px solid rgba(61, 156, 240, 0.45);
  border-color: var(--accent);
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 1rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.92rem;
  user-select: none;
}

.remember-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

button {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.8rem 1rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: var(--accent-hover);
}

.msg {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  font-size: 0.92rem;
}

.msg.error {
  background: rgba(232, 93, 93, 0.15);
  color: #ffb4b4;
  border: 1px solid rgba(232, 93, 93, 0.35);
}

.msg.success {
  background: rgba(60, 179, 113, 0.15);
  color: #9ee4bc;
  border: 1px solid rgba(60, 179, 113, 0.35);
}

.footer-link {
  margin-top: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.dash {
  width: min(640px, 100%);
}

.dash-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.dash-actions a,
.dash-actions button {
  width: auto;
  display: inline-block;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.04);
  text-decoration: none;
}

.meta {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.app-body {
  min-height: 100vh;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  position: relative;
  max-width: 1260px;
  margin: 0 auto;
  padding: 1.1rem 1.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 5.75rem;
}

.topbar-welcome {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.topbar-brand-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 0;
}

.topbar-brand-icon img {
  display: block;
  height: 5.5rem;
  width: auto;
  max-width: min(42vw, 9rem);
  object-fit: contain;
  border-radius: 14px;
}

.topbar h1 {
  font-size: 1.45rem;
}

.topbar-sub {
  margin-bottom: 0;
}

.topbar .btn-secondary,
.topbar-logout {
  position: relative;
  z-index: 1;
  width: auto;
  padding: 0.6rem 0.9rem;
  text-decoration: none;
  display: inline-block;
  flex: 0 0 auto;
}

.home {
  max-width: 1260px;
  margin: 0 auto;
  padding: 1.1rem 1.35rem 2.25rem;
}

.schedule-layout {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.calendar-panel,
.side-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 1.1rem;
}

.calendar-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.calendar-nav-prev {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  z-index: 2;
}

.calendar-nav-next {
  grid-column: 5;
  grid-row: 1;
  justify-self: end;
  z-index: 2;
}

.calendar-nav h2,
.cal-month-title {
  margin: 0;
  font-size: 1.2rem;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  grid-column: 3;
  grid-row: 1;
  justify-self: center;
  z-index: 1;
  pointer-events: none;
}

.cal-filter-tick {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  cursor: pointer;
  margin: 0;
  min-width: 0;
  line-height: 1.2;
  color: var(--text);
  font-size: 0.72rem;
  letter-spacing: 0;
  user-select: none;
  justify-self: start;
  z-index: 2;
}

.cal-shift-filters {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  grid-column: 2;
  grid-row: 1;
  justify-self: start;
  margin-left: 0.5rem;
}

.cal-shift-mode {
  width: 7rem;
  min-height: 1.65rem;
  margin: 0;
  padding: 0.15rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--input);
  color: var(--text);
  color-scheme: dark;
  font-family: var(--font);
  font-size: 0.72rem;
  cursor: pointer;
}

.cal-shift-mode:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.calendar-print-btn {
  width: auto;
  min-height: 1.65rem;
  margin: 0;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
}

.cal-coverage-filters {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  grid-column: 4;
  grid-row: 1;
  justify-self: end;
  margin-right: 0.75rem;
  max-width: 100%;
}

.cal-others-label-text {
  white-space: nowrap;
}

.cal-others-tick-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
}

.cal-others-tick-wrap input {
  position: absolute;
  opacity: 0;
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  cursor: pointer;
}

.cal-others-tick-box {
  width: 1.05rem;
  height: 1.05rem;
  border: 1.5px solid rgba(200, 220, 245, 0.55);
  border-radius: 3px;
  background: rgba(8, 14, 22, 0.55);
  box-sizing: border-box;
  display: block;
  position: relative;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.cal-filter-tick:hover .cal-others-tick-box,
.cal-others-tick-wrap input:focus-visible + .cal-others-tick-box {
  border-color: rgba(61, 156, 240, 0.9);
}

.cal-others-tick-wrap input:checked + .cal-others-tick-box {
  background: rgba(61, 156, 240, 0.28);
  border-color: rgba(61, 156, 240, 0.95);
}

.cal-others-tick-wrap input:checked + .cal-others-tick-box::after {
  content: '';
  position: absolute;
  left: 0.28rem;
  top: 0.05rem;
  width: 0.28rem;
  height: 0.55rem;
  border: solid #e8f4ff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.calendar-panel.hide-cal-others .cal-shifts li.cal-shift-other {
  display: none;
}

.calendar-panel .cal-shifts[hidden],
.calendar-panel .cal-shifts li[hidden] {
  display: none !important;
}

.calendar-panel.hide-cal-others .cal-shifts:not(:has(.cal-shift-mine)) {
  display: none;
}

.calendar-panel.hide-cal-others .cal-day.workday:not(:has(.cal-shift-mine)) {
  background: var(--input);
  border-color: var(--border);
}

.calendar-panel.hide-cal-others .cal-day.past.workday:not(:has(.cal-shift-mine)) {
  background: linear-gradient(160deg, rgba(20, 28, 40, 0.55) 0%, rgba(8, 12, 18, 0.72) 100%);
  border-color: rgba(120, 140, 165, 0.28);
}

.calendar-panel.hide-cal-others .cal-day.workday.selected:not(:has(.cal-shift-mine)) {
  background: rgba(61, 156, 240, 0.18);
  border-color: var(--accent);
}

.calendar-panel.hide-cal-others .cal-day:has(.cal-shift-mine) {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.calendar-panel.hide-cal-others .cal-day:has(.cal-shift-mine) .cal-day-num {
  flex-shrink: 0;
}

.calendar-panel.hide-cal-others .cal-day:has(.cal-shift-mine) .cal-shifts {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 0;
}

.calendar-panel.hide-cal-others .cal-shifts li.cal-shift-mine {
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  font-size: 0.82rem;
  line-height: 1.3;
  padding: 0.35rem 0.4rem;
}

.calendar-panel.hide-cal-others .cal-shifts li.cal-shift-mine strong {
  font-size: 0.9rem;
  text-align: left;
}

.calendar-panel.hide-cal-others .cal-shifts li.cal-shift-mine span {
  font-size: calc(0.78rem - 1pt);
  text-align: left;
}

.nav-btn {
  width: auto;
  padding: 0.4rem 0.7rem;
  text-decoration: none;
  display: inline-block;
  font-size: 0.82rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.45rem;
}

.cal-dow {
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  padding: 0.35rem 0;
}

.cal-day {
  min-height: 117px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--input);
  padding: 0.4rem;
}

.cal-day-link {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.cal-day-link:hover {
  text-decoration: none;
  border-color: rgba(61, 156, 240, 0.7);
  transform: translateY(-1px);
}

.cal-day.empty {
  background: transparent;
  border-color: transparent;
  pointer-events: none;
}

.cal-day.other-month {
  opacity: 0.55;
}

.cal-day.other-month .cal-day-num {
  color: var(--muted);
}

.cal-day.other-month:hover {
  opacity: 0.85;
}

.cal-day.past {
  background: linear-gradient(160deg, rgba(20, 28, 40, 0.55) 0%, rgba(8, 12, 18, 0.72) 100%);
  border-color: rgba(120, 140, 165, 0.28);
  opacity: 0.78;
}

.cal-day.past .cal-day-num {
  color: var(--muted);
}

.cal-day.past.workday {
  background: linear-gradient(160deg, rgba(35, 48, 68, 0.5) 0%, rgba(12, 18, 28, 0.75) 100%);
  border-color: rgba(120, 140, 165, 0.35);
}

.cal-day.past.selected {
  opacity: 0.92;
  background: linear-gradient(160deg, rgba(45, 70, 100, 0.45) 0%, rgba(20, 32, 48, 0.7) 100%);
}

.cal-day.today {
  outline: 2px solid #e6b800;
  outline-offset: 1px;
  border-color: #e6b800;
}

.cal-day.selected {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: rgba(61, 156, 240, 0.18);
}

.cal-day.workday {
  background: rgba(61, 156, 240, 0.12);
  border-color: rgba(61, 156, 240, 0.45);
}

.cal-day.workday.selected {
  background: rgba(61, 156, 240, 0.22);
}

.calendar-panel .calendar-grid .cal-day.coverage-gap {
  outline: 2px solid #ff5b67;
  outline-offset: 1px;
}

.cal-day-num {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.cal-shifts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.22rem;
}

.cal-shifts li {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.65rem;
  line-height: 1.25;
  color: #cfe6ff;
  background: var(--officer-box, rgba(61, 156, 240, 0.18));
  border-radius: 4px;
  padding: 0.22rem 0.3rem;
}

.cal-shifts li strong {
  display: block;
  font-weight: 700;
  color: var(--officer-name, #e0892a);
}

.calendar-panel:not(.hide-cal-others) .cal-shifts li.cal-shift-mine strong {
  color: var(--officer-name-dark, #b84f08);
}

.calendar-panel:not(.hide-cal-others) .cal-shifts li.cal-shift-mine {
  color: #ffe2c2;
  background: linear-gradient(160deg,
    var(--officer-box, color-mix(in srgb, var(--officer-name, #e0892a) 28%, transparent)) 0%,
    var(--officer-box-dark, color-mix(in srgb, var(--officer-name-dark, #b84f08) 16%, transparent)) 100%);
}

.calendar-panel:not(.hide-cal-others) .cal-shifts li.cal-shift-mine span {
  color: color-mix(in srgb, var(--officer-box, var(--officer-name, #e0892a)) 14%, white);
}

.cal-shifts span {
  display: block;
  color: #ffffff;
}

.below-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem;
  align-items: stretch;
  font-size: 1.05rem;
  line-height: 1.4;
}

.below-panel > .side-block {
  min-width: 0;
  width: 100%;
}

.below-panel .side-block h3 {
  font-size: 1.2rem;
  margin-bottom: 0.55rem;
  padding-bottom: 0.5rem;
}

.below-panel .assign-block-header h3 {
  margin-bottom: 0;
  padding-bottom: 0;
}

.below-panel .today-title-date {
  font-size: 1.05rem;
  font-weight: 600;
}

.below-panel .assign-collapse-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.95rem;
}

.below-panel .shift-date-label {
  font-size: 1.1rem;
  margin: -0.2rem 0 0.55rem;
}

.below-panel .shift-list {
  gap: 0.65rem;
}

.below-panel .shift-list li {
  padding-bottom: 0.65rem;
  font-size: 1.05rem;
}

.below-panel .shift-list li.shift-mine {
  padding: 0.55rem 0.7rem;
}

.below-panel .shift-row-info {
  gap: 0.25rem;
}

.below-panel .shift-row-info strong {
  color: #e0892a;
  font-weight: 700;
  font-size: 1.1rem;
}

.below-panel .shift-row-info span {
  font-size: 1.02rem;
}

.below-panel .muted {
  font-size: 0.98rem;
}

.below-panel .btn-delete,
.below-panel .btn-propose,
.below-panel .btn-accept,
.below-panel .btn-decline {
  font-size: 0.9rem;
  padding: 0.35rem 0.65rem;
}

.day-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(5, 10, 16, 0.72);
}

.day-modal-overlay[hidden] {
  display: none !important;
}

.day-modal {
  width: min(520px, 100%);
  max-height: min(82vh, 720px);
  overflow: auto;
  margin: 0;
  font-size: 0.86rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.day-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.day-modal-header h3 {
  margin: 0;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
  flex: 1;
  min-width: 0;
}

.day-delete-all-form {
  flex: 0 0 auto;
  margin: 0;
}

.day-delete-all-form .btn-delete {
  margin: 0;
  white-space: nowrap;
}

.day-modal-close {
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .day-modal-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .day-modal-header .day-modal-close {
    grid-column: 2;
    grid-row: 1;
  }
  .day-delete-all-form {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: end;
    margin-bottom: 0.5rem;
  }
}

.day-modal-close {
  width: auto;
  margin: 0;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.day-modal-close:hover {
  background: var(--accent);
}

.day-modal .shift-date-label {
  margin-top: 0.75rem;
}

.day-modal .btn-delete,
.day-modal .btn-propose,
.day-modal .btn-accept,
.day-modal .btn-decline {
  width: auto;
}

.day-modal .shift-row-info strong {
  color: var(--officer-name, #e0892a);
  font-weight: 700;
}

.today-title-date {
  color: inherit;
  font-weight: inherit;
  font-size: inherit;
}

.day-when-label {
  color: inherit;
  font-weight: inherit;
  font-size: inherit;
}

.side-block h3 {
  margin: 0 0 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.assign-hint {
  margin: -0.4rem 0 0.85rem;
  font-size: 0.85rem;
}

.choose-pick-hint {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.choose-meta-hints .assign-hint {
  margin: 0.15rem 0;
}

.choose-next-unlock-hint {
  margin: 0.15rem 0 0.85rem !important;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.assign-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.assign-block-header h3 {
  margin: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.assign-collapse-btn {
  width: auto;
  margin: 0;
  margin-top: 0;
  padding: 0.4rem 0.7rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: normal;
  letter-spacing: normal;
  text-transform: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  display: inline-block;
}

.assign-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
  color: var(--text);
}

.assign-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
}

.assign-drag-handle {
  flex-shrink: 0;
  font-size: 0.75rem;
  white-space: nowrap;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.assign-drag-handle:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.assign-drag-handle[aria-pressed="true"] {
  border-color: var(--accent);
  background: rgba(61, 156, 240, 0.18);
}

.is-assign-dragging,
.is-assign-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

.assign-drag-preview {
  position: fixed;
  z-index: 2000;
  width: max-content;
  max-width: min(260px, calc(100vw - 16px));
  box-sizing: border-box;
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
}

.assign-drag-preview strong,
.assign-drag-preview span {
  display: block;
}

.assign-drag-preview span {
  margin-top: 0.25rem;
  color: var(--muted);
}

.assign-drag-preview.is-bypass {
  border-color: #d9a600;
}

.calendar-panel .cal-day.assign-drop-target {
  box-shadow: inset 0 0 0 3px var(--accent);
}

.calendar-panel .cal-day.assign-drop-target.assign-drop-bypass {
  box-shadow: inset 0 0 0 3px #d9a600;
}

.cal-day-copy-handle {
  display: inline-block;
  min-width: 24px;
  padding: 3px 5px;
  margin: -3px -5px;
}

.calendar-copy-enabled .cal-day:has(.cal-shifts li:not([hidden])) .cal-day-copy-handle,
.calendar-copy-enabled .cal-shifts li[data-shift-id]:not([hidden]) {
  cursor: grab;
}

.cal-day.assign-copy-source,
.cal-shifts li.assign-copy-source {
  opacity: 0.65;
}

.calendar-panel[aria-busy="true"] .cal-day {
  pointer-events: none;
  cursor: progress;
}

.assign-block.is-collapsed {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.assign-block.is-collapsed .assign-block-header {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.assign-block.is-collapsed .assign-block-body {
  display: none;
}

.choose-shift-staff-full .assign-block-header {
  margin-bottom: 0.35rem;
}

.choose-shift-full-hint {
  margin: 0;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.shift-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.shift-list li {
  display: grid;
  gap: 0.15rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.shift-date-label {
  margin: -0.35rem 0 0.75rem;
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
}

.shift-list li.shift-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.shift-row-info {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.shift-delete-form {
  margin: 0;
  flex-shrink: 0;
}

.btn-delete {
  width: auto;
  margin: 0;
  padding: 0.4rem 0.75rem;
  border: 0;
  border-radius: 6px;
  background: #c62828;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-delete:hover {
  background: #a61f1f;
}

.shift-edit-delete-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-edit {
  width: auto;
  margin: 0;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  background: #176dc0;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
}

.btn-edit:hover {
  background: #12579a;
}

.shift-edit-dialog {
  width: min(440px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 1.15rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
}

.shift-edit-dialog::backdrop {
  background: rgba(5, 10, 16, 0.72);
}

#shift-edit-officer {
  overflow-wrap: anywhere;
}

.shift-edit-times {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.shift-edit-times input {
  min-width: 0;
  margin: 0;
  padding: 0.6rem;
  color-scheme: dark;
}

.shift-edit-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.shift-edit-footer button {
  width: auto;
  padding: 0.6rem 0.85rem;
}

.shift-edit-dialog button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 360px) {
  .shift-edit-times {
    grid-template-columns: minmax(0, 1fr);
  }
}

.shift-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.shift-list li.shift-mine {
  background: rgba(61, 156, 240, 0.1);
  border: 1px solid rgba(61, 156, 240, 0.35);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

.shift-form label {
  margin-top: 0.15rem;
}

.shift-form input,
.shift-form select {
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 1rem;
}

.shift-form select {
  appearance: none;
}

.shift-form-wide .form-grid {
  display: grid;
  grid-template-columns: minmax(16rem, 1.75fr) repeat(3, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}

.shift-form-wide .form-grid input,
.shift-form-wide .form-grid select,
.shift-form-wide .form-grid button {
  margin-bottom: 0;
}

.assign-officer-field {
  min-width: 0;
}

.assign-officer-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-bottom: 0.85rem;
}

.assign-officer-filters label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  cursor: pointer;
}

.assign-officer-filters input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
}

.assign-officer-option[hidden],
#assign-officer-empty[hidden] {
  display: none;
}

#assign-officer-empty {
  padding: 0.55rem 0.65rem;
}

.assign-officer-wrap {
  position: relative;
}

.assign-officer-native {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.assign-officer-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 0;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--text);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  gap: 0.5rem;
}

.assign-officer-trigger::after {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  flex: 0 0 auto;
  margin-top: -0.2rem;
}

.assign-officer-trigger-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  min-width: 0;
  line-height: 1.25;
}

.assign-officer-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  min-width: max(100%, 18rem);
  max-height: 16rem;
  overflow: auto;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card, var(--input));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.assign-officer-option {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}

.assign-officer-option:hover,
.assign-officer-option.is-active {
  background: rgba(61, 156, 240, 0.18);
}

.assign-officer-option[aria-selected="true"] {
  background: rgba(61, 156, 240, 0.28);
}

.assign-officer-name {
  min-width: 0;
}

.assign-hours-pair {
  display: inline-flex;
  gap: 0.25rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.assign-hours.is-none,
.assign-hours.is-over {
  color: #e53935;
}

.assign-hours.is-some {
  color: #d4a017;
}

.assign-hours.is-full {
  color: #2e7d32;
}

.shift-form-wide .form-submit button {
  width: 100%;
}

.choose-current-hours-cell {
  grid-column: span 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
}

.choose-current-hours {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  padding-bottom: 0.15rem;
}

.choose-current-hours-title {
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
}

.choose-current-hours-line {
  white-space: nowrap;
}

.choose-hours-reminder {
  color: #e0892a;
  font-weight: 700;
}

.choose-shift-submit.is-invalid,
.choose-shift-submit.is-invalid:hover,
.choose-shift-submit.is-invalid:disabled {
  background: #c62828;
  color: #fff;
  cursor: pointer;
  opacity: 1;
}

.assign-shift-submit.is-invalid,
.assign-shift-submit.is-invalid:hover,
.assign-shift-submit.is-invalid:disabled {
  background: #c62828;
  color: #fff;
  cursor: not-allowed;
  opacity: 1;
}

.assign-shift-submit.is-bypass,
.assign-shift-submit.is-bypass:hover {
  background: #d4a017;
  color: #1a1a1a;
  cursor: pointer;
  opacity: 1;
}

.shift-row-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
  flex-shrink: 0;
}

.btn-propose,
.btn-accept {
  width: auto;
  margin: 0;
  padding: 0.4rem 0.75rem;
  border: 0;
  border-radius: 6px;
  background: #2e7d32;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-propose:hover,
.btn-accept:hover {
  background: #256628;
  text-decoration: none;
  color: #fff;
}

.btn-decline {
  width: auto;
  margin: 0;
  padding: 0.4rem 0.75rem;
  border: 0;
  border-radius: 6px;
  background: #6b7280;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-decline:hover {
  background: #4b5563;
}

.msg.swap-banner {
  background: rgba(46, 125, 50, 0.15);
  border: 1px solid rgba(46, 125, 50, 0.45);
  color: #b7e0b9;
}

.msg.swap-banner a {
  color: #9ee4a3;
  margin-left: 0.5rem;
}

.cal-day.swap-incoming {
  outline: 2px solid #2e7d32;
  outline-offset: 1px;
  box-shadow: inset 0 0 0 1px rgba(46, 125, 50, 0.35);
}

.cal-day.swap-offer-day,
.cal-day.choose-valid-day {
  border-color: rgba(46, 125, 50, 0.75);
  background: rgba(46, 125, 50, 0.12);
}

.choose-view-valid {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  border: 0;
  flex: 0 0 auto;
  margin-left: auto;
}

.choose-view-valid-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}

.choose-view-valid-item input {
  width: auto;
  margin: 0;
  accent-color: #2e7d32;
}

.cal-day.swap-target-day {
  border-color: rgba(230, 184, 0, 0.9);
  background: linear-gradient(160deg, rgba(255, 220, 90, 0.38) 0%, rgba(176, 110, 18, 0.42) 100%);
  box-shadow: inset 0 0 0 1px rgba(230, 184, 0, 0.4);
  color: #1a1408;
}

.cal-day.swap-target-day .cal-day-num {
  color: #1a1408;
  font-weight: 800;
}

.cal-day.swap-target-day .cal-shifts li {
  color: #1a1408;
  font-weight: 700;
  background: rgba(255, 248, 220, 0.55);
}

.cal-day.swap-target-day .cal-shifts li strong {
  color: #1a1408;
  font-weight: 800;
}

.cal-day.swap-target-day .cal-shifts span {
  color: #2a1f0a;
  font-weight: 700;
}

.cal-day.swap-target-day.selected {
  outline-color: #e6b800;
  background: linear-gradient(160deg, rgba(255, 225, 110, 0.48) 0%, rgba(190, 125, 25, 0.5) 100%);
}

/* Selected target shift chip — darker gold than other shifts on that day */
.cal-day.swap-target-day .cal-shifts li.swap-target-shift {
  background: linear-gradient(135deg, #f0c020 0%, #b8730a 100%);
  border: 1px solid rgba(90, 55, 0, 0.45);
  color: #1a1408;
  font-weight: 700;
}

.cal-day.swap-target-day .cal-shifts li.swap-target-shift strong {
  color: #140f05;
  font-weight: 800;
}

.cal-day.swap-target-day .cal-shifts li.swap-target-shift span {
  color: #1f1608;
  font-weight: 700;
}

.swap-requests {
  margin-bottom: 1rem;
}

.swap-requests h4 {
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
  color: #9ee4a3;
}

.swap-request-card {
  border: 1px solid rgba(46, 125, 50, 0.45);
  background: rgba(46, 125, 50, 0.1);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.65rem;
}

.swap-request-card p {
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

.swap-request-actions {
  display: flex;
  gap: 0.5rem;
}

.swap-select-panel {
  border-color: rgba(46, 125, 50, 0.45);
}

.swap-select-panel .swap-offer-hint {
  margin: 0 0 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.swap-select-panel .shift-row-info a {
  color: var(--accent);
  text-decoration: none;
}

.swap-select-panel .shift-row-info a:hover {
  text-decoration: underline;
}

.swap-select-panel .shift-row-info a strong {
  color: inherit;
  font-weight: 700;
}

.swap-event-log {
  margin-top: 0;
}

.swap-log-track {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scroll-snap-type: x proximity;
}

.swap-log-item {
  flex: 0 0 min(320px, 80vw);
  scroll-snap-align: start;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input);
  padding: 0.75rem 0.85rem;
  display: grid;
  gap: 0.35rem;
}

.swap-log-status {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.swap-log-pending .swap-log-status {
  color: #e6b800;
}

.swap-log-accepted .swap-log-status {
  color: #9ee4a3;
}

.swap-log-declined .swap-log-status,
.swap-log-cancelled .swap-log-status {
  color: #ffb4b4;
}

.swap-log-message {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--text);
}

.swap-log-name {
  color: #e0892a;
  font-weight: 700;
}

.swap-log-time {
  font-size: 0.75rem;
  color: var(--muted);
}

.admin-management-panel {
  margin-top: 1rem;
}

.admin-management-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.admin-management-header h3 {
  margin: 0;
}

.admin-delete-all-form {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 0.9rem;
  flex-shrink: 0;
}

.admin-delete-all-btn {
  white-space: nowrap;
}

.admin-save-all-form {
  display: flex;
  justify-content: flex-end;
  margin: -0.4rem 0 0.9rem;
}

.admin-save-all-btn { width: auto; }

.admin-user-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.admin-user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(5, auto);
  gap: 0.65rem 0.9rem;
  align-items: center;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input);
}

.admin-user-row.is-inactive {
  opacity: 0.72;
}

.admin-user-row.has-delete-user {
  grid-template-columns: minmax(0, 1fr) repeat(5, auto);
}

.admin-delete-user-btn {
  white-space: nowrap;
  justify-self: start;
}

.admin-color-delete-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.admin-color-picker {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  padding: 2px;
  margin: 0;
  border: 1px solid var(--muted);
  border-radius: 50%;
  background: var(--panel);
  cursor: pointer;
}

.admin-color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.admin-color-picker::-webkit-color-swatch { border: 0; border-radius: 50%; }
.admin-color-picker::-moz-color-swatch { border: 0; border-radius: 50%; }
.admin-color-picker:disabled { cursor: not-allowed; opacity: 0.5; }

.admin-color-picker[data-edit-user-color="name"] { background: var(--officer-name, #e0892a); }
.admin-color-picker[data-edit-user-color="box"] { background: var(--officer-box, #3d9cf0); }
.admin-color-picker:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#user-color-officer { overflow-wrap: anywhere; }
.user-color-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.user-color-fields label { display: grid; justify-items: start; gap: 0.5rem; }
.user-color-fields .admin-color-picker { width: 44px; height: 44px; }
.user-color-footer { flex-wrap: wrap; }
#user-color-reset { margin-right: auto; }

.admin-delete-user-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-user-row.is-locked {
  opacity: 0.85;
}

.admin-flag.is-readonly,
.admin-locked-note {
  font-size: 0.82rem;
  color: var(--muted);
}

.admin-user-identity {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.admin-user-name {
  color: var(--officer-name, #e0892a);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.admin-user-meta {
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.86rem;
  white-space: nowrap;
  cursor: pointer;
}

.admin-flag input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.admin-save-btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

@media (max-width: 1000px) {
  .admin-user-row,
  .admin-user-row.has-delete-user {
    grid-template-columns: minmax(0, 1fr) repeat(4, auto);
  }

  .admin-user-identity {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1150px) {
  .calendar-nav {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .calendar-nav h2 {
    grid-column: 2;
  }

  .calendar-nav-next {
    grid-column: 3;
  }

  .cal-shift-filters,
  .cal-coverage-filters {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-inline: 0;
  }
}

@media (max-width: 700px) {
  .cal-shift-filters,
  .cal-coverage-filters {
    justify-self: center;
  }

  .cal-coverage-filters {
    grid-row: 3;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.15rem 0.65rem;
  }
}

@media (max-width: 700px) {
  .home {
    padding-inline: 0.75rem;
  }

  .calendar-panel {
    padding: 0.75rem 0.5rem;
    min-width: 0;
  }

  .calendar-nav {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
  }

  .calendar-nav h2 {
    grid-column: 2;
    min-width: 0;
    font-size: 1rem;
    line-height: 1.3;
  }

  .calendar-nav-next {
    grid-column: 3;
  }

  .calendar-nav .nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    white-space: nowrap;
    padding: 0.5rem;
  }

  .assign-drag-handle {
    min-height: 44px;
  }

  .cal-filter-tick {
    min-height: 44px;
    font-size: 0.75rem;
  }

  .cal-shift-mode,
  .calendar-print-btn {
    min-height: 44px;
    font-size: 0.75rem;
  }

  .calendar-scroll {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 4px 4px 0.6rem;
    scrollbar-width: thin;
    scrollbar-color: var(--muted) var(--input);
  }

  .calendar-grid {
    min-width: 1050px;
    gap: 0.4rem;
  }

  .cal-dow {
    font-size: 0.8rem;
    letter-spacing: 0;
  }

  .cal-day {
    min-width: 0;
    min-height: 128px;
    padding: 0.5rem;
  }

  .cal-day-num {
    font-size: 0.95rem;
  }

  .calendar-panel .cal-shifts li {
    font-size: 0.8rem;
    padding: 0.35rem 0.4rem;
    overflow-wrap: anywhere;
  }

  .cal-day-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
  }

  .day-modal-overlay {
    padding: 0.75rem;
  }

  .day-modal {
    max-height: 90dvh;
    padding: 0.85rem;
    font-size: 0.95rem;
  }

  .day-modal-close {
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
  }

  .day-modal .shift-list li.shift-row {
    flex-wrap: wrap;
  }

  .day-modal .shift-row-info {
    overflow-wrap: anywhere;
  }

  .choose-current-hours-cell {
    grid-column: 1 / -1;
    flex-direction: column;
    align-items: flex-start;
  }

  .choose-view-valid {
    align-items: flex-start;
    margin-left: 0;
  }

  .choose-current-hours-line {
    white-space: normal;
  }

  .admin-user-row,
  .admin-user-row.has-delete-user {
    grid-template-columns: 1fr 1fr;
  }

  .admin-flag {
    min-height: 44px;
    margin-bottom: 0;
  }

  .admin-user-identity {
    grid-column: 1 / -1;
  }

  .admin-color-delete-controls {
    grid-column: 1 / -1;
  }

  .admin-color-picker {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .admin-save-btn {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .below-panel {
    grid-template-columns: 1fr;
  }

  .shift-form-wide .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar-inner {
    min-height: 0;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .topbar-brand-icon {
    position: static;
    transform: none;
    order: 3;
    flex: 1 1 100%;
    margin-top: 0.35rem;
  }

  .topbar-brand-icon img {
    height: 4.25rem;
  }

  .topbar-logout {
    margin-left: auto;
  }
}
