:root {
  --page: #eaf2f6;
  --panel: #ffffff;
  --ink: #07111f;
  --muted: #536b7a;
  --navy: #102f5e;
  --teal: #0f7789;
  --line: #9eb4c3;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  scroll-behavior: smooth;
}

body {
  min-width: 0;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.crew-page {
  width: min(1880px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.crew-header {
  display: grid;
  grid-template-columns: minmax(150px, 240px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: 0 1px 7px rgba(13, 37, 58, 0.12);
}

.brand img {
  display: block;
  width: min(220px, 100%);
  height: auto;
}

.crew-header h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(22px, 2.2vw, 34px);
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.crew-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.crew-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.crew-nav a {
  min-height: 38px;
  padding: 10px 12px;
  border: 1px solid var(--teal);
  border-radius: 4px;
  background: #f8fbfd;
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
}

.crew-nav a:hover,
.crew-nav a:focus-visible {
  background: var(--teal);
  color: #fff;
  outline: none;
}

.fleet-graph-section {
  margin-bottom: 14px;
  min-width: 0;
  border: 1px solid #8fa9ba;
  border-radius: 6px;
  background: linear-gradient(180deg, #f8fbfd 0%, #eef5f8 100%);
  box-shadow: 0 1px 5px rgba(13, 37, 58, 0.12);
  overflow: hidden;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #9eb4c3;
  background: #102f5e;
  color: #fff;
}

.section-title-row h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-title-row p {
  margin: 3px 0 0;
  color: rgba(255, 255, 255, 0.76);
  font-size: 11px;
  font-weight: 800;
}

.section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.section-actions span {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.section-actions button,
.data-modal-foot button,
.data-modal-head button,
.records-toolbar button {
  min-width: 38px;
  min-height: 36px;
  border: 1px solid #b9cad6;
  border-radius: 5px;
  background: #fff;
  color: var(--navy);
  font: 900 18px/1 Arial, Helvetica, sans-serif;
  cursor: pointer;
}

.section-actions button:hover,
.section-actions button:focus-visible,
.data-modal-foot button:hover,
.data-modal-foot button:focus-visible,
.data-modal-head button:hover,
.data-modal-head button:focus-visible,
.records-toolbar button:hover,
.records-toolbar button:focus-visible {
  background: var(--teal);
  color: #fff;
  outline: none;
}

.section-actions button {
  padding: 0 10px;
  font-size: 12px;
  text-transform: uppercase;
}

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

.graph-card {
  min-width: 0;
  border: 1px solid #c4d3de;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(10, 31, 50, 0.12);
  overflow: hidden;
}

.graph-card svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 250px;
  background: #fff;
}

.chart-title {
  fill: #111827;
  font: 900 18px Arial, Helvetica, sans-serif;
}

.grid-line {
  stroke: #d7e1e8;
  stroke-width: 1;
}

.axis-line {
  stroke: #91a5b4;
  stroke-width: 1.2;
}

.axis-label,
.x-label,
.legend-label {
  fill: #1f2937;
  font: 800 10px Arial, Helvetica, sans-serif;
}

.x-label {
  font-size: 9px;
}

.data-label {
  fill: #111827;
  font: 900 11px Arial, Helvetica, sans-serif;
}

.data-label.red-label,
.limit-label {
  fill: #d42027;
}

.limit-label {
  font: 900 11px Arial, Helvetica, sans-serif;
}

.bar-label {
  fill: #111827;
  font-size: 10px;
}

.chart-empty,
.empty-state {
  color: var(--muted);
  fill: var(--muted);
  font: 900 16px Arial, Helvetica, sans-serif;
}

.empty-state {
  padding: 20px;
}

.record-table-wrap {
  padding: 0 8px 10px;
}

.record-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
}

.record-table th,
.record-table td {
  padding: 6px 7px;
  border: 1px solid #bfd0db;
  text-align: right;
  white-space: nowrap;
}

.record-table th {
  background: #d9edf6;
  color: #102f5e;
  font-size: 10px;
  text-transform: uppercase;
}

.record-table th:first-child,
.record-table td:first-child,
.record-table th:nth-child(2),
.record-table td:nth-child(2),
.record-table th:nth-child(3),
.record-table td:nth-child(3) {
  text-align: left;
}

.record-table tr:not(:first-child) {
  cursor: pointer;
}

.record-table tr:not(:first-child):hover {
  background: #eef8fb;
}

.data-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 17, 31, 0.58);
}

.data-modal[hidden] {
  display: none;
}

.data-modal-panel {
  width: min(980px, 100%);
  max-height: min(92dvh, 860px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid #8fa9ba;
  border-radius: 8px;
  background: #f8fbfd;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.records-modal-panel {
  width: min(1480px, calc(100vw - 24px));
  height: min(92dvh, 920px);
  max-height: calc(100dvh - 24px);
  grid-template-rows: auto minmax(0, 1fr);
}

.records-modal-body {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.data-modal-head,
.data-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #b9cad6;
  background: #fff;
}

.data-modal-foot {
  border-top: 1px solid #b9cad6;
  border-bottom: 0;
}

.data-modal-head h2 {
  margin: 0;
  color: var(--navy);
  font-size: 18px;
  font-weight: 900;
}

.data-modal-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.data-modal-body {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  overflow: auto;
}

.data-modal-body label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: #31495a;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.data-modal-body input,
.data-modal-body select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid #b9cad6;
  border-radius: 5px;
  padding: 0 10px;
  background: #fff;
  color: #07111f;
  font: 800 13px Arial, Helvetica, sans-serif;
}

.data-modal-body input[readonly] {
  border-color: #a9c6d3;
  background: #edf7fb;
  color: #102f5e;
}

.password-field {
  grid-column: span 2;
}

.data-modal-foot .danger {
  color: #a8332d;
}

.data-modal-foot .danger:hover,
.data-modal-foot .danger:focus-visible {
  background: #a8332d;
  color: #fff;
}

#crewDataStatus {
  flex: 1 1 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.success-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 17, 31, 0.48);
}

