html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* DriverHub TEC login */
[hidden] {
  display: none !important;
}

body:not(.authenticated) {
  overflow: hidden;
}

body:not(.authenticated) .topbar,
body:not(.authenticated) > main,
body:not(.authenticated) .primary-nav {
  display: none !important;
}

.auth-screen {
  min-height: 100svh;
  padding: clamp(22px, 5vh, 86px) clamp(22px, 4vw, 76px);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  background:
    linear-gradient(90deg, transparent 45%, #08152933 100%),
    url("login-driverhub-tec.png") center / cover no-repeat;
}

.auth-card {
  width: min(590px, 38vw);
  min-width: 430px;
  padding: clamp(28px, 4.2vh, 50px) clamp(32px, 3.2vw, 56px);
  border: 1px solid #a8c8ff80;
  border-radius: 34px;
  background: linear-gradient(145deg, #16366ed9, #3b2949c4);
  box-shadow: 0 30px 80px #02081699, inset 0 1px 0 #ffffff42;
  color: #fff;
  backdrop-filter: blur(18px) saturate(130%);
}

.auth-card .brand {
  margin: 0 0 30px;
  gap: 14px;
}

.auth-brand-logo {
  width: 112px;
  height: 112px;
  border-radius: 25px;
  border: 2px solid #33bfff;
  box-shadow: 0 0 26px #1ea7ff88;
}

.auth-card .brand strong {
  font-size: clamp(36px, 3vw, 52px);
  letter-spacing: -0.05em;
  text-shadow: 0 5px 18px #0008;
}

.auth-card .brand strong span {
  color: #ffd638;
}

.auth-card h1 {
  margin: 0;
  text-align: center;
  font-size: clamp(36px, 3.1vw, 54px);
  line-height: 1;
}

.auth-card p {
  margin: 16px 0 34px;
  color: #e8ebf5;
  text-align: center;
  font-size: clamp(16px, 1.25vw, 22px);
}

.auth-card form {
  gap: 16px;
}

.auth-field {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  border: 1px solid #ffffff4d;
  border-radius: 18px;
  background: #ffffff12;
  box-shadow: inset 0 1px 0 #ffffff18;
}

.auth-field > span {
  flex: 0 0 30px;
  font-size: 28px;
  color: #fff;
  text-align: center;
}

.auth-card .auth-field input {
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font-size: 20px;
}

.auth-card .auth-field input::placeholder {
  color: #dce2ee;
  opacity: .8;
}

#passwordToggle {
  flex: 0 0 38px;
  border: 0;
  background: transparent;
  color: #dce2ee;
  font-size: 23px;
  cursor: pointer;
}

.auth-actions {
  display: grid;
  gap: 14px;
}

.auth-actions .btn {
  width: 100%;
  min-height: 72px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: linear-gradient(135deg, #34b8ff, #0876f9);
  box-shadow: 0 14px 30px #006fee55, inset 0 1px 0 #ffffff55;
  font-size: 20px;
}

.auth-actions .btn b {
  font-size: 32px;
  font-weight: 400;
}

.auth-actions .btn.secondary {
  min-height: 42px;
  background: transparent;
  box-shadow: none;
  color: #2eb9ff;
  font-size: 16px;
}

.auth-message {
  color: #ffd7d7;
  text-align: center;
}

@media (max-width: 820px) {
  .auth-screen {
    justify-content: center;
    padding: 18px;
    background-position: 38% center;
  }

  .auth-card {
    width: min(520px, 100%);
    min-width: 0;
    padding: 28px 22px;
    border-radius: 25px;
  }

  .auth-brand-logo {
    width: 82px;
    height: 82px;
  }

  .auth-card .brand strong {
    font-size: 34px;
  }

  .auth-card h1 {
    font-size: 34px;
  }

  .auth-card p {
    margin: 12px 0 24px;
    font-size: 15px;
  }

  .auth-field,
  .auth-actions .btn {
    min-height: 58px;
  }

  .auth-card .auth-field input {
    font-size: 17px;
  }
}

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

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

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

.receipt-entry-form {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
}

@media (max-width: 760px) {
  .receipt-entry-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .receipt-entry-form .btn {
    width: 100%;
  }
}

img, input, select, textarea, button {
  max-width: 100%;
}

.mobile-menu-toggle {
  display: none;
}

.search-toggle {
  margin-left: auto;
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid #ffffff33;
  border-radius: 12px;
  background: #ffffff12;
  color: #fff;
  font: inherit;
  font-weight: 800;
}

.search-overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  padding: 80px 18px 18px;
  background: #10151cb8;
  backdrop-filter: blur(8px);
}

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

.search-dialog {
  width: min(680px, 100%);
  max-height: calc(100svh - 100px);
  margin: 0 auto;
  padding: 20px;
  overflow-y: auto;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 25px 80px #0007;
}

.search-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  font-size: 20px;
}

