/* Mobile workspace: the same workshop, with navigation and controls for touch.
   Kept separate from desktop surfaces to make the responsive rules maintainable. */
.mobile-nav {
  display: none;
}

/* Consistent logo crop at a measured scale, without stretching the artwork. */
.sidebar .brand.brand-lockup {
  --brand-scale: 0.84;
  gap: 4px;
}
.mobile-brand .brand.brand-lockup {
  --brand-scale: 0.74;
  gap: 4px;
}
:is(.sidebar, .mobile-brand) .brand .brand-emblem {
  width: calc(38px * var(--brand-scale));
  height: calc(28px * var(--brand-scale));
}
:is(.sidebar, .mobile-brand) .brand .brand-emblem img {
  width: calc(52px * var(--brand-scale)) !important;
  height: calc(52px * var(--brand-scale)) !important;
  left: calc(-6px * var(--brand-scale));
  top: calc(-8px * var(--brand-scale));
}
:is(.sidebar, .mobile-brand) .brand .brand-word {
  width: calc(150px * var(--brand-scale));
  height: calc(29px * var(--brand-scale));
}
:is(.sidebar, .mobile-brand) .brand .brand-word img {
  width: calc(195px * var(--brand-scale)) !important;
  height: calc(195px * var(--brand-scale)) !important;
  left: calc(-22px * var(--brand-scale));
  top: calc(-137px * var(--brand-scale));
}
@media (min-width: 721px) {
  :root {
    --sidebar: 214px;
  }
  .sidebar-brand {
    height: 56px;
    min-height: 56px;
    margin-bottom: 6px;
  }
  .sidebar .nav-caption {
    padding: 12px 10px 4px;
  }
  .sidebar .nav button {
    min-height: 39px;
    padding: 8px 10px;
    font-size: 12px;
  }
  .sidebar .nav button svg {
    width: 17px;
    height: 17px;
  }
  .topbar {
    height: 56px;
    padding-inline: 24px;
  }
  .content {
    padding: 20px 24px 32px;
  }
  .page-heading h1,
  .dashboard-workspace h1 {
    font-size: 22px;
  }
  .dashboard-workspace .dashboard-metrics > .summary-cell {
    min-height: 58px;
    padding: 10px 14px;
  }
  .dashboard-workspace .dashboard-metrics > .summary-cell strong {
    font-size: 21px;
  }
  .heading-actions .btn {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 12px;
  }
  .dashboard-workspace .workshop-register td {
    padding-block: 11px;
  }
}