.success-modal[hidden] {
  display: none;
}

.success-modal-panel {
  width: min(380px, 100%);
  display: grid;
  justify-items: center;
  gap: 10px;
  border: 1px solid #8fb9c8;
  border-radius: 8px;
  padding: 22px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
  text-align: center;
}

.success-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #0f7c8d;
  color: #fff;
  font: 900 26px/1 Arial, Helvetica, sans-serif;
}

.success-modal-panel h2 {
  margin: 0;
  color: var(--navy);
  font-size: 20px;
  font-weight: 900;
}

.success-modal-panel p {
  margin: 0;
  color: #31495a;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.success-modal-panel button {
  min-width: 96px;
  min-height: 36px;
  border: 1px solid #0f7c8d;
  border-radius: 5px;
  background: #0f7c8d;
  color: #fff;
  font: 900 12px/1 Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  cursor: pointer;
}

.records-filter-panel {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 9px;
  padding: 12px 14px;
  border-bottom: 1px solid #c5d5df;
  background: #eef7fb;
}

.records-filter-panel label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: #31495a;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.records-filter-panel input,
.records-filter-panel select {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid #b9cad6;
  border-radius: 5px;
  padding: 0 8px;
  background: #fff;
  color: #07111f;
  font: 800 12px Arial, Helvetica, sans-serif;
}

.records-filter-panel .filter-check {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 17px;
}

.records-filter-panel .filter-check input {
  width: 16px;
  height: 16px;
}

.records-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #fff;
}

.records-toolbar span {
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.records-toolbar div {
  display: flex;
  gap: 8px;
}

.records-toolbar button {
  padding: 0 11px;
  font-size: 12px;
  text-transform: uppercase;
}

.modal-record-table {
  min-height: 0;
  padding: 0 14px 14px;
  overflow-x: auto;
  overflow-y: visible;
}

.list-entry-panel {
  border-top: 1px solid #b9cad6;
  background: #f8fbfd;
}

.list-entry-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 0;
}

.list-entry-title h3 {
  margin: 0;
  color: var(--navy);
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
}

.list-entry-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.list-entry-title button,
.list-entry-foot button {
  min-width: 38px;
  min-height: 34px;
  border: 1px solid #b9cad6;
  border-radius: 5px;
  background: #fff;
  color: var(--navy);
  padding: 0 12px;
  font: 900 12px/1 Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  cursor: pointer;
}

.list-entry-title button:hover,
.list-entry-title button:focus-visible,
.list-entry-foot button:hover,
.list-entry-foot button:focus-visible {
  background: var(--teal);
  color: #fff;
  outline: none;
}

.list-common-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  padding: 10px 14px;
}

.bulk-crew-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 14px 10px;
}

.bulk-crew-row {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid #c3d3dd;
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.bulk-crew-row h4 {
  grid-column: 1 / -1;
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid #d6e2e9;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.list-common-grid label,
.bulk-crew-row label {
  min-width: 0;
  display: grid;
  gap: 4px;
  color: #31495a;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.list-common-grid input,
.list-common-grid select,
.bulk-crew-row input {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid #b9cad6;
  border-radius: 5px;
  padding: 0 8px;
  background: #fff;
  color: #07111f;
  font: 800 12px Arial, Helvetica, sans-serif;
}

.list-common-grid input[readonly],
.bulk-crew-row input[readonly] {
  border-color: #a9c6d3;
  background: #edf7fb;
  color: #102f5e;
}

.list-entry-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px 12px;
}

.list-entry-foot .danger {
  color: #a8332d;
}

.list-entry-foot .danger:hover,
.list-entry-foot .danger:focus-visible {
  background: #a8332d;
  color: #fff;
}

#listCrewStatus {
  flex: 1 1 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

@media (max-width: 1280px) {
  .graph-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .records-filter-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .bulk-crew-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .crew-header {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .crew-nav {
    justify-content: flex-start;
  }

  .graph-grid {
    grid-template-columns: 1fr;
  }

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

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

  .records-modal-panel {
    width: min(100%, calc(100vw - 16px));
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
  }

  .list-common-grid,
  .bulk-crew-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .crew-page {
    padding: 8px;
  }

  .crew-header {
    padding: 10px;
  }

  .section-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-actions {
    width: 100%;
    justify-content: space-between;
  }

  .graph-grid {
    padding: 6px;
  }

  .data-modal {
    padding: 6px;
  }

  .records-modal-panel {
    width: calc(100vw - 12px);
    height: calc(100dvh - 12px);
    max-height: calc(100dvh - 12px);
    border-radius: 6px;
  }

  .records-modal-body {
    overflow-y: auto;
  }

  .data-modal-body {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 10px;
  }

  .records-filter-panel {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .records-filter-panel .filter-check {
    padding-top: 0;
  }

  .records-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 10px;
  }

  .records-toolbar div {
    flex-direction: column;
  }

  .list-entry-title,
  .list-entry-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .list-common-grid,
  .bulk-crew-row {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  #listCrewStatus {
    text-align: left;
  }

  .bulk-crew-grid {
    padding: 0 10px 10px;
  }

  .data-modal-foot {
    align-items: stretch;
    flex-wrap: wrap;
  }

  #crewDataStatus {
    flex-basis: 100%;
    order: -1;
    text-align: left;
  }
}