.search-heading button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: #e7eaed;
  font-size: 18px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 2px solid #f4c928;
  border-radius: 14px;
}

.search-box input {
  width: 100%;
  min-height: 50px;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
}

.search-results {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.search-results > p {
  color: #66707c;
}

.search-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.search-results button {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 14px;
  border: 1px solid #dfe4e8;
  border-radius: 13px;
  background: #f7f8f9;
  text-align: left;
}

.search-results button small {
  color: #967800;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.search-results button span {
  color: #66707c;
  font-size: 13px;
  line-height: 1.4;
}

.cash-fund-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.cash-fund-note .btn {
  flex: 0 0 auto;
}

.fleet-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.fleet-card {
  display: grid;
  gap: 5px;
  padding: 18px;
  border: 1px solid #dfe4e8;
  border-radius: 16px;
  background: #fff;
}

.fleet-card span {
  color: #66707c;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.fleet-card strong {
  font-size: 28px;
}

.fleet-card small {
  color: #8b7000;
  font-size: 15px;
  font-weight: 900;
}

.call-result {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 94px;
  padding: 12px;
  border-radius: 13px;
  background: #16784b;
  color: #fff;
  text-decoration: none;
  font-weight: 900;
}

@media (max-width: 600px) {
  .auth-screen {
    min-height: 100svh;
    padding: 16px;
    align-items: start;
  }

  .auth-card {
    margin-top: max(12px, env(safe-area-inset-top));
    padding: 22px 18px;
    border-radius: 20px;
  }

  .auth-card h1 {
    font-size: 28px;
  }

  .auth-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .auth-actions .btn {
    width: 100%;
    min-height: 46px;
  }

  .topbar {
    height: 64px;
    padding: 0 14px;
  }

  .topbar .brand {
    gap: 9px;
    font-size: 16px;
  }

  .topbar .brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 8px 13px;
    border: 1px solid #ffffff33;
    border-radius: 12px;
    background: #ffffff12;
    color: #fff;
    font: inherit;
    font-weight: 800;
  }

  .search-toggle {
    width: 42px;
    padding: 0;
    font-size: 21px;
  }

  .search-toggle span {
    display: none;
  }

  .search-overlay {
    padding: 70px 10px 10px;
  }

  .search-dialog {
    max-height: calc(100svh - 80px);
    padding: 16px;
    border-radius: 18px;
  }

  .search-result {
    grid-template-columns: minmax(0, 1fr) 48px;
  }

  .call-result {
    min-width: 48px;
    padding: 8px;
    font-size: 20px;
  }

  .call-result span {
    display: none;
  }

  .cash-fund-note {
    align-items: stretch;
    flex-direction: column;
  }

  .cash-fund-note .btn {
    width: 100%;
    min-height: 44px;
  }

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

  .fleet-card {
    padding: 15px;
  }

  .primary-nav {
    display: none;
    position: fixed;
    z-index: 50;
    top: 72px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100svh - 88px);
    margin: 0;
    padding: 12px;
    overflow-y: auto;
    flex-direction: column;
    gap: 7px;
    border: 1px solid #dfe4e8;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 18px 50px #10151c40;
  }

  .primary-nav.mobile-open {
    display: flex;
  }

  .primary-nav button {
    width: 100%;
    min-height: 44px;
    padding: 11px 14px;
    text-align: left;
    border-radius: 12px;
  }

  main, .app-page {
    width: 100%;
    padding: 14px 12px calc(36px + env(safe-area-inset-bottom));
  }

  .tabs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    padding: 4px 0 8px;
    overflow: visible;
  }

  .tabs .tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 46px;
    padding: 9px 8px;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }

  .tabs .tab:last-child {
    grid-column: 1 / -1;
  }

  .hero, .compact-hero {
    margin-top: 10px;
    padding: 20px 18px;
    border-radius: 18px;
  }

  .hero h1, .compact-hero h1 {
    font-size: clamp(30px, 11vw, 44px);
    overflow-wrap: anywhere;
  }

  .panel-card, .table-card, .support-card {
    padding: 16px;
    border-radius: 16px;
  }

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

  .form-grid .btn {
    width: 100%;
    min-height: 46px;
  }

  .list-row {
    min-width: 0;
  }

  .list-row > div:first-child,
  .row-actions {
    width: 100%;
    min-width: 0;
  }

  .row-actions {
    flex-wrap: wrap;
  }

  .row-actions .btn {
    min-height: 42px;
  }

  .table-scroll {
    width: 100%;
    overflow: visible;
  }

  .table-card {
    padding: 0;
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .table-card table,
  .table-card tbody,
  .table-card tr,
  .table-card th,
  .table-card td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .table-card table {
    min-width: 0;
  }

  .table-card thead {
    display: none;
  }

  .table-card tbody {
    display: grid;
    gap: 12px;
  }

  .table-card tbody tr {
    padding: 15px;
    border: 1px solid #dfe4e8;
    border-radius: 16px;
    background: #fff;
  }

  .table-card tbody th {
    padding: 0 0 11px;
    border-bottom: 2px solid #f4c928;
    font-size: 17px;
    text-align: left;
  }

  .table-card tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #e7eaed;
    text-align: right;
    font-weight: 800;
  }

  .table-card tbody td:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .table-card tbody td::before {
    content: attr(data-label);
    color: #66707c;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
  }
}

