:root {
  --bg: #eef4f8;
  --panel: #ffffff;
  --ink: #102033;
  --muted: #64748b;
  --line: #d9e2ec;
  --blue: #0f4c81;
  --teal: #0f766e;
  --amber: #c77700;
  --rose: #be123c;
  --green: #15803d;
  --shadow: 0 16px 38px rgba(15, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  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,
a {
  border: 0;
  cursor: pointer;
  text-decoration: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 520px) minmax(280px, 420px);
  align-content: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background: linear-gradient(135deg, #e0f2fe 0%, #eef4f8 48%, #fff7ed 100%);
}

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

.login-hero {
  min-height: 360px;
  display: grid;
  align-content: end;
  gap: 10px;
  padding: 28px;
  color: #ffffff;
  background: linear-gradient(135deg, #0f4c81, #0f766e 55%, #d97706);
}

.login-hero span,
.brand span {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: var(--blue);
  font-weight: 950;
  font-size: 1.3rem;
}

.login-hero p,
.topbar span,
.panel-head span,
.metric span,
small {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.login-hero p {
  color: rgba(255, 255, 255, 0.78);
}

.login-hero h1,
.topbar h1,
.panel-head h2,
.metric strong {
  margin: 0;
  letter-spacing: 0;
}

.login-hero h1 {
  max-width: 420px;
  font-size: 3.15rem;
  line-height: 1;
}

.login-card,
.form-panel {
  display: grid;
  gap: 13px;
  padding: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.inline-filter {
  min-width: 240px;
  max-width: 320px;
}

.report-filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.login-card button,
.form-panel button,
.top-actions button,
.top-actions a,
.logout,
.filter-row button,
.action-row button,
.permission-grid button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 13px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 900;
}

.message {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 750;
}

.message.error {
  color: var(--rose);
}

.developer-credit {
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
}

.erp-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 18px;
  padding: 18px;
  background: #102033;
  color: #ffffff;
}

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

.brand span {
  width: 48px;
  height: 48px;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: #9fb4c8;
}

.sidebar nav {
  display: grid;
  align-content: start;
  gap: 7px;
  overflow: auto;
}

.sidebar nav button,
.sidebar nav summary,
.logout {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: #c7d7e7;
  text-align: left;
  font-weight: 850;
}

.sidebar nav summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ffffff;
  background: rgba(15, 118, 110, 0.22);
  border: 1px solid rgba(148, 211, 220, 0.2);
  list-style: none;
}

.sidebar nav summary::-webkit-details-marker {
  display: none;
}

.sidebar nav summary::after {
  content: "›";
  margin-left: 8px;
  color: #9fb4c8;
  font-size: 1.1rem;
  transform: rotate(0deg);
  transition: transform 0.16s ease;
}

.nav-group {
  display: grid;
  gap: 6px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
}

.nav-group[open] {
  border-color: rgba(148, 211, 220, 0.26);
  background: rgba(255, 255, 255, 0.055);
}

.nav-group[open] summary {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.5), rgba(29, 79, 120, 0.68));
  border-color: rgba(148, 211, 220, 0.34);
}

.nav-group[open] summary::after {
  transform: rotate(90deg);
  color: #ffffff;
}

.nav-group button {
  min-height: 36px;
  padding-left: 28px;
  background: rgba(255, 255, 255, 0.035);
  border-left: 3px solid rgba(148, 211, 220, 0.24);
}

.sidebar nav button.active {
  background: #1d4f78;
  color: #ffffff;
}

.logout {
  background: rgba(190, 18, 60, 0.22);
  color: #fecdd3;
  text-align: center;
}

.sidebar-credit {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #dbeafe;
  text-align: center;
}

.content {
  min-width: 0;
  padding: 22px;
}

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

.topbar h1 {
  font-size: 1.75rem;
}

