:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #eef4f0;
  --surface-3: #e4ece7;
  --text: #17211d;
  --muted: #61706a;
  --line: #dce5df;
  --brand: #256f50;
  --brand-2: #5ca979;
  --brand-dark: #174736;
  --danger: #b42318;
  --warning: #ad6800;
  --info: #1d5f8f;
  --ok: #257a52;
  --shadow: 0 18px 48px rgba(31, 51, 42, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

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

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

button {
  border: 0;
}

img {
  max-width: 100%;
}

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

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
}

.login-card {
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-logo {
  display: block;
  width: 260px;
  max-width: 76%;
  margin: 0 auto 26px;
}

.login-card h1 {
  margin: 0 0 6px;
  text-align: center;
  font-size: 1.45rem;
  font-weight: 760;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
  text-align: center;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field label {
  color: #35453f;
  font-size: 0.9rem;
  font-weight: 680;
}

.field input,
.field select,
.field textarea,
.report-controls input,
.report-controls select,
.inline-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 12px 13px;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.field textarea,
.note-textarea,
.item-note {
  min-height: 108px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.report-controls input:focus,
.report-controls select:focus,
.inline-input:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px rgba(92, 169, 121, 0.18);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transform: translateY(-50%);
}

.password-toggle:hover,
.password-toggle.is-visible {
  background: var(--surface-2);
  color: var(--brand);
}

.password-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.action-button,
.status-option {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 760;
  line-height: 1;
  text-decoration: none;
  transition:
    transform 0.14s ease,
    box-shadow 0.14s ease,
    background 0.14s ease,
    color 0.14s ease;
}

.primary-button {
  width: 100%;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(37, 111, 80, 0.22);
  padding: 13px 18px;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--brand-dark);
  padding: 12px 16px;
}

.ghost-button {
  background: transparent;
  color: var(--brand-dark);
  padding: 11px 12px;
}

.danger-button {
  background: #fff1ef;
  color: var(--danger);
  padding: 11px 14px;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.action-button:hover,
.status-option:hover {
  transform: translateY(-1px);
}

button:disabled,
.disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none !important;
  box-shadow: none !important;
}

.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  padding: 12px clamp(16px, 4vw, 34px);
  backdrop-filter: blur(12px);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 13px;
}

.brand-lockup img {
  width: 168px;
  max-height: 44px;
  object-fit: contain;
  object-position: left center;
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy span {
  color: var(--muted);
  font-size: 0.82rem;
}

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

.chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: #34443e;
  font-size: 0.82rem;
  font-weight: 720;
  padding: 6px 10px;
}

.chip.ok {
  border-color: #cce8d7;
  background: #edf9f1;
  color: var(--ok);
}

.chip.warn {
  border-color: #f5d39a;
  background: #fff7e8;
  color: var(--warning);
}

.chip.info {
  border-color: #c7dded;
  background: #edf6fc;
  color: var(--info);
}

.layout {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 34px);
}

.layout.operator-layout {
  width: min(560px, 100%);
  padding-top: 18px;
}

.page-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.operation-title {
  align-items: center;
  margin-bottom: 12px;
}

.operation-title h1 {
  font-size: clamp(1.38rem, 6vw, 1.7rem);
}

.sync-icon-button {
  display: grid;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition:
    transform 0.14s ease,
    border-color 0.14s ease,
    background 0.14s ease,
    color 0.14s ease;
}

.sync-icon-button span {
  font-size: 2rem;
  font-weight: 820;
  line-height: 1;
}

.sync-icon-button.ok {
  border-color: #bfe6cf;
  background: #ebf9f1;
  color: var(--ok);
}

.sync-icon-button.warn {
  border-color: #f2c3bd;
  background: #fff0ef;
  color: var(--danger);
}

.sync-icon-button:hover {
  transform: translateY(-1px);
}

.page-title h1,
.page-title h2 {
  margin: 0 0 6px;
  font-size: clamp(1.45rem, 4vw, 2.15rem);
  letter-spacing: 0;
}

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

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.operation-status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.operation-status-card {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 9px 8px;
}

.operation-status-card span,
.operation-status-card small {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.15;
}

.operation-status-card span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 820;
}

.operation-status-card strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(0.98rem, 3.3vw, 1.18rem);
  font-weight: 860;
  letter-spacing: 0;
  line-height: 1.05;
}

.operation-status-card small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 650;
}

.operation-status-card.ok {
  border-color: #c8e9d4;
  background: #f5fcf7;
}

.operation-status-card.ok strong {
  color: var(--ok);
}

.operation-status-card.alert {
  border-color: #efc3be;
  background: #fff7f6;
}

.operation-status-card.alert strong {
  color: var(--danger);
}

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

.operator-layout .actions-grid {
  grid-template-columns: 1fr;
  gap: 12px;
}

.action-button {
  min-height: 132px;
  align-items: flex-start;
  justify-content: space-between;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 18px;
  text-align: left;
}

.action-button strong {
  display: block;
  margin-bottom: 8px;
  font-size: clamp(1.08rem, 3vw, 1.35rem);
}

.action-button span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
}

.action-button .action-index {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--brand-dark);
  font-weight: 820;
}

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

