:root {
  color-scheme: light;
  --ink: #16201f;
  --muted: #62706d;
  --line: #d9e0dd;
  --surface: #ffffff;
  --soft: #eef3f1;
  --brand: #116c63;
  --brand-dark: #084d48;
  --accent: #b13f2d;
  --warn: #a33224;
  --shadow: 0 16px 42px rgba(18, 34, 32, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f7f9f8;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(17, 108, 99, 0.14);
}

label {
  display: grid;
  gap: 7px;
  color: #364440;
  font-size: 0.88rem;
  font-weight: 700;
}

.field-help {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

h1,
h2,
p {
  margin: 0;
}

.shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-panel {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.stack {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 18px 0 16px;
}

.topbar h1,
.login-panel h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.05;
}

.eyebrow {
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 4px 0 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.mode-tab {
  min-height: 44px;
  background: transparent;
  color: var(--muted);
}

.mode-tab.active {
  background: var(--surface);
  color: var(--brand-dark);
  box-shadow: 0 4px 16px rgba(10, 35, 33, 0.08);
}

.entry-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.entry-tab {
  min-height: 40px;
  background: transparent;
  color: var(--muted);
}

.entry-tab.active {
  background: var(--surface);
  color: var(--brand-dark);
  box-shadow: 0 4px 16px rgba(10, 35, 33, 0.08);
}

.app-panel {
  display: none;
}

.app-panel.active {
  display: grid;
  gap: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 18px 0 4px;
}

.section-head p {
  color: var(--muted);
  margin-top: 4px;
}

.form-grid,
.filters {
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide,
.form-actions {
  grid-column: 1 / -1;
}

.check-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 20px;
  height: 20px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary,
.secondary,
.ghost,
.danger {
  min-height: 42px;
  padding: 0 15px;
}

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

.secondary {
  background: #dfe9e6;
  color: var(--brand-dark);
}

.ghost {
  background: transparent;
  color: var(--brand-dark);
  border: 1px solid var(--line);
}

.danger {
  background: #f8dfda;
  color: var(--warn);
}

.filters {
  grid-template-columns: auto minmax(180px, 260px) auto auto;
  align-items: end;
}

.roster-list,
.summary-list {
  display: grid;
  gap: 12px;
}

.month-list {
  display: grid;
  gap: 10px;
}

.day-card {
  display: grid;
  grid-template-columns: minmax(132px, 170px) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.other-duty-day {
  background: #fbfcff;
}

.day-head {
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px;
  border-radius: 8px;
  background: var(--soft);
}

.day-head strong {
  font-size: 1rem;
}

.day-head span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.day-duties {
  display: grid;
  gap: 7px;
}

.day-duty {
  display: grid;
  grid-template-columns: minmax(160px, 1.1fr) minmax(260px, 1.6fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e5ebf2;
  border-radius: 8px;
  background: var(--soft);
}

.day-duty.rest-duty {
  background: #eaf7ef;
}

.day-duty.other-duty {
  background: #fff6e5;
}

.day-duty-title,
.day-duty-toggle,
.day-duty-edit,
.day-duty-delete,
.other-duty-button,
.rest-day-button {
  width: 100%;
  min-height: 34px;
  padding: 7px 8px;
  border-radius: 8px;
  text-align: left;
}

.day-duty-title {
  display: grid;
  gap: 2px;
  background: transparent;
  color: var(--ink);
}

.day-duty-title span {
  font-weight: 900;
}

.day-duty-title small {
  color: var(--muted);
  font-weight: 700;
}

.day-duty-times {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 7px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.day-duty-times > div {
  display: grid;
  gap: 2px;
}

.day-duty-times > div > span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.day-duty-times .time-lines {
  margin-top: 0;
  font-size: 0.74rem;
  font-weight: 800;
}

.day-duty-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 6px;
}

.day-duty-edit,
.day-duty-toggle {
  background: rgba(255, 255, 255, 0.7);
  color: var(--brand-dark);
  font-size: 0.78rem;
  text-align: center;
}

.day-duty-delete {
  background: #f8dfda;
  color: var(--warn);
  font-size: 0.78rem;
  text-align: center;
}

.empty-day-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.other-duty-button,
.rest-day-button {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--line);
  font-weight: 800;
  text-align: center;
}

.rest-day-button {
  color: var(--brand-dark);
}

.roster-card,
.summary-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
}

.roster-card {
  display: grid;
  gap: 14px;
}

.roster-main {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.flight-title {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  font-weight: 900;
  font-size: 1.1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--soft);
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.flown {
  background: #d7efe8;
}

.badge.pending {
  background: #f7e6c8;
  color: #7c4b00;
}

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

.meta {
  padding: 10px;
  background: #f7f9f8;
  border-radius: 8px;
  min-width: 0;
}

.meta span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.meta strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.time-lines {
  display: grid;
  gap: 2px;
  line-height: 1.35;
}

.time-lines span {
  display: block;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.summary-band {
  display: grid;
  gap: 12px;
  padding: 18px 0 30px;
}

.summary-card {
  display: grid;
  grid-template-columns: 1fr repeat(4, minmax(110px, auto));
  gap: 10px;
  align-items: center;
}

.empty,
.error {
  color: var(--warn);
  font-weight: 700;
}

@media (max-width: 820px) {
  .shell {
    padding: 14px;
  }

  .topbar,
  .section-head,
  .roster-main {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .filters,
  .entry-tabs,
  .meta-grid,
  .summary-card {
    grid-template-columns: 1fr;
  }

  .day-card,
  .day-duty,
  .day-duty-times,
  .day-duty-actions,
  .empty-day-actions {
    grid-template-columns: 1fr;
  }

  .form-actions button,
  .filters button {
    width: 100%;
  }
}
