* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(135deg, #f4f7fb 0%, #eef4ff 100%);
  color: #1f2937;
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 28px;
}
.app-shell.narrow {
  max-width: 980px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  padding: 20px 22px;
  border: 1px solid #dbe3ef;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
}
.topbar h1,
.section-head h2,
.section-head h3 {
  margin: 0;
  color: #102a43;
}
.eyebrow {
  color: #2563eb;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.section-head p {
  margin: 5px 0 0;
}
.stats-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
.stat span {
  color: #64748b;
  font-size: 14px;
}
.stat strong {
  font-size: 32px;
  color: #0f172a;
}
.stat.success {
  border-left: 4px solid #10b981;
}
.stat.warning {
  border-left: 4px solid #f59e0b;
}
.stat.neutral {
  border-left: 4px solid #64748b;
}
.table-wrap {
  overflow-x: auto;
}
td small {
  display: block;
  margin-top: 4px;
  color: #64748b;
}
.badge {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.green {
  background: #d1fae5;
  color: #047857;
}
.badge.amber {
  background: #fef3c7;
  color: #b45309;
}
.badge.gray {
  background: #e2e8f0;
  color: #475569;
}
.branch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.branch-panel {
  min-width: 0;
}
.branch-code {
  color: #1d4ed8;
  background: #eff6ff;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
}
.stack {
  display: grid;
  gap: 18px;
}
.toolbar {
  display: grid;
  grid-template-columns: 1fr minmax(190px, 280px) auto;
  gap: 12px;
  margin-bottom: 18px;
}
.notice {
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 10px;
  color: #991b1b;
  background: #fee2e2;
}
.empty {
  padding: 28px;
  text-align: center;
  color: #64748b;
}
.compact-input {
  max-width: 320px;
}
.modal-card {
  max-width: 760px !important;
  max-height: 90vh;
  overflow: auto;
}
.modal-card.compact-modal {
  max-width: 620px !important;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}
.form-grid .hidden {
  display: none;
}
.form-actions {
  grid-column: 1/-1;
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}
.full-field {
  grid-column: 1/-1;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  font-size: 24px;
  cursor: pointer;
}
.qr-card,
.scan-card {
  text-align: center;
  padding: 32px;
}
.qr-frame {
  width: min(100%, 390px);
  aspect-ratio: 1;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border: 1px solid #dbeafe;
  border-radius: 22px;
  background: #f8fafc;
}
.qr-frame img {
  width: 90%;
  height: 90%;
  object-fit: contain;
}
.countdown {
  font-size: 20px;
  font-weight: 800;
  color: #1d4ed8;
  margin: 12px 0;
}
.scan-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 40px;
}
.permission-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.permission-group {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
}
.permission-group legend {
  padding: 0 7px;
  font-weight: 800;
  color: #1e3a8a;
  text-transform: capitalize;
}
.permission-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 4px;
  cursor: pointer;
}
.permission-item input {
  width: auto;
  margin-top: 3px;
}
.permission-item strong,
.permission-item small {
  display: block;
}
.permission-item small {
  color: #64748b;
  margin-top: 2px;
  font-weight: 400;
}
.language-switcher {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
  display: flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
}
.language-switcher button {
  border: 0;
  border-radius: 8px;
  padding: 7px 9px;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.language-switcher button.active {
  color: #fff;
  background: #2563eb;
}
.deduction-control {
  min-width: 150px;
  display: grid;
  gap: 7px;
}
.deduction-control select,
.deduction-control input {
  padding: 7px 8px;
  font-size: 13px;
}
.amount-input {
  position: relative;
}
.amount-input input {
  padding-right: 30px;
}
.amount-input span {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}
.net-pay {
  color: #047857;
  white-space: nowrap;
}
.total-deduction {
  color: #b45309;
  white-space: nowrap;
}
.time-adjust {
  font-weight: 800;
  white-space: nowrap;
}
.time-adjust.positive {
  color: #047857;
}
.time-adjust.negative {
  color: #dc2626;
}
.attendance-alert {
  background: #fee2e2 !important;
  color: #b91c1c;
  font-weight: 800;
}

.weekly-shift-editor {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
}

.permission-static-nav {
  display: none !important;
}

.permission-nav {
  position: relative;
}

.permission-nav summary {
  list-style: none;
  cursor: pointer;
}

.permission-menu-trigger {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.3);
}