@media (max-width: 720px) {
  :root {
    --mobile-nav-height: 58px;
  }
  html {
    scroll-padding-top: 80px;
    scroll-padding-bottom: 90px;
  }
  .main {
    background: #f4f7fa;
  }
  .content {
    padding: 16px 14px
      calc(var(--mobile-nav-height) + 28px + env(safe-area-inset-bottom, 0px));
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    height: calc(54px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
    padding-inline: 12px;
    gap: 12px;
    background: #fff;
  }
  .mobile-brand {
    flex: 1;
    min-width: 0;
  }
  .mobile-brand .brand {
    width: fit-content;
    max-width: 100%;
  }
  .topbar .profile {
    padding-left: 0;
    border: 0;
  }
  .topbar .avatar {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed;
    inset: auto 0 0;
    z-index: 20;
    min-height: calc(
      var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px)
    );
    padding: 5px max(6px, env(safe-area-inset-right, 0px))
      calc(5px + env(safe-area-inset-bottom, 0px))
      max(6px, env(safe-area-inset-left, 0px));
    border-top: 1px solid #d8e1e8;
    background: #fff;
  }
  .mobile-nav button {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 0;
    min-height: 48px;
    gap: 3px;
    padding: 5px 0;
    border-radius: 5px;
    color: #526474;
    font-size: 11px;
    line-height: 1.25;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .mobile-nav svg {
    width: 19px;
    height: 19px;
  }
  .mobile-nav button[aria-current="page"],
  .mobile-nav .current-section {
    color: #0768aa;
    background: #eaf2f8;
    font-weight: 600;
  }
  .mobile-nav button:active {
    background: #dcebf6;
  }
  .menu-open .mobile-nav {
    visibility: hidden;
  }
  .sidebar {
    width: min(286px, calc(100vw - 48px));
    max-width: 286px;
    padding-top: env(safe-area-inset-top, 0px);
    padding-inline: 10px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .sidebar .nav button {
    min-height: 44px;
    padding: 8px 10px;
    font-size: 13px;
    gap: 10px;
  }
  .sidebar .nav button svg {
    width: 17px;
    height: 17px;
  }
  .sidebar .nav-caption {
    padding: 10px 10px 4px;
    font-size: 11px;
  }
  .sidebar .side-bottom {
    margin-top: 12px;
    padding-top: 8px;
  }
  .sidebar .workshop-identity {
    display: none;
  }
  .sidebar .sidebar-close {
    top: 5px;
    right: 6px;
    width: 44px;
    height: 44px;
  }

  .sidebar-brand {
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 2;
    height: 54px;
    min-height: 54px;
    margin: 0 -10px 4px;
    padding: 0 12px;
  }

  .page-heading h1,
  .dashboard-workspace h1 {
    font-size: 22px;
    letter-spacing: -0.5px;
  }
  .subtitle {
    font-size: 12px;
    line-height: 1.6;
  }
  .page-heading .heading-actions {
    gap: 8px;
  }
  .heading-actions .btn,
  .btn {
    min-height: 44px;
  }
  .heading-actions .btn {
    font-size: 13px;
  }
  .panel {
    border-color: #d8e1e8;
    border-radius: 6px;
    background: #fff;
  }
  .panel-head h2 {
    font-size: 16px;
  }
  .panel-head p {
    font-size: 13px;
    line-height: 1.5;
  }
  .panel-body {
    padding-inline: 16px;
  }
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    font-size: 16px;
    min-height: 44px;
  }
  input[type="checkbox"],
  input[type="radio"] {
    min-height: 0;
  }
  .field label {
    font-size: 14px;
    color: #344f62;
  }
  .field-hint {
    line-height: 1.6;
  }
  .filters {
    padding: 0;
    gap: 10px;
  }
  .filters select {
    font-size: 16px;
  }
  .search {
    min-width: 0;
  }
  .search input {
    min-height: 44px;
    font-size: 16px;
    background: #fff;
  }
  .search svg {
    top: 15px;
  }
  .tabs,
  .detail-tabs,
  .dossier-nav {
    overscroll-behavior-x: contain;
  }
  .tabs button {
    min-height: 44px;
  }

  .dashboard-workspace .page-heading {
    margin-bottom: 4px;
  }
  .dashboard-workspace .heading-actions {
    margin-top: 10px;
  }
  .dashboard-workspace .owner-tabs {
    margin-top: 8px;
    background: transparent;
  }
  .dashboard-workspace .owner-tabs > div {
    gap: 16px;
  }
  .dashboard-workspace .owner-tabs > div > button {
    font-size: 13px;
  }
  .dashboard-workspace .dashboard-metrics {
    background: #fff;
    border: 1px solid #d8e1e8;
    border-radius: 6px;
    overflow: hidden;
    margin: 12px 0 14px;
  }
  .dashboard-workspace .dashboard-metrics > .summary-cell {
    min-height: 66px;
    padding: 10px 12px;
    gap: 5px;
  }
  .dashboard-workspace .dashboard-metrics > .summary-cell:nth-child(2n) {
    border-right: 0;
  }
  .dashboard-workspace .dashboard-metrics > .summary-cell:nth-child(-n + 2) {
    border-bottom: 1px solid #e1e7ed;
  }
  .dashboard-workspace .summary-label {
    font-size: 12px;
    color: #526474;
  }
  .dashboard-workspace .workshop-list > .panel-head {
    padding: 12px;
    background: #fff;
  }
  .dashboard-workspace .list-toolbar {
    gap: 8px;
    padding: 12px;
  }
  .dashboard-workspace .list-toolbar .search {
    flex-basis: 100%;
  }
  .dashboard-workspace .dashboard-stage-select,
  #dashboard-order {
    width: 100%;
    max-width: none;
    flex: 1 1 100%;
    font-size: 16px;
    min-height: 44px;
  }
  .dashboard-workspace .register-meta {
    background: #f7f9fb;
    font-size: 12px;
  }
  .dashboard-workspace .service-cards {
    padding: 0 12px;
  }
  .dashboard-workspace .service-card {
    padding: 16px 0 10px;
  }
  .service-card .mobile-vehicle {
    margin-top: 12px;
    gap: 10px;
  }
  .service-card .mobile-vehicle b {
    font-size: 15px;
    color: #193345;
  }
  .service-card .mobile-vehicle small {
    font-size: 13px;
    margin-top: 2px;
    color: #526474;
  }
  .register-mobile-meta {
    margin-top: 12px;
    gap: 10px;
  }
  .register-mobile-meta b {
    font-size: 13px;
  }
  .service-card .card-bottom {
    margin-top: 8px;
    gap: 8px;
  }
  .service-card .card-bottom .btn {
    font-size: 13px;
    min-height: 44px;
    padding-inline: 6px;
  }
  .dashboard-workspace .workbench-aside {
    gap: 14px;
  }
  .dashboard-workspace .workbench-aside > .panel {
    padding: 16px;
    border: 1px solid #d8e1e8;
    border-radius: 6px;
    background: #fff;
  }
  .dashboard-workspace .panel .btn.full-width {
    width: 100%;
    font-size: 14px;
  }
  .dashboard-workspace .attention-item {
    min-height: 64px;
  }
  .dashboard-workspace .connection-note {
    padding: 16px 0;
  }

  .calendar-panel .panel-head {
    padding: 12px;
  }
  .calendar .day {
    min-height: 64px;
    padding: 6px 3px;
  }
  .calendar .day .num {
    font-size: 12px;
  }
  .calendar .dayname {
    font-size: 10px;
    padding-block: 10px;
  }
  .calendar .event {
    font-size: 11px;
    padding: 3px 2px;
  }

  /* A vehicle file is a full screen workspace on phones, above the navigation. */
  dialog[open] {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    overscroll-behavior: contain;
  }
  .dialog-head {
    min-height: 60px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
    align-items: center;
    box-shadow: none;
  }
  .dialog-head h2 {
    font-size: 18px;
    line-height: 1.3;
  }
  .dialog-head p {
    font-size: 13px;
    line-height: 1.5;
  }
  .dialog-head .icon-btn {
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid #d8e1e8;
    border-radius: 5px;
  }
  .dialog-content {
    padding: 16px 16px calc(28px + env(safe-area-inset-bottom, 0px));
  }
  .detail-header {
    border-radius: 5px;
    flex-wrap: wrap;
  }
  .detail-header h3 {
    font-size: 15px;
  }
  .detail-header select {
    font-size: 16px;
    width: 100%;
  }
  .detail-tabs {
    margin-inline: -16px;
    padding-inline: 16px;
    gap: 20px;
    margin-bottom: 16px;
    border-bottom: 1px solid #d8e1e8;
  }
  .detail-tabs button {
    font-size: 14px;
    flex-shrink: 0;
  }
  .form-grid {
    gap: 18px;
  }
  .form-actions {
    display: flex;
    gap: 10px;
    background: #fff;
    padding-top: 16px;
    margin-top: 20px;
  }
  .form-actions .btn {
    font-size: 14px;
  }
  .check-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .check-row label {
    font-size: 15px;
  }
  .check-row select {
    width: 100%;
  }
  .check-note summary {
    min-height: 44px;
  }
  .checklist-summary {
    flex-wrap: wrap;
  }
  .segmented button {
    font-size: 14px;
    min-height: 44px;
  }
  #toast {
    bottom: calc(
      var(--mobile-nav-height) + 14px + env(safe-area-inset-bottom, 0px)
    );
  }
}
@media (max-width: 360px) {
  .content {
    padding-inline: 12px;
  }
  .mobile-nav button {
    font-size: 10px;
  }
  .dashboard-workspace .owner-tabs > div {
    gap: 10px;
  }
  .dashboard-workspace .owner-tabs > div > button {
    font-size: 12px;
  }
  .dashboard-workspace .dashboard-metrics > .summary-cell strong {
    font-size: 21px;
  }
  .page-heading h1 {
    font-size: 22px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mobile-nav button {
    transition: none;
  }
}
@media print {
  .mobile-nav {
    display: none !important;
  }
}

/* Filters remain immediately available on desktop, expandable on a phone. */
.dashboard-controls {
  display: contents;
}
.mobile-filter-toggle,
.mobile-control-label {
  display: none;
}
@media (max-width: 720px) {
  .dashboard-workspace .list-toolbar {
    flex-wrap: wrap;
  }
  .dashboard-workspace .list-toolbar .search {
    flex: 1 1 0;
    max-width: none;
  }
  .mobile-filter-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    min-width: 48px;
    min-height: 44px;
    color: #526474;
    background: #fff;
    border: 1px solid #bacbd8;
    border-radius: 5px;
  }
  .mobile-filter-toggle.has-filters,
  .mobile-filter-toggle[aria-expanded="true"] {
    color: #0768aa;
    background: #eaf2f8;
    border-color: #8eb7d2;
  }
  .dashboard-controls {
    display: none;
  }
  .dashboard-controls.filters-open {
    display: grid;
    width: 100%;
    gap: 8px;
    padding: 8px 0 4px;
  }
  .mobile-control-label {
    display: block;
    font-size: 13px;
    color: #526474;
    margin-top: 4px;
  }
}