body.report-open {
  overflow: hidden;
}

.report-modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  box-sizing: border-box;
  overflow: auto;
  padding: 24px;
  background: #eef1f4;
}

.report-sheet {
  box-sizing: border-box;
  width: min(900px, 100%);
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  padding: 32px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 18px 60px #10151c24;
}

.report-sheet * {
  box-sizing: border-box;
}

.report-actions {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 22px;
  background: #fff;
}

.report-title {
  padding: 24px;
  border-radius: 18px;
  background: #10151c;
  color: #fff;
}

.report-title h1,
.report-title p {
  margin: 0 0 8px;
}

.report-table-wrap {
  overflow-x: auto;
  margin-top: 24px;
}

.report-sheet table {
  width: 100%;
  border-collapse: collapse;
}

.report-sheet th,
.report-sheet td {
  padding: 12px;
  border-bottom: 1px solid #dfe4e8;
  text-align: left;
}

.report-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding: 18px;
  border-radius: 14px;
  background: #f4c928;
}

.report-total strong {
  font-size: 24px;
}

@media (max-width: 600px) {
  .report-modal {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
    padding: 0;
  }

  .report-sheet {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    padding: 16px;
    border-radius: 0;
  }

  .report-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .report-actions .btn {
    width: 100%;
  }

  .report-table-wrap {
    overflow: visible;
  }

  .report-sheet table,
  .report-sheet tbody {
    display: block;
    width: 100%;
  }

  .report-sheet thead {
    display: none;
  }

  .report-sheet tbody {
    display: grid;
    gap: 12px;
  }

  .report-sheet tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 100%;
    gap: 0;
    overflow: hidden;
    border: 1px solid #dfe4e8;
    border-radius: 14px;
    background: #f8fafb;
  }

  .report-sheet tbody td {
    display: grid;
    gap: 5px;
    min-width: 0;
    padding: 12px;
    border-bottom: 1px solid #e5e9ed;
    font-weight: 800;
  }

  .report-sheet tbody td:last-child {
    border-bottom: 0;
  }

  .report-sheet tbody td::before {
    content: attr(data-label);
    color: #66707c;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .report-sheet tbody td[colspan] {
    grid-column: 1 / -1;
  }
}