.permission-menu-trigger:hover {
  background: linear-gradient(135deg, #6d28d9, #1d4ed8);
}

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

.permission-nav-panel {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: min(390px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(35, 28, 22, 0.18);
}

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

.permission-nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-radius: 11px;
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
}

.permission-nav-item:hover {
  filter: brightness(0.94);
  transform: translateY(-1px);
}

.nav-blue {
  background: #d99a16;
}
.nav-green {
  background: #d99a16;
}
.nav-purple {
  background: #d99a16;
}
.nav-orange {
  background: #d99a16;
}
.nav-cyan {
  background: #d99a16;
}
.nav-pink {
  background: #d99a16;
}
.nav-teal {
  background: #d99a16;
}
.nav-amber {
  background: #d99a16;
}
.nav-danger {
  grid-column: 1 / -1;
  background: #dc2626;
}

.permission-language-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  padding: 8px;
  border-radius: 11px;
  background: #f1f5f9;
}

.permission-menu-control {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 11px;
  color: #713f12;
  background: #fef3c7;
  font-size: 12px;
  font-weight: 900;
}

.permission-menu-control input,
.permission-menu-control select {
  width: 100%;
  border-color: #f2c45d;
  background: #fff;
}

.permission-language-row button {
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.permission-language-row button:nth-child(1) {
  background: #d99a16;
}
.permission-language-row button:nth-child(2) {
  background: #d99a16;
}
.permission-language-row button:nth-child(3) {
  background: #d99a16;
}

.permission-language-row button.active {
  border-color: #0f172a;
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px #0f172a;
}

.language-switcher-in-menu {
  display: none !important;
}

.weekly-shift-grid {
  display: grid;
  gap: 7px;
}

.weekly-shift-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(105px, 0.8fr) auto minmax(105px, 0.8fr);
  gap: 8px;
  align-items: center;
}

.weekly-shift-row label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.weekly-shift-row input[type='checkbox'] {
  width: auto;
}

@media (max-width: 620px) {
  .weekly-shift-row {
    grid-template-columns: 1fr 1fr auto 1fr;
  }
}
.salary-input {
  min-width: 130px;
  padding: 8px;
}
.adjust {
  font-weight: 800;
  white-space: nowrap;
}
.adjust.positive {
  color: #047857;
}
.adjust.negative {
  color: #dc2626;
}
.month-input {
  width: auto;
  min-width: 155px;
}
.salary-branch {
  display: grid;
  gap: 22px;
}
.salary-subgroup {
  border-top: 1px solid #e2e8f0;
  padding-top: 16px;
}
.salary-subgroup h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  color: #1e293b;
}
.salary-subgroup h3 span {
  padding: 4px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 12px;
}
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  color: #102a43;
  text-decoration: none;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0.12em;
}
.site-brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
}
.brand-bar {
  display: flex;
  align-items: center;
  min-height: 74px;
  margin-bottom: 12px;
  padding: 12px 20px;
  border: 1px solid #dbe3ef;
  border-radius: 18px;
  background: linear-gradient(135deg, #ffffff, #f8faff);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
.topbar {
  flex-wrap: wrap;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.h1 {
  font-size: 24px;
  font-weight: 700;
  color: #102a43;
  margin: 0;
}

.card {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  border: 1px solid #e5e7eb;
}

.center {
  text-align: center;
}

.row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.col {
  flex: 1;
  min-width: 220px;
}

.form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  resize: vertical;
  font: inherit;
}
.recipe-category summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
}
.recipe-category summary small {
  display: block;
  color: #64748b;
  margin-top: 4px;
}
.recipe-category-summary-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.recipe-category-arrow {
  padding: 0 4px;
  font-size: 20px;
}
.recipe-category-delete {
  grid-column: auto;
}
.recipe-category-body {
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
  margin-top: 16px;
}
.recipe-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}
.recipe-card {
  display: block;
  padding: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.recipe-card.has-image {
  display: grid;
  grid-template-columns: clamp(220px, 32%, 360px) minmax(0, 1fr);
  align-items: start;
  gap: 20px;
}

.recipe-card-content {
  min-width: 0;
}

.recipe-text-columns {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 20px;
}

.recipe-text-columns p {
  overflow-wrap: anywhere;
  line-height: 1.55;
}
.recipe-card h3,
.recipe-card h4 {
  margin: 0 0 8px;
}

.recipe-image-button {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  background: #eef2f7;
  cursor: zoom-in;
}

.recipe-image-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease;
}

