:root {
  --ink: #16211f;
  --muted: #63706d;
  --line: #d9e1de;
  --panel: #ffffff;
  --surface: #f5f7f2;
  --brand: #0f7a5f;
  --brand-dark: #095440;
  --amber: #c88719;
  --red: #b84a3a;
  --blue: #2f6f9f;
  --shadow: 0 18px 45px rgba(25, 40, 36, 0.11);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  background: #fbfcf9;
  border-right: 1px solid var(--line);
}

.brand,
.account-card,
.status-strip,
.section-title,
.chat-header,
.withdraw-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  background: #050505;
  box-shadow: 0 8px 18px rgba(22, 33, 31, 0.16);
}

.brand span,
.label,
.account-card span,
.pill,
.job-meta,
.stop-meta,
.transaction-meta,
.eyebrow {
  color: var(--muted);
  font-size: 0.82rem;
}

.role-switch,
.segmented,
.map-filters {
  display: grid;
  gap: 4px;
  padding: 4px;
  background: #e9efeb;
  border-radius: 8px;
  grid-template-columns: repeat(4, auto);
}

.role-switch {
  grid-template-columns: 1fr 1fr;
}

.segmented {
  grid-template-columns: repeat(3, auto);
}

.role-button,
.segmented button,
.map-filters button {
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.role-button.active,
.segmented button.active,
.map-filters button.active {
  color: var(--ink);
  background: white;
  box-shadow: 0 2px 8px rgba(22, 33, 31, 0.08);
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 750;
}

.nav-item.active,
.nav-item:hover {
  color: var(--ink);
  background: #eaf2ed;
}

.icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--brand);
  font-weight: 900;
}

.account-card {
  align-items: flex-start;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.9rem, 4vw, 3.1rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
}

.eyebrow {
  margin-bottom: 8px;
  text-transform: uppercase;
  font-weight: 800;
}

.status-strip {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-strip > div {
  min-width: 134px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.status-strip strong,
.status-strip span {
  display: block;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar,
.app-cover,
.content-grid,
.chat-layout,
.wallet-grid,
.map-layout,
.billing-grid {
  display: grid;
  gap: 18px;
}

.toolbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-bottom: 18px;
}

.app-cover {
  grid-template-columns: 190px minmax(0, 1fr);
  align-items: center;
  margin-bottom: 18px;
  min-height: 210px;
  overflow: hidden;
  border: 1px solid #222826;
  border-radius: 8px;
  padding: 18px;
  color: white;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0.54)),
    url("assets/big-rig-trucken.png");
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow);
}

.app-cover img {
  width: 170px;
  height: 170px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.58);
}

.app-cover strong {
  display: block;
  margin: 8px 0;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.app-cover p {
  max-width: 640px;
  color: #f4f1ea;
  line-height: 1.5;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.search-box input,
.message-form input,
.withdraw-row input,
.post-form input,
.post-form textarea {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.content-grid {
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
}

.job-list,
.thread-list,
.transactions,
.stops-panel,
.detail-panel,
.chat-panel,
.balance-panel,
.plan-panel,
.post-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.job-list,
.thread-list,
#transactionsList,
#stopsList {
  display: grid;
  gap: 10px;
}

.job-list,
.thread-list {
  padding: 12px;
}

.job-card,
.thread-card,
.transaction-row,
.stop-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: white;
}

.job-card {
  display: grid;
  gap: 8px;
  text-align: left;
}

.job-card.active,
.thread-card.active {
  border-color: var(--brand);
  background: #f0faf5;
}

.job-card strong,
.thread-card strong,
.stop-card strong {
  display: block;
}

.job-route,
.transaction-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf1ef;
  color: var(--ink);
  font-weight: 750;
}

.pill.open {
  background: #e4f5ed;
  color: var(--brand-dark);
}

.pill.accepted {
  background: #fff2d8;
  color: #7c4e00;
}

.detail-panel,
.balance-panel,
.transactions,
.stops-panel,
.plan-panel,
.post-form {
  padding: 18px;
}

.detail-panel {
  min-height: 520px;
}