@media print {
  body > *:not(#monthlyReportModal) {
    display: none !important;
  }

  #monthlyReportModal {
    position: static;
    display: block !important;
    overflow: visible;
    padding: 0;
    background: #fff;
  }

  .report-sheet {
    width: 100%;
    min-height: 0;
    padding: 0;
    box-shadow: none;
  }

  .report-actions {
    display: none !important;
  }
}

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

.hours-form label {
  display: grid;
  gap: 7px;
  color: #66707c;
  font-size: 12px;
  font-weight: 800;
}

.hours-form input,
.hours-form textarea,
.hours-month-head input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid #d8dde2;
  border-radius: 11px;
  background: #fff;
  color: #10151c;
  font: inherit;
}

.hours-remark {
  grid-column: 1 / -1;
}

.hours-remark textarea {
  min-height: 88px;
  resize: vertical;
}

.hours-save,
.hours-month-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hours-preview {
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff8d8;
  color: #6e5b00;
  font-weight: 900;
}

.hours-month-head {
  margin-bottom: 16px;
}

.hours-month-head h2,
.hours-month-head p {
  margin: 0;
}

.hours-month-head input {
  width: auto;
  min-width: 175px;
}

.hours-report-actions {
  align-items: stretch;
  flex-wrap: wrap;
}

.hours-report-actions .btn {
  font-size: 14px;
}

.hours-note {
  max-width: 650px;
  margin: 9px 0 0;
  padding: 9px 11px;
  border-left: 3px solid #f4c928;
  border-radius: 0 8px 8px 0;
  background: #fff9df;
  color: #3f4852;
  font-size: 13px;
}

.home-date {
  margin-top: 8px !important;
  text-transform: capitalize;
}

@media (max-width: 760px) {
  .hours-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .hours-form label,
  .hours-form input,
  .hours-form textarea {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  .hours-form label {
    overflow: hidden;
  }

  .hours-form input[type="date"],
  .hours-form input[type="time"] {
    display: block;
    min-height: 52px;
    -webkit-appearance: none;
    appearance: none;
  }

  .hours-remark,
  .hours-save {
    grid-column: 1;
  }

  .hours-save,
  .hours-month-head {
    align-items: stretch;
    flex-direction: column;
  }

  .hours-save .btn,
  .hours-month-head input {
    width: 100%;
  }

  .hours-report-actions {
    flex-direction: column;
    width: 100%;
  }

  .hours-report-actions .btn {
    width: 100%;
  }
}

.pin-form {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.pin-form input {
  box-sizing: border-box;
  width: min(220px, 100%);
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid #d8dde2;
  border-radius: 11px;
  background: #fff;
  font: inherit;
  font-size: 18px;
  letter-spacing: .2em;
  text-align: center;
}

.secure-codes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.secure-codes-head h2,
.secure-codes-head p {
  margin: 0;
}

@media (max-width: 600px) {
  .pin-form {
    align-items: stretch;
    flex-direction: column;
  }

  .pin-form input,
  .pin-form .btn {
    width: 100%;
  }
}