.action-button.primary-action span,
.action-button.primary-action .action-index {
  color: #fff;
}

.action-button.primary-action .action-index {
  background: rgba(255, 255, 255, 0.18);
}

.action-body {
  min-width: 0;
}

.operator-layout .action-button {
  min-height: 106px;
  padding: 18px 16px;
}

.operator-layout .action-button strong {
  font-size: clamp(1.1rem, 4.5vw, 1.28rem);
}

.active-trip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid #cfe5d6;
  border-radius: var(--radius);
  background: #eefaf2;
  margin: 0 0 22px;
  padding: 16px;
}

.active-trip strong {
  display: block;
  margin-bottom: 4px;
}

.active-trip span {
  color: var(--muted);
}

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.panel-body {
  padding: 18px;
}

.checklist-list {
  display: grid;
  gap: 14px;
}

.checklist-item {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

.checklist-item h3 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.35;
}

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

.status-option {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: #31443b;
  padding: 12px 10px;
  text-align: center;
}

.status-option.selected {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.item-note {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.note-textarea {
  width: 100%;
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  gap: 18px;
}

.admin-nav {
  position: sticky;
  top: 84px;
  align-self: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px;
}

.admin-nav button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  border-radius: 6px;
  background: transparent;
  color: #30443b;
  cursor: pointer;
  font-weight: 760;
  padding: 12px;
}

.admin-nav button.active {
  background: var(--brand);
  color: #fff;
}

.admin-content {
  min-width: 0;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: #43544d;
  font-size: 0.84rem;
  letter-spacing: 0;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.trips-report-table {
  min-width: 760px;
  table-layout: auto;
}

.trips-report-table th,
.trips-report-table td {
  padding: 10px 8px;
  white-space: nowrap;
}

.trips-report-table th:nth-child(3),
.trips-report-table td:nth-child(3),
.trips-report-table th:nth-child(5),
.trips-report-table td:nth-child(5) {
  min-width: 145px;
}

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

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

.split-form .full {
  grid-column: 1 / -1;
}

.report-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.report-controls label {
  display: grid;
  gap: 6px;
  color: #34443e;
  font-size: 0.86rem;
  font-weight: 760;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.report-filter-button {
  min-height: 45px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.segmented button {
  min-height: 42px;
  background: transparent;
  color: #31443b;
  cursor: pointer;
  font-weight: 760;
  padding: 10px 14px;
}

.segmented button.active {
  background: var(--brand);
  color: #fff;
}

.report-document {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 24px;
}

.report-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 2px solid var(--brand);
  padding-bottom: 14px;
  margin-bottom: 20px;
}

.report-brand img {
  width: 220px;
  object-fit: contain;
}

.report-brand h2 {
  margin: 0;
  font-size: 1.35rem;
}

.report-brand p {
  margin: 5px 0 0;
  color: var(--muted);
}

.day-group {
  break-inside: avoid;
  margin: 0 0 24px;
}

.day-group h3 {
  margin: 0 0 12px;
  border-left: 4px solid var(--brand);
  padding-left: 10px;
}

.daily-note {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbf9;
  margin-top: 12px;
  padding: 12px;
}

.daily-note strong {
  display: block;
  margin-bottom: 6px;
}

.empty-state {
  display: grid;
  min-height: 190px;
  place-items: center;
  border: 1px dashed #bdcbc3;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.toast-host {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
}

.toast {
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  color: #23322c;
  font-weight: 680;
}

.loading-overlay {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(244, 247, 245, 0.68);
  padding: 24px;
  backdrop-filter: blur(5px);
}

.loading-card {
  display: grid;
  min-width: min(260px, 100%);
  justify-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px 22px;
  text-align: center;
}

.loading-card strong {
  color: var(--brand-dark);
  font-size: 1rem;
}

.loading-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #d8e9df;
  border-top-color: var(--brand);
  border-radius: 999px;
  animation: loading-spin 0.8s linear infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

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

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-nav {
    position: static;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-lockup img {
    width: 142px;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .layout {
    padding: 16px;
  }

  .page-title {
    flex-direction: column;
  }

  .operation-title {
    align-items: center;
    flex-direction: row;
  }

  .dashboard-grid,
  .actions-grid,
  .status-options,
  .split-form,
  .report-controls {
    grid-template-columns: 1fr;
  }

  .action-button {
    min-height: 112px;
  }

  .active-trip {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .report-brand {
    align-items: flex-start;
    flex-direction: column;
  }

  .report-brand img {
    width: 180px;
  }

  .login-page {
    padding: 18px;
  }

  .login-card {
    padding: 24px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .admin-nav,
  .page-title,
  .report-controls,
  .report-actions,
  .toast-host,
  .no-print {
    display: none !important;
  }

  .layout {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .admin-shell {
    display: block;
  }

  .panel,
  .report-document {
    border: 0;
    box-shadow: none;
  }

  .panel-header {
    display: none;
  }

  .panel-body,
  .report-document {
    padding: 0;
  }

  .data-table {
    min-width: 0;
    font-size: 11px;
  }

  .data-table th,
  .data-table td {
    padding: 6px;
  }
}