.recipe-image-button:hover img {
  transform: scale(1.025);
}

.recipe-edit-image {
  display: flex;
  align-items: center;
  gap: 16px;
}

.recipe-edit-image img {
  width: 140px;
  height: 100px;
  border-radius: 12px;
  object-fit: cover;
}

.recipe-image-viewer {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  background: rgb(2 6 23 / 96%);
}

.recipe-viewer-toolbar {
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  color: #fff;
  background: rgb(15 23 42 / 88%);
}

.recipe-viewer-stage {
  display: grid;
  flex: 1;
  place-items: center;
  overflow: auto;
  padding: 24px;
}

.recipe-viewer-stage img {
  max-width: 90vw;
  max-height: 82vh;
  object-fit: contain;
  transform-origin: center;
  transition: transform 100ms ease;
}

@media (max-width: 820px) {
  .recipe-card.has-image {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .recipe-image-button {
    width: 100%;
    max-height: 260px;
    aspect-ratio: 16 / 10;
  }

  .recipe-text-columns {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
}

@media (max-width: 640px) {
  .recipe-card .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .recipe-card .section-head .actions,
  .recipe-card .section-head .btn {
    width: 100%;
  }

  .recipe-card .section-head .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .recipe-edit-image {
    align-items: flex-start;
    flex-direction: column;
  }
}
.recipe-card h4 {
  margin-top: 14px;
  color: #2563eb;
}

input:focus,
select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

.btn.secondary {
  background: #f3f4f6;
  color: #374151;
  box-shadow: none;
}

.btn.ghost {
  background: #ffffff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  box-shadow: none;
}

.btn.small {
  padding: 6px 10px;
  font-size: 13px;
}

.muted {
  color: #64748b;
  font-size: 14px;
}

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

.stat {
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  border: 1px solid #e2e8f0;
}

.num {
  font-size: 28px;
  font-weight: 700;
  color: #0f172a;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

th {
  background: #f8fafc;
  color: #334155;
  font-weight: 600;
}

tr:hover {
  background: #f9fbff;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden,
.hidden {
  display: none;
}

.modal .card {
  width: 100%;
  max-width: 480px;
}

@media (max-width: 768px) {
  .container {
    padding: 16px;
  }

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

  .stats {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 16px;
  }
  .topbar {
    flex-direction: column;
  }
  .actions {
    justify-content: flex-start;
  }
  .permission-nav-panel {
    right: auto;
    left: 0;
  }
  .permission-nav-grid {
    grid-template-columns: 1fr;
  }
  .permission-language-row,
  .nav-danger,
  .permission-menu-control {
    grid-column: 1;
  }
  .branch-grid,
  .form-grid,
  .permission-groups {
    grid-template-columns: 1fr;
  }
  .toolbar {
    grid-template-columns: 1fr;
  }
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
.pwa-login-install {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1000;
  box-shadow: 0 10px 28px rgb(15 23 42 / 24%);
}

@media (display-mode: standalone) {
  .pwa-login-install {
    display: none !important;
  }
}

.data-option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.data-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: #f8fafc;
  cursor: pointer;
}

.data-option input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.data-option span,
.data-option small {
  display: block;
}

.data-option small {
  margin-top: 4px;
  color: #64748b;
}

.data-month-only {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

/* Responsive layout shared by every application page. */
@media (max-width: 768px) {
  body {
    overflow-x: hidden;
    background: #f4f7fb;
  }

  .app-shell,
  .container {
    width: 100%;
    padding: 12px;
  }

  .brand-bar {
    min-height: 60px;
    margin-bottom: 10px;
    padding: 9px 12px;
    border-radius: 14px;
  }

  .site-brand {
    gap: 8px;
    font-size: 17px;
  }

  .site-brand img {
    width: 40px;
    height: 40px;
  }

  .topbar {
    gap: 14px;
    margin-bottom: 14px;
    padding: 16px;
    border-radius: 14px;
  }

  .topbar > div,
  .topbar .actions,
  .section-head > div {
    width: 100%;
    min-width: 0;
  }

  .topbar h1 {
    overflow-wrap: anywhere;
    font-size: clamp(22px, 7vw, 28px);
    line-height: 1.15;
  }

  .section-head h2 {
    font-size: 20px;
  }

  .topbar .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .topbar .actions > *,
  .toolbar > *,
  .form-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .topbar .actions > :only-child,
  .topbar .actions > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .btn {
    min-height: 44px;
    padding: 11px 13px;
    touch-action: manipulation;
  }

  .btn.small {
    min-height: 38px;
    padding: 8px 10px;
  }

  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  textarea {
    min-height: 120px;
  }

  .card {
    padding: 15px;
    border-radius: 14px;
  }

  .stack,
  .branch-grid,
  .salary-branch {
    gap: 12px;
  }

  .stats-4,
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .stat {
    min-width: 0;
    padding: 13px;
  }

  .stat strong,
  .num {
    font-size: 24px;
  }

  .compact-input,
  .month-input {
    width: 100%;
    max-width: none;
  }

  .table-wrap {
    width: calc(100% + 15px);
    margin-right: -15px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table {
    min-width: 720px;
    margin-top: 0;
  }

  .salary-subgroup .table-wrap table {
    min-width: 1180px;
  }

  th,
  td {
    padding: 10px 9px;
    font-size: 13px;
    vertical-align: top;
  }

  .table-wrap th:first-child,
  .table-wrap td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 125px;
    background: #fff;
    box-shadow: 1px 0 #e5e7eb;
  }

  .table-wrap th:first-child {
    z-index: 2;
    background: #f8fafc;
  }

  .table-wrap td .actions {
    flex-wrap: nowrap;
  }

  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal .card,
  .modal-card,
  .modal-card.compact-modal {
    width: 100%;
    max-width: none !important;
    max-height: calc(100dvh - 16px);
    padding: 16px;
    overflow-y: auto;
    border-radius: 18px 18px 0 0;
  }

  .modal .section-head {
    position: sticky;
    z-index: 4;
    top: -16px;
    align-items: center;
    flex-direction: row;
    padding: 12px 0;
    background: #fff;
  }

  .modal .section-head > div {
    width: auto;
    flex: 1;
  }

  .modal .section-head .icon-btn {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
  }

  .form-grid,
  .permission-groups {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-actions {
    position: sticky;
    bottom: -16px;
    z-index: 3;
    padding: 12px 0 16px;
    background: linear-gradient(to bottom, rgb(255 255 255 / 70%), #fff 30%);
  }

  .weekly-shift-row {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    padding: 10px 0;
    border-bottom: 1px solid #e2e8f0;
  }

  .weekly-shift-row label {
    grid-column: 1 / -1;
  }

  .weekly-shift-row input[type='time'] {
    min-width: 0;
  }

  .permission-nav {
    width: 100%;
  }

  .permission-nav > summary,
  .permission-menu-trigger {
    width: 100%;
  }

  .permission-nav-panel {
    position: fixed;
    inset: auto 10px 10px;
    width: auto;
    max-height: min(72dvh, 620px);
    overflow-y: auto;
    padding: 10px;
    border-radius: 16px;
  }

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

  .permission-language-row,
  .permission-menu-control,
  .nav-danger {
    grid-column: 1 / -1;
  }

  .permission-nav-item {
    min-height: 46px;
    padding: 9px;
  }

  .qr-card,
  .scan-card {
    padding: 20px 14px;
  }

  .qr-frame {
    width: min(100%, 330px);
    border-radius: 16px;
  }

  .recipe-category summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .recipe-category-summary-actions {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    width: 100%;
  }

  .recipe-viewer-toolbar {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .recipe-viewer-toolbar > * {
    flex: 0 0 auto;
  }

  .recipe-viewer-stage {
    padding: 10px;
  }

  .data-option-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
  }

  .data-option {
    padding: 13px;
  }

  .language-switcher,
  .pwa-login-install {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .app-shell,
  .container {
    padding: 9px;
  }

  .topbar,
  .card {
    padding: 13px;
  }

  .stats-4,
  .stats {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar .actions,
  .permission-nav-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar .actions > *,
  .topbar .actions > :last-child:nth-child(odd),
  .permission-language-row,
  .permission-menu-control,
  .nav-danger {
    grid-column: 1;
  }

  .permission-language-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .recipe-card {
    padding: 12px;
  }

  .recipe-card .section-head .actions {
    grid-template-columns: minmax(0, 1fr);
  }
}
