:root {
  --bg: #f6f6f6;
  --bg-alt: #efefef;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --stroke: #ececec;
  --accent: #1f1f1f;
  --primary: #b3122b;
  --primary-dark: #8f0f22;
  --accent-soft: #e6e6e6;
  --shadow: 0 12px 28px rgba(18, 18, 18, 0.08);
  --shadow-soft: 0 4px 14px rgba(18, 18, 18, 0.08);
  --radius: 18px;
}

body {
  background: var(--bg);
  color: var(--text);
}

#app-shell {
  width: min(960px, 100%);
  padding: 0 18px 92px;
}

#app-shell a {
  margin-top: 0;
}

.app-header {
  padding: 20px 4px 6px;
}

.app-title {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.3px;
}

.app-subtitle {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

#content-container {
  margin-top: 10px;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header h1 {
  font-size: 26px;
  font-weight: 800;
  margin: 0;
  text-align: left;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-box {
  background: #ffffff;
  padding: 14px 16px 16px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.section-summary {
  gap: 12px;
  margin-bottom: 8px;
}

.section-header h2 {
  font-size: 18px;
  margin: 0;
}

.section-box .section-header h2 {
  font-weight: 800;
}

.card-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-stack--tight {
  gap: 10px;
}

.card-stack--quiet {
  gap: 12px;
}

.card-stack--horizontal {
  flex-direction: row;
  overflow-x: auto;
  padding-bottom: 6px;
}

.card-stack--horizontal .approval-card {
  min-width: 240px;
  flex: 0 0 auto;
}

.card-stack--horizontal .active-row {
  min-width: 220px;
  flex: 0 0 auto;
}

.card-stack--horizontal .inspection-card--light {
  min-width: 220px;
  flex: 0 0 auto;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.summary-tile {
  background: var(--card);
  border-radius: 16px;
  padding: 12px;
  border: 1px solid rgba(0, 0, 0, 0.03);
  display: grid;
  gap: 6px;
}

.summary-tile--alert {
  background: #fff3f3;
  border-color: #f3c9c9;
}

.summary-icon {
  font-size: 20px;
}

.summary-value {
  font-size: 19px;
  font-weight: 800;
  color: #1f1f1f;
}

.summary-label {
  font-size: 12px;
  color: var(--muted);
}

.summary-message {
  margin: 0;
  font-size: 14px;
  color: #3f3f3f;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 20;
  opacity: 0;
  transition: opacity 220ms ease;
  will-change: opacity;
}

.modal:empty {
  display: none;
}

.modal.is-open {
  opacity: 1;
}

body.modal-open {
  overflow: hidden;
}

.modal-content {
  width: min(960px, 100%);
  min-height: 70vh;
  max-height: min(90vh, 900px);
  overflow: auto;
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.modal-content.is-loading {
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 0;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #2f2f2f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.modal-skeleton {
  display: grid;
  gap: 12px;
  padding: 16px 18px 24px;
}

.skeleton-line {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e6e6e6 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.skeleton-line.w-60 {
  width: 60%;
}

.skeleton-line.w-40 {
  width: 40%;
}

.skeleton-card {
  height: 120px;
  border-radius: 14px;
  background: linear-gradient(90deg, #f2f2f2 25%, #e8e8e8 50%, #f2f2f2 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.modal-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #e2e2e2;
  border-top-color: #9a9a9a;
  animation: spin 0.9s linear infinite;
  margin: 0 0 18px 18px;
}

@keyframes shimmer {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 100% 50%;
  }
}

.section-title-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin-left: 8px;
  border-radius: 999px;
  background: #f3f3f3;
  font-size: 12px;
  font-weight: 700;
  color: #2f2f2f;
}

.card-title {
  font-weight: 700;
  font-size: 18px;
  margin: 6px 0;
}

.card-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.card-note {
  margin-top: 8px;
  color: #3a3a3a;
}

.booking-text {
  margin-top: 10px;
  padding: 12px 14px;
  background: #f3f3f3;
  border-radius: 12px;
  border: 1px dashed #e1e1e1;
  white-space: pre-wrap;
  font-size: 12px;
  color: #4a4a4a;
}

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

.plate {
  background: #1f1f1f;
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.4px;
}

.chip {
  background: #f3f3f3;
  color: #333333;
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.status-pill {
  background: #f3f3f3;
  color: #3a3a3a;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill--kustannusarvio,
.status-pill--aloittamatta {
  background: #ffe6c7;
  color: #6a3d00;
}

.status-pill--kesken,
.status-pill--takuu {
  background: #dbe9ff;
  color: #1d3e77;
}

.status-pill--valmis {
  background: #d9f2e3;
  color: #1f5e3a;
}

.status-pill--laskutettu {
  background: #ececec;
  color: #4a4a4a;
}

.status-pill--peruttu {
  background: #f1f1f1;
  color: #6a6a6a;
}

.status-pill--tuntematon {
  background: #f1f1f1;
  color: #6a6a6a;
}

.approval-status--approved {
  background: #d9f2e3;
  color: #1f5e3a;
}

.approval-status--pending {
  background: #ffe6c7;
  color: #6a3d00;
}

.approval-status--declined {
  background: #f8dfe0;
  color: #7a1f26;
}

.approval-status--expired {
  background: #f1f1f1;
  color: #5a5a5a;
}

.muted-pill {
  background: #f0f0f0;
  color: #5a5a5a;
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.meta-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.meta-value {
  font-size: 14px;
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.summary-title {
  font-size: 18px;
  font-weight: 700;
}

.summary-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.active-row {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.active-row-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex-wrap: wrap;
}

.active-row-status {
  align-self: flex-start;
  margin-bottom: 12px;
}

.active-row-title {
  font-weight: 700;
  font-size: 17px;
  color: #1f1f1f;
  margin-bottom: 6px;
}

.active-row-date {
  font-size: 12px;
  color: var(--muted);
}

.active-row-plate {
  font-size: 18px;
  font-weight: 800;
  color: #1f1f1f;
  margin: 11px 0px 5px;
}

.active-row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  flex-direction: column;
  justify-content: flex-start;
}

.active-row-meta-sep {
  color: #c5c5c5;
}

.active-row--placeholder .status-pill {
  background: #fff1dd;
  color: #7a4b00;
  font-size: 11px;
  padding: 3px 8px;
  margin-left: -3px;
}

.active-row .status-pill {
  font-size: 11px;
  padding: 3px 8px;
  text-transform: capitalize;
}

.booking-disclaimer {
  margin: 10px 0 0;
  font-size: 12px;
  color: #6a3d00;
}

.active-row-actions .button {
  padding: 8px 12px;
  font-size: 12px;
}

.inspection-card--light {
  padding: 14px;
  box-shadow: none;
  border: 1px solid #ededed;
  background: #fafafa;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 10px 16px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
}

.button.primary {
  background: var(--primary);
  color: #ffffff;
}

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

.button.ghost {
  background: #f1f1f1;
  color: #2f2f2f;
}

.inline-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  font-size: 13px;
}

.inline-link:hover {
  text-decoration: underline;
}

button.inline-link {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.muted {
  color: var(--muted);
}

.dot {
  margin: 0 6px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #f0f0f0;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.bell-button {
  background: #f1f1f1;
  font-size: 16px;
}

.tabbar {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 92%);
  background: #fbfbfb;
  border-radius: 999px;
  padding: 8px 14px;
  display: flex;
  justify-content: space-around;
  border: 1px solid #e9e9e9;
  z-index: 10;
  transition: transform 0.5s ease;
}

.tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #1d1d1d;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  margin-top: 0;
  position: relative;
  flex: 1;
}

.tabbar-item.is-active {
  color: #1f1f1f;
}

.tabbar-item.is-active::before {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.tabbar-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f3f3f3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.tabbar-badge {
  position: absolute;
  top: -2px;
  right: 24px;
  background: #ffb347;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 6px;
  display: none;
}

.tabbar-item:not(:last-child)::after {
  content: "";
  position: absolute;
  right: 0;
  top: 12px;
  bottom: 12px;
  width: 1px;
  background: #e6e6e6;
}

.tabbar-badge.is-visible {
  display: inline-flex;
}

.vehicle-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.vehicle-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vehicle-section--archived {
  padding-top: 10px;
  border-top: 1px solid #e6e6e6;
}

.vehicle-card.is-open {
  border-color: var(--accent-soft);
}

.vehicle-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vehicle-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.vehicle-title {
  font-size: 18px;
  font-weight: 700;
}

.vehicle-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.vehicle-km {
  margin-top: 10px;
  font-weight: 700;
  font-size: 16px;
}

.vehicle-next {
  margin-top: 6px;
  color: #3f3f3f;
  font-size: 13px;
}

.vehicle-sync {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}

.vehicle-workorders {
  margin: 8px 0 18px;
}

.vehicle-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.vehicle-card--archived {
  opacity: 0.85;
  border-style: dashed;
}

.workorder-sublist h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.workorder-sublist h3:first-child {
  margin-top: 0;
}

.summary-card .card-actions {
  margin-top: 10px;
}

.workorder-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.workorder-statuses {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-group {
  background: #faf7f4;
  border-radius: 14px;
  padding: 10px;
}

.status-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.status-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sync-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding-bottom: 8px;
}

.sync-footer-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sync-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  background: transparent;
  border: 0;
  padding: 0;
  border-radius: 0;
  max-width: none;
}

.sync-button {
  background: #f2f2f2;
  color: #2f2f2f;
  font-weight: 600;
  padding: 8px 12px;
  font-size: 12px;
}

.sync-button:hover {
  background: #e9e9e9;
}

.sync-message {
  margin-top: 4px;
}

.sync-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #e2e2e2;
  border-top-color: #9a9a9a;
  animation: spin 0.9s linear infinite;
  display: none;
}

.htmx-request .sync-spinner {
  display: inline-block;
}

.button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.status-note {
  color: #3a3a3a;
  font-size: 13px;
}

.workorder-detail .page-header {
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.workorder-detail .page-header h1 {
  flex: 1;
}

.workorder-detail {
  --tabbar-safe: 57px;
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  padding: 16px 10px calc(20px + var(--tabbar-safe));
  overflow: visible;
  background: var(--bg);
}

.workorder-detail-top {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.workorder-detail .page-header-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.page-header-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.page-header-sub {
  font-size: 12px;
  color: var(--muted);
}

.sync-mini {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 6px 8px;
  background: transparent;
  border: 0;
  border-radius: 10px;
}

.sync-mini .meta-label {
  font-size: 10px;
}

.sync-mini .meta-value {
  font-size: 12px;
  font-weight: 600;
}

.workorder-timeline {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 0;
}

.workorder-timeline-body {
  min-height: 0;
  display: flex;
}

.workorder-detail .timeline-feed {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.workorder-detail .timeline-list {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 24px;
}

.approval-create-section {
  align-items: flex-start;
}

.approval-create-panel {
  max-width: 780px;
  width: 100%;
  text-align: left;
  margin-right: auto;
}

.detail-hero {
  background: #fafafa;
  border: 1px solid #ededed;
  border-radius: 14px;
  padding: 12px;
  box-shadow: none;
}

.detail-hero--compact .meta-grid {
  gap: 6px;
  margin-top: 8px;
}

.detail-hero--compact .meta-label {
  font-size: 10px;
  letter-spacing: 0.4px;
}

.detail-hero--compact .meta-value {
  font-size: 13px;
}

.status-timeline-row {
  overflow-x: auto;
}

.status-timeline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  margin: auto;
  width: max-content;
}

.status-step {
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1f1f1;
  color: #4a4a4a;
  font-weight: 600;
}

.status-step.is-current {
  background: #1d3e77;
  color: #ffffff;
}

.status-arrow {
  color: #b0b0b0;
  font-size: 12px;
}

.next-steps-title {
  font-size: 13px;
  font-weight: 700;
  color: #2f2f2f;
  margin-bottom: 4px;
}

.next-steps p {
  margin: 0;
  color: #3f3f3f;
  font-size: 13px;
}

.next-steps--compact {
  background: #f4f4f4;
  border-radius: 12px;
  padding: 10px 12px;
}

.timeline-feed {
  padding: 0;
}

.timeline-list {
  position: relative;
}

.timeline-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  position: relative;
  padding-left: 20px;
}

.timeline-items::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 16px;
  bottom: 16px;
  width: 1px;
  margin-top: 7px;
  background: #e2e2e2;
}

.timeline-item {
  display: flex;
  gap: 12px;
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -13px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.timeline-content {
  flex: 1;
}

.timeline-title {
  font-weight: 700;
  margin: 0;
}

.timeline-time {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.timeline-card {
  padding: 8px 10px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #ededed;
  cursor: default;
}

.timeline-card--plain {
  padding: 0;
  border: 0;
  background: transparent;
}

.timeline-title {
  font-weight: 700;
}

.timeline-initial {
  margin-top: 6px;
}

.timeline-initial .timeline-bubble {
  margin: 0;
}

.detail-notes {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.service-manager-page {
  max-width: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  --tabbar-safe: 0px;
}

.tools-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tools-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tools-list .button {
  justify-content: flex-start;
  width: 100%;
}

.tools-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.timeline-bubble {
  padding: 10px 12px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #ededed;
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 6px;
}

.timeline-bubble p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.approval-card {
  border-left: 4px solid #d9d9d9;
}

.approval-card--receipt {
  border-left-width: 4px;
  padding: 20px;
}

.approval-card--compact {
  border-left-width: 2px;
  border-left-color: #e3e3e3;
  padding: 12px 14px;
}

.approval-compact-main {
  gap: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.approval-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.approval-total {
  font-size: 24px;
  font-weight: 800;
  color: #1f1f1f;
  margin: 4px 0;
}

.approval-meta-sep {
  color: #c5c5c5;
}

.approval-microcopy {
  font-size: 12px;
  color: #6a6a6a;
}

.approval-card--compact .status-pill {
  font-size: 11px;
  padding: 3px 8px;
  letter-spacing: 0.2px;
  background: #f2f4f6;
  color: #4a4a4a;
}

.approval-card--compact .card-title {
  font-size: 19px;
  margin: 0;
}

.approval-card--compact .card-actions {
  gap: 8px;
  margin-top: 12px;
}

.approval-card--compact .button {
  padding: 10px 20px;
  font-size: 14px;
  line-height: 1;
}

.approvals-section .approval-list {
  display: grid;
  gap: 12px;
}

.approvals-section:not(:has(.approval-card)) {
  display: none;
}

.workorder-detail .approval-card {
  border-left: 0;
  border: 1px solid #f1e2c9;
  background: #fffaf2;
  box-shadow: none;
}

.workorder-detail .approval-card--receipt {
  padding: 16px;
}

.workorder-detail .receipt-grand {
  font-size: 22px;
  font-weight: 800;
}

.workorder-detail .approval-card .card-actions {
  gap: 8px;
  margin-top: 10px;
}

.modal-sync-footer {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  padding: 0 4px 10px;
}

.approval-lines,
.approval-attachments {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.receipt-lines {
  gap: 10px;
}

.approval-line {
  padding: 12px;
  border-radius: 12px;
  background: #f4f4f4;
}

.receipt-line {
  background: #f7f7f7;
  border: 1px solid #ededed;
  border-radius: 14px;
  padding: 12px 14px;
}

.approval-line-header,
.approval-line-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: #6b5e57;
}

.receipt-line-top,
.receipt-line-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.receipt-line-top {
  font-size: 12px;
  color: #6b6b6b;
}

.receipt-tag {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
}

.receipt-qty {
  font-variant-numeric: tabular-nums;
}

.receipt-line-main {
  margin-top: 6px;
}

.receipt-title {
  font-weight: 700;
  font-size: 16px;
}

.receipt-total {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.receipt-line-sub {
  margin-top: 4px;
  font-size: 12px;
  color: #6b6b6b;
}

.receipt-line-note {
  margin-top: 6px;
  font-size: 12px;
  color: #6b6b6b;
}

.approval-line-note {
  font-size: 12px;
  color: #6b6b6b;
}

.approval-totals {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.receipt-totals {
  border-top: 1px dashed #e1e1e1;
  padding-top: 12px;
}

.receipt-grand {
  font-weight: 800;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.approval-attachment img {
  width: 100%;
  display: block;
  border-radius: 12px;
}

.approval-create-panel .approval-form {
  display: grid;
  gap: 12px;
}

.approval-create-panel .form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 2fr 1fr;
}

.approval-create-panel .form-field {
  display: grid;
  gap: 6px;
}

.approval-create-panel .form-field--full {
  grid-column: 1 / -1;
}

.approval-create-panel .form-label {
  font-size: 12px;
  font-weight: 600;
  color: #4a403a;
}

.approval-create-panel input,
.approval-create-panel textarea,
.approval-create-panel select {
  border-radius: 10px;
  border: 1px solid #d8ccc4;
  padding: 8px 10px;
  font-size: 13px;
  background: #ffffff;
}

.approval-line-head {
  display: grid;
  grid-template-columns: 0.8fr 2fr 1.6fr 0.7fr 0.8fr 1fr 0.7fr;
  gap: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b5e57;
  text-align: left;
}

.approval-line-items {
  display: grid;
  gap: 8px;
}

.approval-line-row {
  display: grid;
  gap: 6px;
  grid-template-columns: 0.8fr 2fr 1.6fr 0.7fr 0.8fr 1fr 0.7fr;
  align-items: center;
}

.approval-line-row input,
.approval-line-row select {
  padding: 6px 8px;
  font-size: 12px;
}

.approval-line-add {
  align-self: flex-start;
}

.approval-line-row select,
.approval-line-row input {
  width: 100%;
}

.form-errors {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  color: #b35a12;
  font-size: 12px;
}

.form-success {
  margin: 10px 0;
  color: #2b6f3a;
  font-size: 12px;
}

@media (max-width: 900px) {
  .approval-create-panel {
    max-width: 100%;
  }

  .approval-create-panel .form-grid {
    grid-template-columns: 1fr;
  }

  .approval-line-head {
    display: none;
  }

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

@media (max-width: 600px) {
  .approval-line-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  #app-shell {
    padding: 0 14px 92px;
  }

  .summary-bar {
    grid-template-columns: 1fr;
  }

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

/* Fleet UI refresh (2026-02) */
:root {
  --bg: #f4f1eb;
  --bg-alt: #ebe5da;
  --card: #ffffff;
  --panel: #f6f2ea;
  --text: #1d222a;
  --muted: #636b75;
  --stroke: #d8d0c4;
  --accent: #1d2128;
  --accent-soft: #d8cec0;
  --primary: #c94128;
  --primary-dark: #a3301c;
  --ok-bg: #dcefdc;
  --ok-text: #214d31;
  --warn-bg: #ffe5c2;
  --warn-text: #7f4c04;
  --note-bg: #dde8fb;
  --note-text: #1f4478;
  --danger-bg: #f7dce1;
  --danger-text: #7b1e2a;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --shadow-soft: 0 10px 24px rgba(31, 28, 24, 0.08);
  --shadow: 0 24px 48px rgba(31, 28, 24, 0.16);
}

body {
  color: var(--text);
  background:
    radial-gradient(circle at 15% -10%, rgba(255, 247, 233, 0.82) 0%, rgba(255, 247, 233, 0) 42%), radial-gradient(circle at 88% 4%, rgba(234, 241, 252, 0.62) 0%, rgba(234, 241, 252, 0) 38%),
    linear-gradient(180deg, #efebe4 0%, #f5f2ec 58%, #f7f5f1 100%);
}

main {
  width: 100%;
  align-items: stretch;
  padding: 0 0 30px;
}

body > header {
  width: min(1120px, 100%);
  margin: 10px auto 0;
  padding: 0 20px;
}

.site-nav {
  display: flex;
  justify-content: flex-end;
}

.site-nav a {
  margin-top: 0;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #3f4956;
  border: 1px solid rgba(42, 38, 31, 0.18);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.66);
}

.site-nav a:hover {
  background: rgba(255, 255, 255, 0.9);
}

#app-shell {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 12px 20px 114px;
  display: grid;
  gap: 18px;
}

.app-header {
  border: 1px solid rgba(44, 39, 32, 0.09);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.72)),
    repeating-linear-gradient(-30deg, rgba(82, 76, 69, 0.04), rgba(82, 76, 69, 0.04) 1px, transparent 1px, transparent 14px);
  padding: 14px 18px;
  display: grid;
  gap: 7px;
  position: relative;
  overflow: hidden;
}

.app-header::after {
  content: "";
  position: absolute;
  inset: auto -30% -30% auto;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 65, 40, 0.2), rgba(201, 65, 40, 0));
  pointer-events: none;
}

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

.app-title {
  font-size: clamp(24px, 3vw, 30px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 900;
  color: #171a1f;
  line-height: 1;
}

.app-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #8b2915;
  background: rgba(201, 65, 40, 0.14);
  border: 1px solid rgba(201, 65, 40, 0.28);
}

.app-subtitle {
  color: #5d6873;
  font-size: 13px;
  letter-spacing: 0.03em;
  max-width: 65ch;
  text-transform: none;
}

#content-container {
  min-height: 55vh;
  margin-top: 0;
}

.page {
  gap: 20px;
}

.page > * {
  animation: fleet-fade-up 360ms ease both;
}

.page > *:nth-child(2) {
  animation-delay: 40ms;
}

.page > *:nth-child(3) {
  animation-delay: 80ms;
}

.page-header {
  padding: 0 4px;
}

.page-header h1 {
  font-size: clamp(26px, 2.8vw, 34px);
  letter-spacing: 0.01em;
}

.section {
  gap: 12px;
}

.section-header h2 {
  font-size: clamp(18px, 2.4vw, 24px);
  letter-spacing: 0.01em;
}

.section-box {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(58, 47, 34, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(253, 250, 244, 0.94)), linear-gradient(120deg, rgba(255, 236, 216, 0.28), rgba(233, 240, 255, 0.24));
  padding: 18px;
}

.card {
  border-radius: var(--radius-md);
  border: 1px solid rgba(58, 47, 34, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 253, 249, 0.96));
  padding: 16px;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.card-title {
  font-size: clamp(18px, 2.2vw, 24px);
}

.summary-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-tile {
  border-radius: var(--radius-md);
  border: 1px solid rgba(58, 47, 34, 0.13);
  background: linear-gradient(170deg, #ffffff, #faf7f1);
  padding: 12px;
  gap: 5px;
}

.summary-tile--alert {
  background: linear-gradient(175deg, #fff3f4, #fff7f1);
  border-color: rgba(194, 58, 41, 0.26);
}

.summary-icon {
  font-size: 19px;
}

.summary-value {
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.2;
  font-weight: 900;
}

.summary-label {
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #5f6771;
}

.section-title-badge {
  background: #ecf0f7;
  color: #1f334f;
  border: 1px solid rgba(25, 56, 105, 0.18);
}

.card-stack {
  gap: 12px;
}

.card-stack--horizontal {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 1fr);
  overflow-x: auto;
  padding: 10px 8px 14px;
  margin: -10px -8px -6px;
  scrollbar-width: thin;
}

.card-stack--horizontal .card {
  min-height: 100%;
}

.plate {
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  background: #1f2329;
}

.chip {
  background: #edf0f5;
  border: 1px solid #d7deea;
  color: #29313c;
}

.status-pill {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 5px 10px;
  line-height: 1;
  letter-spacing: 0.02em;
}

.status-pill--kustannusarvio,
.status-pill--aloittamatta {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.status-pill--kesken,
.status-pill--takuu {
  background: var(--note-bg);
  color: var(--note-text);
}

.status-pill--valmis {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.status-pill--laskutettu,
.status-pill--peruttu,
.status-pill--tuntematon {
  background: #e7ebf1;
  color: #3c4653;
}

.approval-status--pending {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.approval-status--approved {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.approval-status--declined {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.approval-status--expired {
  background: #eceef1;
  color: #4b5563;
}

.meta-label {
  letter-spacing: 0.08em;
}

.button {
  border-radius: 12px;
  letter-spacing: 0.01em;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    filter 140ms ease;
}

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

.button.primary {
  color: #fff;
  background: linear-gradient(135deg, #cc4a2f 0%, #aa301c 100%);
}

.button.primary:hover {
  background: linear-gradient(135deg, #d1563a 0%, #982b18 100%);
}

.button.ghost {
  border: 1px solid rgba(48, 45, 38, 0.17);
  background: #f5f3ee;
  color: #222831;
}

.inline-link {
  color: #1f3558;
  text-decoration: underline;
  text-decoration-color: rgba(31, 53, 88, 0.34);
  text-underline-offset: 2px;
}

.inline-link:hover {
  text-decoration-color: rgba(31, 53, 88, 0.8);
}

.icon-button {
  border-radius: 12px;
  border: 1px solid rgba(36, 33, 26, 0.13);
  background: #f8f4ec;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.66);
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 24px));
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(44, 39, 32, 0.18);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  justify-content: space-between;
  gap: 8px;
  z-index: 60;
}

.tabbar-item {
  border-radius: 12px;
  padding: 8px 10px 9px;
  color: #353b43;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
  min-width: 0;
}

.tabbar-item:hover {
  background: rgba(237, 239, 244, 0.85);
}

.tabbar-item .tabbar-icon {
  background: #eceff5;
  color: #1f334f;
  border: 1px solid #d7deeb;
}

.tabbar-item:not(:last-child)::after {
  display: none;
}

.vehicle-card {
  cursor: pointer;
}

.vehicle-card.is-open {
  border-color: rgba(31, 51, 79, 0.35);
}

.vehicle-workorders {
  margin: 8px 0 14px;
  padding: 14px;
  border: 1px solid rgba(53, 50, 44, 0.16);
  border-radius: var(--radius-md);
  background: #fbf9f5;
}

.workorder-sublist h3 {
  margin-top: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #5f6975;
}

.workorder-card--compact .meta-grid {
  margin-top: 12px;
}

.pagination {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed rgba(47, 42, 34, 0.21);
}

.workorder-group {
  gap: 14px;
}

.status-group {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(56, 49, 38, 0.12);
  background: #f7f4ee;
}

.status-item {
  border-radius: 10px;
  padding: 8px;
}

.status-note {
  line-height: 1.45;
}

.sync-footer {
  border-top: 1px dashed rgba(53, 47, 38, 0.19);
  margin-top: 2px;
  padding-top: 10px;
}

.sync-button {
  border: 1px solid rgba(43, 38, 31, 0.14);
  background: #f8f3eb;
}

.sync-spinner {
  border-top-color: #2b4b75;
}

.modal {
  background: rgba(22, 24, 28, 0.4);
  backdrop-filter: blur(8px);
}

.modal-content {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: linear-gradient(180deg, #fffefc 0%, #f7f2e9 100%);
  min-height: min(70vh, 780px);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-top: 14px;
  padding-bottom: 12px;
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.96), rgba(255, 253, 247, 0.86));
  backdrop-filter: blur(5px);
  border-bottom: 1px solid rgba(58, 47, 34, 0.12);
}

.modal-skeleton {
  padding-top: 18px;
}

.skeleton-line,
.skeleton-card {
  animation: fleet-shimmer 1.2s linear infinite;
}

.workorder-detail {
  background: transparent;
  padding: 10px 10px calc(18px + var(--tabbar-safe));
  gap: 12px;
}

.status-timeline {
  gap: 8px;
  background: rgba(239, 241, 246, 0.72);
  padding: 6px 10px;
  border-radius: 999px;
}

.status-step {
  background: #e6eaf2;
  color: #2b3f5c;
}

.status-step.is-current {
  background: #1f334f;
}

.next-steps--compact {
  border: 1px solid rgba(52, 46, 38, 0.13);
  border-radius: 14px;
  background: linear-gradient(170deg, #f5f2ea, #f0eeea);
}

.detail-hero {
  border-radius: var(--radius-md);
  border: 1px solid rgba(58, 47, 34, 0.13);
  background: linear-gradient(180deg, #f9f5ee, #f4eee5);
}

.workorder-timeline-body {
  border: 1px solid rgba(58, 47, 34, 0.11);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #fffefc, #faf6ef);
}

.timeline-items {
  padding: 14px 14px 16px 24px;
  gap: 14px;
}

.timeline-items::before {
  left: 13px;
  background: linear-gradient(180deg, rgba(44, 62, 92, 0.54), rgba(44, 62, 92, 0.1));
}

.timeline-item::before {
  left: -11px;
  width: 9px;
  height: 9px;
  background: #294264;
}

.timeline-card {
  border-radius: 12px;
  border: 1px solid rgba(56, 49, 39, 0.15);
  background: #fff;
}

.timeline-card.timeline-card--plain {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.timeline-bubble {
  border-radius: 12px;
  border: 1px solid rgba(56, 49, 39, 0.14);
}

.timeline-bubble.from-mechanic {
  background: #eef3fd;
  border-color: #cad9f5;
}

.timeline-bubble.from-customer {
  background: #f7efe3;
  border-color: #e4d6c2;
}

.timeline-bubble.from-system {
  background: #f3f5f7;
  border-color: #dadfe6;
}

.approval-card {
  border-left: 4px solid #a7b5cb;
}

.approval-card--receipt {
  border-left-color: #d29256;
  background: linear-gradient(180deg, #fffcf4, #fbf4e8);
}

.approval-card--compact {
  border-left: 3px solid #9eb0c9;
}

.approval-total {
  font-size: clamp(24px, 3.2vw, 33px);
}

.approval-line,
.receipt-line {
  border-radius: 12px;
}

.approval-attachment img {
  border: 1px solid rgba(50, 44, 35, 0.17);
}

.approval-create-panel {
  border: 1px solid rgba(57, 47, 35, 0.16);
  background: linear-gradient(180deg, #fffef8, #f6efe2);
}

.approval-create-panel input,
.approval-create-panel textarea,
.approval-create-panel select {
  border-radius: 10px;
  border: 1px solid rgba(57, 47, 35, 0.22);
  background: #fff;
}

.approval-create-panel input:focus,
.approval-create-panel textarea:focus,
.approval-create-panel select:focus {
  outline: none;
  border-color: #264a79;
  box-shadow: 0 0 0 3px rgba(38, 74, 121, 0.13);
}

.form-errors,
.form-success {
  border-radius: 10px;
  padding: 10px;
}

.form-errors {
  background: #fff0ec;
  border: 1px solid rgba(179, 70, 33, 0.25);
}

.form-success {
  background: #e8f5ea;
  border: 1px solid rgba(61, 126, 71, 0.26);
}

@keyframes fleet-fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fleet-shimmer {
  0% {
    background-position: 200% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@media (min-width: 980px) {
  #app-shell {
    padding: 16px 30px 120px;
    gap: 18px;
  }

  .app-header {
    padding: 18px 22px;
  }

  .tabbar {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    width: min(860px, calc(100% - 36px));
    border-radius: var(--radius-md);
    padding: 10px;
    z-index: 60;
    justify-content: center;
  }

  .tabbar-item {
    flex-direction: row;
    align-items: center;
    gap: 9px;
    flex: 0 1 auto;
    padding: 9px 14px;
  }

  .tabbar-item .tabbar-icon {
    width: 26px;
    height: 26px;
  }

  #content-container {
    min-height: 65vh;
  }

  .section-box {
    padding: 20px;
  }

  .summary-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .card-stack--horizontal {
    grid-auto-columns: minmax(280px, 1fr);
  }
}

@media (max-width: 840px) {
  body > header {
    padding: 0 14px;
  }

  #app-shell {
    padding: 10px 14px 114px;
  }

  .app-header {
    border-radius: 20px;
    padding: 12px 14px;
  }

  .app-title {
    font-size: 22px;
  }

  .page-header h1 {
    font-size: 28px;
  }

  .summary-bar {
    grid-template-columns: 1fr;
  }

  .section-box {
    padding: 14px;
    border-radius: 18px;
  }

  .card-stack--horizontal {
    grid-auto-columns: minmax(84%, 1fr);
  }
}

@media (max-width: 520px) {
  .tabbar {
    border-radius: 14px;
    padding: 6px;
  }

  .tabbar-item {
    font-size: 12px;
    gap: 4px;
    padding: 7px 6px 8px;
  }

  .tabbar-icon {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .workorder-detail {
    padding-left: 2px;
    padding-right: 2px;
  }

  .modal-content {
    border-radius: 18px;
  }
}

/* Workorder modal layout refresh (frontend-design) */
.modal-content {
  width: min(1080px, 96%);
}

.modal-header {
  padding: 16px 20px 14px;
}

/* History page refresh */
.history-page {
  gap: 22px;
}

.history-page-header {
  align-items: flex-end;
  padding-inline: 2px;
}

.history-hero {
  display: grid;
  gap: 8px;
  max-width: 760px;
}

.history-hero-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #697486;
  font-weight: 700;
}

.history-page-subtitle {
  margin: 0;
  color: #4f5d71;
  font-size: 15px;
  line-height: 1.45;
}

.history-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border: 1px solid rgba(39, 45, 56, 0.13);
  background: linear-gradient(155deg, #ffffff 0%, #f9f6ef 52%, #f1ece1 100%);
  box-shadow: 0 10px 24px rgba(27, 35, 46, 0.08);
  overflow: hidden;
}

.history-shell > * {
  position: relative;
  z-index: 1;
}

.history-shell-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.history-shell-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.history-results {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.history-results-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.history-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid rgba(34, 42, 55, 0.12);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.98), rgba(248, 245, 238, 0.96));
  box-shadow: 0 6px 14px rgba(34, 42, 55, 0.06);
}

.history-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.history-card-id {
  display: inline-flex;
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7586;
  font-weight: 700;
}

.history-card-title h3 {
  margin: 3px 0 0;
  font-size: 21px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.history-status-pill {
  white-space: nowrap;
  padding: 7px 10px;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.history-card-subtitle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.history-vehicle-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #3d4b60;
  font-size: 15px;
  font-weight: 700;
}

.history-card-note {
  margin: 0;
  border-left: 3px solid rgba(51, 64, 86, 0.25);
  padding: 8px 0 8px 12px;
  color: #313c4d;
  font-size: 14px;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 10px;
}

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

.history-metric {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 13px;
  border: 1px solid rgba(46, 54, 67, 0.11);
  background: rgba(255, 255, 255, 0.82);
}

.history-metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6d7787;
  font-weight: 700;
}

.history-metric-value {
  font-size: 17px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: #222d3c;
  font-weight: 700;
}

.history-card-actions {
  display: flex;
  justify-content: flex-end;
}

.history-card-actions .button {
  min-width: 132px;
}

.history-pagination {
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px dashed rgba(52, 45, 38, 0.22);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.history-page-arrow {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(52, 61, 74, 0.14);
  background: rgba(255, 255, 255, 0.82);
  color: #1f3558;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  text-decoration: none;
  font-weight: 700;
}

.history-page-arrow.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.history-page-numbers {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.history-page-number {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(52, 61, 74, 0.14);
  background: rgba(255, 255, 255, 0.8);
  color: #31455f;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-page-number.is-current {
  background: #273448;
  border-color: #273448;
  color: #fff;
}

.history-page-ellipsis {
  color: #6a778a;
  font-size: 14px;
  padding: 0 2px;
}

.history-skeleton .card {
  margin: 0;
  padding: 22px;
}

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

  .history-card-title h3 {
    font-size: 20px;
  }
}

@media (max-width: 760px) {
  .history-page {
    gap: 16px;
  }

  .history-shell {
    padding: 16px;
    gap: 14px;
  }

  .history-shell-head h2 {
    font-size: 21px;
  }

  .history-card {
    padding: 16px;
    gap: 12px;
  }

  .history-card-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-card-title h3 {
    font-size: 18px;
  }

  .history-vehicle-meta {
    font-size: 14px;
  }

  .history-metrics {
    grid-template-columns: 1fr;
  }

  .history-metric-value {
    font-size: 16px;
  }

  .history-card-actions {
    justify-content: flex-start;
  }

  .history-pagination {
    gap: 8px;
    flex-wrap: wrap;
  }
}

.modal-title {
  font-size: 18px;
  letter-spacing: 0.01em;
}

.workorder-detail--modal {
  --tabbar-safe: 0px;
  min-height: auto;
  grid-template-rows: none;
  gap: 16px;
  padding: 18px 18px 22px;
  height: 100%;
  overflow: hidden;
}

.workorder-detail--modal .workorder-layout-shell {
  display: grid;
  min-height: 0;
  gap: 14px;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr);
}

.workorder-detail--modal .workorder-panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(252, 248, 240, 0.95));
  border: 1px solid rgba(50, 44, 36, 0.12);
  padding: 16px;
}

.workorder-detail--modal .workorder-main-grid > .workorder-panel {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.workorder-detail--modal .workorder-panel--overview {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(250, 245, 236, 0.96)), radial-gradient(circle at 100% 0, rgba(226, 235, 250, 0.5), rgba(226, 235, 250, 0));
}

.workorder-detail--modal .workorder-detail-top {
  gap: 14px;
}

.workorder-detail--modal .status-timeline-row {
  margin: 0;
}

.workorder-detail--modal .status-timeline {
  margin: 0;
  width: auto;
  justify-content: flex-start;
  background: #edf1f8;
  padding: 8px 10px;
}

.workorder-detail--modal .workorder-summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}

.workorder-detail--modal .next-steps--compact,
.workorder-detail--modal .detail-hero {
  margin: 0;
  min-height: 100%;
  border-radius: 14px;
}

.workorder-detail--modal .next-steps--compact {
  padding: 12px 14px;
}

.workorder-detail--modal .detail-hero {
  padding: 12px 14px;
}

.workorder-detail--modal .meta-grid {
  gap: 10px;
}

.workorder-detail--modal .workorder-main-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  min-height: 0;
}

.workorder-detail--modal .workorder-timeline {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 12px;
  overflow: hidden;
}

.workorder-detail--modal .workorder-timeline-body {
  min-height: 0;
  overflow: hidden;
}

.workorder-detail--modal .timeline-feed {
  min-height: 0;
}

.workorder-detail--modal .timeline-list {
  max-height: min(48vh, 460px);
  overflow-y: auto;
  padding-right: 4px;
}

.workorder-detail--modal .timeline-items {
  padding: 16px 14px 18px 24px;
}

.workorder-detail--modal .section-header {
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(63, 53, 39, 0.12);
  margin-bottom: 2px;
}

.workorder-detail--modal .section-header h2 {
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1.1;
  margin: 0;
}

.workorder-detail--modal .approvals-section .approval-list {
  display: grid;
  gap: 14px;
  padding: 12px;
  border: 1px solid rgba(57, 49, 38, 0.12);
  border-radius: 16px;
  background: linear-gradient(180deg, #fffefb, #f9f5ee);
  overflow-y: auto;
  max-height: min(48vh, 460px);
}

.workorder-detail--modal .approval-card--receipt {
  border-radius: 14px;
  padding: 18px;
}

.workorder-detail--modal .approval-lines {
  gap: 10px;
}

.workorder-detail--modal .approval-card .card-actions {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(63, 53, 39, 0.2);
  flex-wrap: wrap;
}

.workorder-detail--modal .approval-card .button {
  min-width: 110px;
}

#workorder-modal .modal-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#workorder-modal .modal-content > .workorder-detail--modal {
  flex: 1;
  min-height: 0;
}

.approval-detail-modal {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow: hidden;
  background: rgba(17, 20, 26, 0.44);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 5;
}

.approval-detail-modal.is-open {
  display: flex;
}

.approval-detail-dialog {
  width: min(760px, 100%);
  max-height: calc(100% - 28px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(51, 45, 36, 0.16);
  background: linear-gradient(180deg, #fffefb, #f8f3e8);
  box-shadow: var(--shadow-strong);
  padding: 14px;
}

.approval-detail-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.98), rgba(255, 253, 247, 0.9));
  border-bottom: 1px solid rgba(51, 45, 36, 0.14);
}

.approval-detail-header h3 {
  margin: 0;
}

.approval-detail-body .approval-card {
  margin: 0;
}

.approval-detail-body {
  min-height: 0;
  overflow-y: auto;
}

@media (min-width: 860px) {
  .workorder-detail--modal .workorder-summary-grid {
    grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  }
}

@media (min-width: 1240px) {
  .workorder-detail--modal .workorder-main-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    align-items: start;
  }

  .workorder-detail--modal .approvals-section {
    position: sticky;
    top: 86px;
  }
}

@media (max-width: 840px) {
  .workorder-detail--modal {
    padding: 12px 12px 16px;
    gap: 12px;
  }

  .workorder-detail--modal .workorder-panel {
    padding: 13px;
    border-radius: 14px;
  }

  .workorder-detail--modal .status-timeline {
    font-size: 10px;
    gap: 6px;
  }

  .workorder-detail--modal .timeline-list {
    max-height: min(44vh, 360px);
  }

  .workorder-detail--modal .section-header h2 {
    font-size: 24px;
  }
}

@media (max-width: 640px) {
  .modal-content {
    width: min(1080px, 98%);
  }

  .modal-header {
    padding: 12px 12px 10px;
  }

  .modal-title {
    font-size: 15px;
  }

  .workorder-detail--modal .section-header h2 {
    font-size: 20px;
  }

  .approval-detail-dialog {
    padding: 10px;
  }
}

/* Typography consistency sweep */
:root {
  --type-2xs: 12px;
  --type-xs: 13px;
  --type-sm: 14px;
  --type-md: 15px;
  --type-lg: 18px;
  --type-xl: clamp(23px, 2vw, 27px);
  --type-section: clamp(19px, 1.6vw, 22px);
  --fw-regular: 500;
  --fw-medium: 600;
  --fw-semibold: 700;
  --fw-heavy: 800;
  --track-tight: -0.01em;
  --track-normal: 0.005em;
  --track-wide: 0.045em;
}

#app-shell,
.modal-content {
  font-size: var(--type-sm);
  line-height: 1.45;
  font-weight: var(--fw-regular);
  letter-spacing: var(--track-normal);
}

.page-header h1 {
  font-size: var(--type-xl);
  line-height: 1.1;
  font-weight: var(--fw-heavy);
  letter-spacing: var(--track-tight);
}

.section-header h2,
.workorder-detail--modal .section-header h2 {
  font-size: var(--type-section);
  line-height: 1.15;
  font-weight: var(--fw-semibold);
  letter-spacing: var(--track-tight);
}

.card-title,
.vehicle-title,
.active-row-title,
.receipt-title {
  font-size: var(--type-lg);
  line-height: 1.2;
  font-weight: var(--fw-semibold);
  letter-spacing: var(--track-tight);
}

.approval-total,
.receipt-grand {
  font-size: clamp(28px, 2.4vw, 32px);
  line-height: 1.1;
  font-weight: var(--fw-heavy);
  letter-spacing: var(--track-tight);
}

.summary-value {
  font-size: clamp(19px, 2vw, 24px);
  line-height: 1.15;
  font-weight: var(--fw-heavy);
  letter-spacing: var(--track-tight);
}

.active-row-plate,
.meta-value {
  font-size: var(--type-md);
  line-height: 1.25;
  font-weight: var(--fw-medium);
  letter-spacing: 0;
}

.card-note,
.card-subtitle,
.vehicle-next,
.status-note,
.next-steps p,
.timeline-bubble p,
.detail-notes {
  font-size: var(--type-md);
  line-height: 1.45;
  font-weight: var(--fw-regular);
  letter-spacing: var(--track-normal);
}

.meta,
.vehicle-subtitle,
.active-row-date,
.active-row-meta,
.booking-disclaimer,
.vehicle-sync,
.approval-meta,
.approval-microcopy,
.timeline-time,
.timeline-meta,
.receipt-line-sub,
.receipt-line-note,
.approval-line-note,
.sync-message,
.modal-sync-footer,
.sync-mini .meta-value {
  font-size: var(--type-sm);
  line-height: 1.35;
  font-weight: var(--fw-regular);
  letter-spacing: var(--track-normal);
}

.meta-label,
.summary-label,
.page-header-sub,
.receipt-tag,
.sync-mini .meta-label {
  font-size: var(--type-xs);
  line-height: 1.25;
  font-weight: var(--fw-medium);
  letter-spacing: var(--track-wide);
}

.status-pill,
.tabbar-icon,
.approval-card--compact .status-pill {
  font-size: var(--type-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
}

.button,
.inline-link,
.tabbar-item,
.next-steps-title,
.modal-title {
  font-size: var(--type-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
}

.workorder-detail--modal .status-timeline {
  font-size: var(--type-xs);
}

.workorder-detail--modal .approval-card--compact .status-pill {
  font-size: var(--type-2xs);
}

.workorder-detail--modal .approval-card--compact .card-title {
  font-size: var(--type-md);
  line-height: 1.25;
}

@media (max-width: 840px) {
  .page-header h1 {
    font-size: clamp(21px, 5.5vw, 25px);
  }

  .section-header h2,
  .workorder-detail--modal .section-header h2 {
    font-size: clamp(18px, 4.4vw, 20px);
  }

  .card-title,
  .vehicle-title,
  .active-row-title,
  .receipt-title {
    font-size: clamp(17px, 4.4vw, 19px);
  }

  .approval-total,
  .receipt-grand {
    font-size: clamp(24px, 6.4vw, 30px);
  }

  .workorder-detail--modal .status-timeline {
    font-size: var(--type-2xs);
  }
}

/* Shadow consistency sweep */
:root {
  --shadow-soft: 0 3px 10px rgba(31, 28, 24, 0.09);
  --shadow: 0 8px 20px rgba(31, 28, 24, 0.14);
  --shadow-strong: 0 14px 30px rgba(26, 23, 18, 0.2);
}

.section-box,
.summary-tile,
.card,
.approval-card,
.workorder-detail--modal .workorder-panel,
.workorder-detail--modal .approval-card {
  box-shadow: var(--shadow-soft);
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.card-stack--horizontal {
  padding: 12px 12px 18px;
  margin: -12px -12px -8px;
}

.card-stack--horizontal .card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.vehicle-card.is-open,
.workorder-detail--modal .approval-card {
  box-shadow: var(--shadow);
}

.workorder-detail--modal .approval-card:not(.js-card-openable):hover {
  transform: none;
  box-shadow: var(--shadow);
}

.tabbar {
  box-shadow: var(--shadow);
}

.modal-content {
  box-shadow: var(--shadow-strong);
}

/* Ensure workorder modal stays above bottom tabbar footprint */
:root {
  --modal-tabbar-clearance: 98px;
}

.modal {
  padding: 12px 12px calc(var(--modal-tabbar-clearance) + env(safe-area-inset-bottom));
}

.modal-content {
  max-height: calc(100dvh - var(--modal-tabbar-clearance) - 24px - env(safe-area-inset-bottom));
}

@media (max-width: 640px) {
  :root {
    --modal-tabbar-clearance: 92px;
  }

  .modal {
    padding: 8px 8px calc(var(--modal-tabbar-clearance) + env(safe-area-inset-bottom));
  }
}

.button.primary {
  box-shadow: 0 5px 14px rgba(163, 48, 28, 0.24);
}

@media (hover: hover) and (pointer: fine) {
  .js-card-openable {
    cursor: pointer;
  }

  .card,
  .button {
    transition:
      transform 160ms ease,
      box-shadow 160ms ease,
      filter 160ms ease;
    will-change: transform;
  }

  .card:hover {
    transform: translateY(-2px);
  }

  .card-stack--horizontal .card:hover {
    transform: translateY(-1px);
  }

  .button:hover {
    transform: translateY(-2px);
  }

  .button.primary:hover {
    box-shadow: 0 10px 20px rgba(163, 48, 28, 0.3);
  }
}

.card-stack--horizontal .inspection-card--light:hover,
.inspection-card--light:hover {
  transform: none;
  box-shadow: var(--shadow-soft);
  border-color: rgba(58, 47, 34, 0.1);
}