.top-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.top-actions a {
  display: inline-grid;
  place-items: center;
  background: var(--teal);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

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

.metric {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  padding: 17px;
  border-radius: 8px;
  color: #ffffff;
  box-shadow: var(--shadow);
}

.metric span {
  color: rgba(255, 255, 255, 0.78);
}

.metric strong {
  font-size: 1.8rem;
}

.blue {
  background: linear-gradient(135deg, #0f4c81, #2563eb);
}

.teal {
  background: linear-gradient(135deg, #0f766e, #14b8a6);
}

.amber {
  background: linear-gradient(135deg, #c77700, #f59e0b);
}

.rose {
  background: linear-gradient(135deg, #be123c, #fb7185);
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  font-size: 1.06rem;
}

.split {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

#vehiclesView .split,
#routesView .split,
#pickupPointsView .split,
#routeVehicleAssignView .split {
  grid-template-columns: 1fr;
}

#vehiclesView .form-panel {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#vehiclesView .form-panel .panel-head,
#vehiclesView .form-panel .two-col,
#vehiclesView .form-panel button {
  grid-column: 1 / -1;
}

#routesView .split {
  gap: 14px;
}

#routesView .form-panel,
#pickupPointsView .form-panel,
#routeVehicleAssignView .form-panel {
  width: min(100%, 760px);
  justify-self: center;
  padding: 14px;
  border-color: rgba(15, 118, 110, 0.26);
  background: linear-gradient(135deg, #ffffff 0%, #ecfeff 52%, #fff7ed 100%);
}

#routesView .form-panel .panel-head,
#pickupPointsView .form-panel .panel-head,
#routeVehicleAssignView .form-panel .panel-head {
  margin: -14px -14px 12px;
  padding: 14px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(135deg, #0f766e, #2563eb);
}

#routesView .form-panel .panel-head h2,
#routesView .form-panel .panel-head span,
#pickupPointsView .form-panel .panel-head h2,
#pickupPointsView .form-panel .panel-head span,
#routeVehicleAssignView .form-panel .panel-head h2,
#routeVehicleAssignView .form-panel .panel-head span {
  color: #ffffff;
}

#routesView .form-panel label,
#pickupPointsView .form-panel label,
#routeVehicleAssignView .form-panel label {
  gap: 6px;
}

#routesView .form-panel input,
#routesView .form-panel select,
#pickupPointsView .form-panel input,
#pickupPointsView .form-panel select,
#routeVehicleAssignView .form-panel input,
#routeVehicleAssignView .form-panel select {
  min-height: 38px;
}

#routesView .form-panel button,
#pickupPointsView .form-panel button,
#routeVehicleAssignView .form-panel button {
  justify-self: end;
  min-width: 150px;
  background: linear-gradient(135deg, #0f766e, #2563eb);
}

#pickupPointsView .route-pickup-panel {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 50%, #eff6ff 100%);
}

#pickupPointsView .route-pickup-panel .panel-head {
  background: linear-gradient(135deg, #15803d, #0f766e);
}

#routeVehicleAssignView .route-assign-panel {
  background: linear-gradient(135deg, #ffffff 0%, #eff6ff 50%, #fff7ed 100%);
}

#routeVehicleAssignView .route-assign-panel .panel-head {
  background: linear-gradient(135deg, #2563eb, #c77700);
}

#routesView .panel:not(.form-panel),
#pickupPointsView .panel:not(.form-panel),
#routeVehicleAssignView .panel:not(.form-panel) {
  border-color: rgba(37, 99, 235, 0.2);
}

#routesView .panel:not(.form-panel) .panel-head,
#pickupPointsView .panel:not(.form-panel) .panel-head,
#routeVehicleAssignView .panel:not(.form-panel) .panel-head {
  margin: -16px -16px 14px;
  padding: 14px 16px;
  border-radius: 8px 8px 0 0;
  background: #eff6ff;
}

#routesView .panel:not(.form-panel) .panel-head h2,
#pickupPointsView .panel:not(.form-panel) .panel-head h2,
#routeVehicleAssignView .panel:not(.form-panel) .panel-head h2 {
  color: #0f4c81;
}

#pickupPointsView .route-pickup-list .panel-head {
  background: #f0fdf4;
}

#pickupPointsView .route-pickup-list .panel-head h2 {
  color: #15803d;
}

#routeVehicleAssignView .route-assign-list .panel-head {
  background: #fff7ed;
}

#routeVehicleAssignView .route-assign-list .panel-head h2 {
  color: #c77700;
}

#routesView .table-wrap,
#pickupPointsView .table-wrap,
#routeVehicleAssignView .table-wrap {
  border-color: rgba(37, 99, 235, 0.22);
}

#routesView th,
#pickupPointsView th,
#routeVehicleAssignView th {
  color: #0f4c81;
  background: #f0f9ff;
}

.route-summary-panel {
  border-color: rgba(15, 118, 110, 0.22);
}