.detail-hero {
  min-height: 170px;
  margin: -18px -18px 18px;
  padding: 18px;
  border-radius: 8px 8px 0 0;
  color: white;
  background:
    linear-gradient(120deg, rgba(22, 33, 31, 0.88), rgba(15, 122, 95, 0.54)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='320' viewBox='0 0 900 320'%3E%3Crect width='900' height='320' fill='%23344b45'/%3E%3Cpath d='M0 245h900v75H0z' fill='%23212e2b'/%3E%3Cpath d='M54 265h190M348 265h190M642 265h190' stroke='%23f1c66a' stroke-width='10' stroke-linecap='round'/%3E%3Crect x='472' y='112' width='250' height='72' rx='8' fill='%23f6f4ea'/%3E%3Crect x='345' y='132' width='116' height='52' rx='7' fill='%230f7a5f'/%3E%3Ccircle cx='410' cy='202' r='26' fill='%2316211f'/%3E%3Ccircle cx='665' cy='202' r='26' fill='%2316211f'/%3E%3Ccircle cx='410' cy='202' r='10' fill='%23d9e1de'/%3E%3Ccircle cx='665' cy='202' r='10' fill='%23d9e1de'/%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

.detail-hero h2 {
  max-width: 520px;
  margin-top: 74px;
  font-size: 1.7rem;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.action-row,
.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  color: white;
  background: var(--brand);
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button {
  color: var(--ink);
  background: #e9efeb;
}

.chat-layout {
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 640px;
}

.thread-card {
  text-align: left;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 640px;
}

.chat-header,
.message-form {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.chat-header {
  justify-content: space-between;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow: auto;
}

.message {
  max-width: min(560px, 82%);
  padding: 12px 14px;
  border-radius: 8px;
  background: #eef3f0;
}

.message.me {
  align-self: flex-end;
  color: white;
  background: var(--brand);
}

.message small {
  display: block;
  margin-bottom: 4px;
  font-weight: 800;
}

.message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.message-form input,
.withdraw-row input,
.payment-setup input,
.post-form input,
.post-form textarea {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
}

.wallet-grid,
.billing-grid {
  grid-template-columns: repeat(3, minmax(260px, 1fr));
}

.balance-panel {
  min-height: 280px;
}

.balance-panel strong {
  display: block;
  margin: 12px 0;
  font-size: 3.6rem;
  line-height: 1;
}

.balance-panel p,
.plan-panel p {
  color: var(--muted);
  line-height: 1.5;
}

.withdraw-row {
  gap: 10px;
  margin-top: 22px;
}

#transactionsList,
#stopsList {
  margin-top: 14px;
}

.map-layout {
  grid-template-columns: minmax(420px, 1fr) 360px;
}

.map-panel {
  position: relative;
  min-height: 640px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.72) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.72) 1px, transparent 1px),
    linear-gradient(135deg, #dce9e1, #eef0dd 46%, #ccdcd5);
  background-size: 54px 54px, 54px 54px, cover;
  box-shadow: var(--shadow);
}

.map-panel::before,
.map-panel::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  border: 18px solid rgba(47, 111, 159, 0.18);
}

.map-panel::before {
  width: 360px;
  height: 360px;
  left: -120px;
  top: 110px;
}

.map-panel::after {
  width: 420px;
  height: 420px;
  right: -160px;
  bottom: -90px;
}

.route-line {
  position: absolute;
  left: 12%;
  right: 9%;
  top: 52%;
  height: 16px;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, var(--ink), var(--ink) 58px, #f1c66a 58px, #f1c66a 86px);
  transform: rotate(-16deg);
  box-shadow: 0 12px 30px rgba(22, 33, 31, 0.2);
}

.map-pin {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 3px solid white;
  border-radius: 50%;
  color: white;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(22, 33, 31, 0.22);
}

.map-pin.fuel {
  background: var(--blue);
}

.map-pin.food {
  background: var(--amber);
}

.map-pin.rest {
  background: var(--brand);
}

.stop-card {
  display: grid;
  gap: 5px;
}

.post-form {
  display: grid;
  gap: 16px;
}

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

.post-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.post-form textarea {
  min-height: 120px;
  padding-top: 12px;
  resize: vertical;
}

.plan-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 240px;
}

.plan-panel strong {
  font-size: 1.8rem;
}

.price-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  color: #7c4e00;
  background: #fff2d8;
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 8px;
  color: white;
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: 0.22s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.company-only {
  display: none;
}

body.company-mode .company-only {
  display: flex;
}

body.company-mode .driver-only {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr;
    padding: 14px;
  }

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

  .nav-item {
    justify-content: center;
  }

  .nav-item span:last-child {
    display: none;
  }

  .account-card {
    display: none;
  }

  .topbar,
  .app-cover,
  .toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .app-cover {
    min-height: auto;
  }

  .app-cover img {
    width: 140px;
    height: 140px;
  }

  .status-strip {
    justify-content: stretch;
  }

  .status-strip > div,
  .content-grid,
  .chat-layout,
  .wallet-grid,
  .map-layout,
  .billing-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    min-height: auto;
  }

  .map-panel,
  .chat-panel,
  .chat-layout {
    min-height: 520px;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 14px;
  }

  .brand span {
    display: none;
  }

  .status-strip {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar,
  .action-row,
  .withdraw-row,
  .message-form {
    grid-template-columns: 1fr;
    display: grid;
  }

  .segmented,
  .map-filters {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .map-filters {
    width: 100%;
  }

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