/* Layout mode: desktop vs mobile (toggled from header) */

body.layout-desktop .mobile-only {
  display: none !important;
}

body.layout-mobile .desktop-only {
  display: none !important;
}

.layout-toggle {
  font-size: 0.82rem;
  white-space: nowrap;
}

/* —— Shared mobile layout polish —— */

body.layout-mobile {
  padding: 0.85rem 0.85rem 5.5rem;
}

body.layout-mobile.has-sidebar {
  padding: 0;
}

body.layout-mobile .app-shell {
  grid-template-columns: 1fr;
}

body.layout-mobile .sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.55rem;
  padding: 0.75rem 0.85rem;
  border-right: none;
  border-bottom: 1px solid #1a1713;
}

body.layout-mobile .sidebar-brand {
  flex: 1 1 auto;
  min-width: 7rem;
}

body.layout-mobile .sidebar-product {
  font-size: 1rem;
}

body.layout-mobile .sidebar-new-job {
  width: auto;
  margin: 0;
  flex: 0 0 auto;
}

body.layout-mobile .sidebar-nav {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0.3rem;
  width: 100%;
  padding-bottom: 0.15rem;
  -webkit-overflow-scrolling: touch;
}

body.layout-mobile .sidebar-section {
  display: none;
}

body.layout-mobile .sidebar-link {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
}

body.layout-mobile .sidebar-footer {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 0;
  padding-top: 0.45rem;
  gap: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

body.layout-mobile .sidebar-footer .role-badge {
  width: 100%;
}

body.layout-mobile .sidebar-footer .btn,
body.layout-mobile .sidebar-footer form {
  width: auto;
  flex: 1 1 auto;
}

body.layout-mobile .sidebar-footer form.inline .btn {
  width: 100%;
}

body.layout-mobile .app-main {
  padding: 0.85rem 0.85rem 5.5rem;
}

body.layout-mobile h1 {
  font-size: 1.35rem;
}

body.layout-mobile .top {
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

body.layout-mobile .top-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

body.layout-mobile .top-meta {
  gap: 0.35rem 0.5rem;
}

body.layout-mobile .top-actions .layout-toggle {
  grid-column: 1 / -1;
}

body.layout-mobile .btn-new-job {
  padding: 0.65rem 1rem;
  font-size: 1rem;
}

body.layout-mobile .tabs {
  flex-wrap: wrap;
}

body.layout-mobile .tabs a {
  flex: 1;
  text-align: center;
  min-width: 5.5rem;
}

body.layout-mobile .modal-card {
  width: min(100%, 24rem);
  margin: 0.75rem;
}

body.layout-mobile .job-form,
body.layout-mobile .users-panel,
body.layout-mobile .table-wrap {
  border-radius: 10px;
}

/* —— Job list cards —— */

body.layout-mobile .job-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

body.layout-mobile .job-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.9rem;
  box-shadow: var(--shadow);
}

body.layout-mobile .job-card.is-high-priority {
  border-left: 3px solid #1c1a17;
}

body.layout-mobile .job-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

body.layout-mobile .job-card-title {
  font-size: 1rem;
  line-height: 1.35;
}

body.layout-mobile .job-card-desc {
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--ink);
}

body.layout-mobile .job-card-meta {
  margin: 0 0 0.75rem;
  display: grid;
  gap: 0.35rem;
}

body.layout-mobile .job-card-meta div {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0.5rem;
  font-size: 0.84rem;
}

body.layout-mobile .job-card-meta dt {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

body.layout-mobile .job-card-meta dd {
  margin: 0;
}

body.layout-mobile .job-card-workers dd {
  line-height: 1.35;
}

body.layout-mobile .job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}

body.layout-mobile .job-actions .btn {
  flex: 1 1 calc(50% - 0.25rem);
  min-width: 4.5rem;
  padding: 0.55rem 0.5rem;
}

body.layout-mobile td.actions .job-actions,
body.layout-desktop td.actions .job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

body.layout-desktop td.actions .job-actions .btn {
  font-size: 0.82rem;
  padding: 0.3rem 0.5rem;
}

/* —— Job form —— */

body.layout-mobile .form-layout {
  grid-template-columns: 1fr;
}

body.layout-mobile .form-body {
  grid-template-columns: 1fr;
}

body.layout-mobile .form-side {
  order: 0;
}

body.layout-mobile .attach-section {
  min-height: auto;
}

body.layout-mobile .drop-zone {
  min-height: 11rem;
}

body.layout-mobile .form-actions {
  display: flex;
  gap: 0.5rem;
  position: sticky;
  bottom: 0;
  margin: 1rem -0.85rem -0.85rem;
  padding: 0.75rem 0.85rem;
  background: #efe9dd;
  border-top: 1px solid var(--line);
  z-index: 5;
}

body.layout-mobile .form-actions .btn.primary {
  flex: 1;
  padding: 0.7rem 1rem;
}

body.layout-mobile .crew-row {
  grid-template-columns: 1fr;
}

/* —— Login —— */

body.layout-mobile.login-page {
  padding: 1rem 0.85rem 2rem;
  display: flex;
  flex-direction: column;
}

body.layout-mobile .login-layout-toggle {
  align-self: flex-end;
  margin-bottom: 0.5rem;
}

body.layout-mobile .login-shell {
  width: 100%;
  max-width: none;
}

body.layout-mobile .name-grid {
  grid-template-columns: 1fr 1fr;
}

body.layout-mobile .name-chip {
  min-height: 3.25rem;
}

/* —— Assignments —— */

body.layout-mobile .assign-grid {
  grid-template-columns: 1fr;
}

body.layout-mobile .view-note {
  font-size: 0.85rem;
}

body.layout-mobile .sheet-toolbar {
  flex-direction: column;
  align-items: stretch;
}

body.layout-mobile .sheet-tabs {
  justify-content: flex-start;
  overflow-x: auto;
  flex-wrap: nowrap;
  padding-bottom: 0.25rem;
}

/* —— People admin —— */

body.layout-mobile .users-add {
  grid-template-columns: 1fr;
}

body.layout-mobile .user-edit {
  grid-template-columns: 1fr;
}

body.layout-mobile .user-edit-row {
  display: block;
}

body.layout-mobile .users-table table,
body.layout-mobile .users-table thead {
  display: none;
}

body.layout-mobile .users-table tbody {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

body.layout-mobile .users-table tr {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

body.layout-mobile .users-table td {
  display: block;
  border: none;
  padding: 0;
}

body.layout-mobile .users-table .user-edit {
  padding: 0.85rem;
}

body.layout-mobile.sheet-page {
  padding: 0.75rem;
}

body.layout-mobile .assign-sheet {
  width: 100%;
  aspect-ratio: auto;
  overflow-x: auto;
}