.route-summary-panel .panel-head {
  margin: -16px -16px 14px;
  padding: 14px 16px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(135deg, #ecfeff, #eff6ff);
}

.route-summary-panel .panel-head h2 {
  color: #0f766e;
}

#routeListTable th {
  color: #0f766e;
  background: #ecfeff;
}

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

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #ffffff;
}

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

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

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

.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.icon-action {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 950;
  line-height: 1;
}

.icon-action.edit {
  background: #2563eb;
}

.icon-action.delete {
  background: #be123c;
}

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

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.entry-card {
  display: grid;
  gap: 9px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.entry-card h3,
.entry-card p {
  margin: 0;
}

.entry-card p {
  color: var(--muted);
  font-size: 0.88rem;
}

.pill {
  display: inline-flex;
  width: fit-content;
  min-height: 26px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.72rem;
  font-weight: 950;
}

.pending {
  background: #fef3c7;
  color: #a16207;
}

.accepted {
  background: #dcfce7;
  color: #15803d;
}

.rejected {
  background: #ffe4e6;
  color: #be123c;
}

.action-row,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-row img {
  width: 118px;
  height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  cursor: zoom-in;
}

.photo-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.82);
}

.photo-preview-modal.open {
  display: flex;
}

.photo-preview-panel {
  display: grid;
  gap: 12px;
  width: min(100%, 960px);
  max-height: 94vh;
}

.photo-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
}

.photo-preview-head button {
  min-height: 38px;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font-weight: 900;
}

.photo-preview-panel img {
  max-width: 100%;
  max-height: 84vh;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.expiry-popup-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.82);
}

.expiry-popup-modal.open {
  display: flex;
}

.expiry-popup-panel {
  display: grid;
  gap: 12px;
  width: min(100%, 680px);
  max-height: 88vh;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
  overflow: auto;
}

.expiry-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.expiry-popup-head strong {
  color: #be123c;
  font-size: 1.1rem;
}

.expiry-popup-head button {
  min-height: 38px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-weight: 900;
}

.expiry-popup-list {
  display: grid;
  gap: 8px;
}

.expiry-popup-list article {
  padding: 10px;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  background: #fff1f2;
  color: #7f1d1d;
  font-weight: 800;
  line-height: 1.35;
}

.action-row .accept {
  background: var(--green);
}

.action-row .reject {
  background: var(--rose);
}

.filter-row button {
  background: #ffffff;
  color: var(--muted);
  border: 1px solid var(--line);
}

.filter-row button.active {
  background: var(--blue);
  color: #ffffff;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.permission-row {
  display: grid;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
  box-shadow: 0 8px 18px rgba(15, 32, 51, 0.06);
}

.permission-row header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.permission-grid button {
  min-height: 38px;
  background: #e2e8f0;
  color: #475569;
}

.permission-grid button.active {
  background: var(--blue);
  color: #ffffff;
}

.role-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.role-card {
  min-height: 116px;
  display: grid;
  align-content: space-between;
  padding: 15px;
  border-radius: 8px;
  color: #ffffff;
  box-shadow: var(--shadow);
}

.role-card strong {
  font-size: 1.05rem;
}

.role-card span,
.role-card small {
  color: rgba(255, 255, 255, 0.82);
}

.role-card.manager {
  background: linear-gradient(135deg, #0f4c81, #2563eb);
}

.role-card.supervisor {
  background: linear-gradient(135deg, #0f766e, #14b8a6);
}

.role-card.driver {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
}

.role-card.helper {
  background: linear-gradient(135deg, #c77700, #f59e0b);
}

.role-card.accounts {
  background: linear-gradient(135deg, #be123c, #fb7185);
}

.role-card.viewer {
  background: linear-gradient(135deg, #334155, #64748b);
}

.user-list {
  display: grid;
  gap: 9px;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.user-row strong,
.user-row span {
  display: block;
}

.user-row span {
  color: var(--muted);
  font-size: 0.84rem;
}

.settings-summary {
  display: grid;
  gap: 10px;
}

.settings-summary article {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.settings-summary strong {
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 980px) {
  .login-screen,
  .erp-shell,
  .split {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

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

@media (max-width: 620px) {
  .content {
    padding: 14px;
  }

  .login-hero h1 {
    font-size: 2.15rem;
  }

  .topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .two-col,
  #vehiclesView .form-panel,
  .sidebar nav {
    grid-template-columns: 1fr;
  }

  .permission-row {
    grid-template-columns: 1fr;
  }
}
