:root {
  color-scheme: light;
  --bg: #f5f7f5;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #687782;
  --line: #d8e0dc;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --ok: #17803d;
  --bad: #b42318;
  --warn: #946200;
  --shadow: 0 10px 24px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 42%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

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

button.secondary {
  background: #e7eeeb;
  color: var(--ink);
}

button.secondary:hover {
  background: #d7e2de;
}

button.danger {
  background: var(--bad);
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
}

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

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

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

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

.login {
  display: grid;
  gap: 18px;
  width: min(420px, calc(100vw - 28px));
  margin: 12vh auto;
  padding: 24px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 12px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  background: #e7eeeb;
  color: var(--ink);
}

.tab.active {
  background: var(--accent);
  color: white;
}

.status-strip {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  margin-bottom: 16px;
}

.direct-strip {
  border-width: 2px;
}

.direct-on {
  border-color: rgba(23, 128, 61, 0.42);
}

.direct-off {
  border-color: rgba(180, 35, 24, 0.3);
}

.direct-actions {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.availability-toggle {
  min-height: 74px;
  border-radius: 8px;
  font-size: 22px;
  padding: 0 24px;
}

.availability-toggle.on {
  background: var(--ok);
}

.availability-toggle.off {
  background: var(--bad);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 8px;
}

.segmented button {
  background: #e7eeeb;
  color: var(--ink);
}

.segmented button.active.ok {
  background: var(--ok);
  color: white;
}

.segmented button.active.bad {
  background: var(--bad);
  color: white;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
}

.crew-readiness {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.crew-location {
  display: grid;
  gap: 10px;
}

.crew-days {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
}

.crew-card {
  display: grid;
  gap: 8px;
  min-height: 170px;
  padding: 14px;
}

.crew-card p {
  font-size: 13px;
}

.crew-green {
  border-color: rgba(23, 128, 61, 0.45);
  background: #f1fbf4;
}

.crew-missing {
  border-color: rgba(180, 35, 24, 0.28);
  background: #fff8f7;
}

.day {
  display: grid;
  gap: 12px;
  min-height: 230px;
  padding: 14px;
}

.date {
  color: var(--muted);
  font-weight: 800;
  text-transform: capitalize;
}

.availability-buttons {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.time-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.hour-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  user-select: none;
  touch-action: none;
}

.hour-slot {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8faf9;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  padding: 0;
}

.hour-slot:hover {
  background: #d7e2de;
}

.hour-slot.selected {
  border-color: var(--ok);
  background: var(--ok);
  color: white;
}

.available {
  border-color: rgba(23, 128, 61, 0.35);
  background: #f1fbf4;
}

.unavailable {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff4f2;
}

.unknown {
  border-color: rgba(148, 98, 0, 0.35);
  background: #fff9eb;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: normal;
}

.status-pill.ok {
  background: #dff6e7;
  color: var(--ok);
}

.status-pill.bad {
  background: #ffe0dc;
  color: var(--bad);
}

.status-pill.warn {
  background: #fff0c2;
  color: var(--warn);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.user-form {
  grid-template-columns: repeat(10, minmax(110px, 1fr)) auto;
}

.message {
  min-height: 24px;
  color: var(--bad);
  font-weight: 700;
}

@media (max-width: 760px) {
  .topbar,
  .toolbar,
  .status-strip {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }

  .segmented,
  .direct-actions,
  .calendar-grid,
  .crew-days,
  .inline-form,
  .user-form {
    grid-template-columns: 1fr;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }
}
