* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #3157f6;
  --primary-dark: #2344cd;
  --warning: #f59e0b;
  --danger: #dc2626;
  --success: #059669;
  --sidebar: #111827;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 255px 1fr;
}

.sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 36px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #3157f6, #0ea5e9);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
}

.brand p {
  margin: 3px 0 0;
  color: #9ca3af;
  font-size: 12px;
}

.brand-dark h1 {
  color: var(--text);
}

.brand-dark p {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.account-card {
  margin-top: auto;
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  display: grid;
  gap: 5px;
  font-size: 12px;
}

.account-card span {
  color: #9ca3af;
}

.account-card button {
  border: 0;
  background: transparent;
  color: #93c5fd;
  padding: 8px 0 0;
  text-align: left;
  font-weight: 700;
}

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

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

.topbar h2 {
  margin: 4px 0 0;
  font-size: 28px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 11px;
  font-weight: 800;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  font-weight: 700;
  transition: 0.2s ease;
}

.btn-primary {
  color: #fff;
  background: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-danger {
  background: #fee2e2;
  color: #991b1b;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.stat-card strong {
  font-size: 34px;
}

.stat-card.warning strong {
  color: var(--warning);
}

.content-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.panel-head h3,
.modal h3 {
  margin: 5px 0 0;
  font-size: 20px;
}

.location-summary,
.activity-list,
.mini-table {
  display: grid;
  gap: 10px;
}

.location-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 13px 14px;
  background: #f8fafc;
  border-radius: 12px;
}

.location-row strong {
  font-size: 18px;
}

.activity-item {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-item strong {
  display: block;
  margin-bottom: 4px;
}

.activity-item span {
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  margin-bottom: 16px;
}

.inventory-toolbar {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(240px, 340px);
  gap: 14px;
  align-items: end;
}

.toolbar-field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #374151;
  font-size: 12px;
  font-weight: 800;
}

.search-field {
  width: 100%;
}

.filter-field {
  width: 100%;
  justify-self: end;
}

.search-control {
  position: relative;
  min-width: 0;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 21px;
  line-height: 1;
  pointer-events: none;
}

.search-control input {
  padding-left: 43px;
  font-size: 15px;
}

.search-control input::placeholder {
  color: #7c8799;
  opacity: 1;
}

.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.section-toolbar h3 {
  margin: 0;
  font-size: 18px;
}

.section-toolbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  color: var(--text);
}

.inventory-toolbar input,
.inventory-toolbar select {
  height: 48px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(49, 87, 246, 0.12);
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

th,
td {
  text-align: left;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td {
  font-size: 14px;
}

.material-name {
  font-weight: 800;
}

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

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  margin: 2px 4px 2px 0;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 700;
}

.badge.low {
  background: #fff7ed;
  color: #c2410c;
}

.badge.active {
  background: #dcfce7;
  color: #166534;
}

.badge.paused {
  background: #fef3c7;
  color: #92400e;
}

.badge.completed {
  background: #e5e7eb;
  color: #374151;
}

.badge.location-type.depot {
  background: #e0e7ff;
  color: #3730a3;
}

.badge.location-type.van {
  background: #e0f2fe;
  color: #0369a1;
}

.badge.location-type.other {
  background: #f3e8ff;
  color: #7e22ce;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-action {
  border: 0;
  background: #eef2ff;
  color: var(--primary);
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 700;
}

.table-action.edit {
  background: #ecfeff;
  color: #0e7490;
}

.table-action.delete {
  background: #fef2f2;
  color: #b91c1c;
}

.mini-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f8fafc;
  align-items: center;
}

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

.project-card,
.location-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.project-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.project-card h3,
.location-card h3 {
  margin: 0 0 8px;
}

.project-card p,
.location-card p {
  color: var(--muted);
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.5;
}

.project-actions {
  display: flex;
  gap: 7px;
  margin-top: 14px;
}

.location-card.inactive {
  opacity: 0.72;
}

.location-card-head > div {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.location-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-weight: 900;
  background: #eef2ff;
  color: #3730a3;
}

.location-icon.van {
  background: #e0f2fe;
  color: #0369a1;
}

.location-icon.other {
  background: #f3e8ff;
  color: #7e22ce;
}

.location-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 15px;
}

.location-stats > div {
  padding: 12px;
  border-radius: 12px;
  background: #f8fafc;
  display: grid;
  gap: 4px;
}

.location-stats span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 800;
}

.location-stats strong {
  font-size: 17px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.hidden {
  display: none !important;
}

.modal {
  width: min(780px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  padding: 26px;
  position: relative;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: 0;
  background: #f3f4f6;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 22px;
}

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

.form-grid label,
.login-form label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

.full {
  grid-column: 1 / -1;
}

.form-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin-top: -4px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 26px 10px;
}

.toast {
  position: fixed;
  right: 25px;
  top: 24px;
  z-index: 50;
  max-width: 420px;
  padding: 13px 16px;
  border-radius: 12px;
  color: #fff;
  background: #111827;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at top left, #dbeafe, transparent 40%), var(--bg);
}

.login-card {
  width: min(430px, 100%);
  background: #fff;
  border-radius: 22px;
  padding: 30px;
  box-shadow: 0 25px 70px rgba(15, 23, 42, 0.16);
}

.login-card h2 {
  margin: 8px 0;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.login-form .btn {
  margin-top: 4px;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-top: 16px;
}

.alert.error {
  background: #fef2f2;
  color: #991b1b;
}

@media (max-width: 1100px) {
  .project-grid,
  .location-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .account-card {
    margin-top: 20px;
  }

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

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

@media (max-width: 760px) {
  .inventory-toolbar {
    grid-template-columns: 1fr;
  }

  .filter-field {
    justify-self: stretch;
  }

  .section-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .section-toolbar .btn {
    width: 100%;
  }
}

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

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

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    flex: 1;
  }

  .stats-grid,
  .project-grid,
  .location-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .full {
    grid-column: auto;
  }

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

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

  .toast {
    left: 14px;
    right: 14px;
    top: 14px;
  }
}

/* v1.3 stock updates, project progress, and reports */
.stats-grid-five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.table-action.adjust {
  background: #ecfdf5;
  color: #047857;
}

.table-action.progress-action {
  background: #eef2ff;
  color: #3730a3;
}

.table-action.report-action {
  background: #fff7ed;
  color: #c2410c;
}

.badge.movement-purchase {
  background: #dcfce7;
  color: #166534;
}

.badge.movement-adjustment {
  background: #fef3c7;
  color: #92400e;
}

.badge.movement-transfer {
  background: #e0e7ff;
  color: #3730a3;
}

.stock-current {
  padding: 12px 14px;
  border-radius: 10px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 800;
}

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

.project-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.project-materials {
  margin-top: 12px;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}

.progress-header strong {
  color: var(--primary);
  font-size: 16px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
  margin-top: 7px;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3157f6, #0ea5e9);
  transition: width 0.25s ease;
}

.project-log-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.project-log-title span {
  color: var(--muted);
}

.timeline {
  display: grid;
  gap: 0;
  margin-top: 10px;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 10px;
  padding-bottom: 14px;
}

.timeline-item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 13px;
  bottom: 0;
  width: 2px;
  background: #dbeafe;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border: 3px solid #bfdbfe;
  border-radius: 50%;
  background: var(--primary);
  z-index: 1;
}

.timeline-content {
  min-width: 0;
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.timeline-head > div {
  min-width: 0;
}

.timeline-head strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
}

.timeline-head span:not(.progress-pill) {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}

.progress-pill {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  color: #3730a3;
  background: #eef2ff;
  font-size: 11px;
  font-weight: 900;
}

.timeline-content p {
  margin: 6px 0 0;
  color: #475569;
  font-size: 12px;
  line-height: 1.45;
}

.timeline-actions {
  display: flex;
  gap: 9px;
  margin-top: 6px;
}

.timeline-actions button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
}

.timeline-actions button.danger-link {
  color: var(--danger);
}

.project-empty-log {
  padding: 12px;
  border-radius: 10px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.project-actions-wrap {
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 15px;
}

.report-builder {
  max-width: 980px;
}

.report-intro {
  max-width: 780px;
  color: var(--muted);
  line-height: 1.6;
}

.report-form {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(170px, 0.8fr) minmax(170px, 0.8fr) auto;
  gap: 14px;
  align-items: end;
  margin-top: 22px;
}

.report-form label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  font-weight: 800;
  color: #374151;
}

.report-form input,
.report-form select,
.report-form .btn {
  height: 48px;
}

.report-project-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.report-project-summary:empty {
  display: none;
}

.report-project-summary > div {
  padding: 15px;
  border-radius: 12px;
  background: #f8fafc;
  display: grid;
  gap: 6px;
}

.report-project-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.report-project-summary strong {
  font-size: 18px;
  text-transform: capitalize;
}

@media (max-width: 1250px) {
  .stats-grid-five {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

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

  .report-project-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .project-grid,
  .stats-grid-five {
    grid-template-columns: 1fr;
  }

  .report-form {
    grid-template-columns: 1fr;
  }

  .report-form .btn {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .report-project-summary {
    grid-template-columns: 1fr;
  }

  .timeline-head {
    flex-direction: column;
  }
}

/* v1.4 roles, assignments and worker field interface */
.role-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  background: #e2e8f0;
  color: #334155;
}

.role-administrator { background: #ede9fe; color: #6d28d9; }
.role-project_manager { background: #dbeafe; color: #1d4ed8; }
.role-engineer { background: #cffafe; color: #0e7490; }
.role-worker { background: #dcfce7; color: #15803d; }

.account-card .role-badge {
  margin: 7px 0 3px;
}

.permission-note {
  margin-top: 14px;
  padding: 16px 18px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #eff6ff;
  color: #334155;
  line-height: 1.55;
  font-size: 13px;
}

.assignment-field {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 15px;
  background: #f8fafc;
}

.assignment-field-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.assignment-field-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.worker-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  max-height: 230px;
  overflow-y: auto;
}

.worker-option {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 10px !important;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.worker-option input {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
}

.worker-option span {
  display: grid;
  gap: 2px;
}

.worker-option small {
  color: var(--muted);
  font-weight: 500;
}

.compact-empty {
  padding: 15px;
  grid-column: 1 / -1;
}

.project-assignees {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.project-assignees > strong {
  color: #475569;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.worker-badge {
  background: #dcfce7;
  color: #166534;
}

.worker-body {
  min-height: 100vh;
  background: #eef2f7;
}

.worker-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px max(18px, calc((100vw - 1280px) / 2));
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.worker-brand,
.worker-account {
  display: flex;
  align-items: center;
  gap: 11px;
}

.worker-brand > div:last-child,
.worker-account > div {
  display: grid;
  gap: 2px;
}

.worker-brand strong {
  font-size: 18px;
}

.worker-brand span,
.worker-account span {
  color: var(--muted);
  font-size: 12px;
}

.worker-account {
  text-align: right;
}

.worker-main {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 60px;
}

.worker-hero {
  position: relative;
  overflow: hidden;
  padding: 30px;
  border-radius: 22px;
  background: linear-gradient(135deg, #111827, #1d4ed8);
  color: #fff;
  box-shadow: var(--shadow);
}

.worker-hero::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  right: -90px;
  top: -120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .09);
}

.worker-hero .eyebrow {
  color: #bfdbfe;
}

.worker-hero h1 {
  margin: 7px 0 8px;
  font-size: clamp(30px, 5vw, 48px);
}

.worker-hero > p:last-of-type {
  max-width: 650px;
  margin: 0;
  color: #dbeafe;
  line-height: 1.6;
}

.worker-stats {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.worker-stats > div {
  min-width: 160px;
  padding: 13px 16px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 13px;
  background: rgba(255,255,255,.09);
  display: grid;
  gap: 3px;
}

.worker-stats span {
  color: #bfdbfe;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.worker-stats strong {
  font-size: 25px;
}

.worker-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(330px, .8fr);
  gap: 18px;
  align-items: start;
  margin-top: 20px;
}

.worker-report-panel {
  position: sticky;
  top: 92px;
}

.worker-report-panel h2,
.worker-side h2 {
  margin: 4px 0 0;
}

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

.worker-report-form label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.worker-report-form input,
.worker-report-form select,
.worker-report-form textarea {
  min-height: 49px;
  font-size: 16px;
}

.worker-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.progress-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px 18px;
  gap: 10px;
  align-items: center;
}

.progress-input-row input[type="range"] {
  min-height: auto;
  padding: 0;
}

.progress-input-row input[type="number"] {
  text-align: center;
  font-weight: 800;
}

.worker-project-hint {
  padding: 12px 14px;
  border-radius: 10px;
  background: #eff6ff;
  color: #1e40af;
  font-size: 13px;
  line-height: 1.5;
}

.worker-submit {
  min-height: 52px;
  font-size: 16px;
}

.worker-side {
  display: grid;
  gap: 18px;
}

.worker-project-cards,
.worker-recent-reports {
  display: grid;
  gap: 10px;
}

.worker-project-card {
  width: 100%;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  text-align: left;
  color: var(--text);
}

.worker-project-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 8px 24px rgba(37, 99, 235, .08);
}

.worker-project-card > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.worker-project-card > div:first-child span,
.worker-project-card small {
  color: var(--muted);
  text-transform: capitalize;
}

.worker-report-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.worker-report-item > div {
  display: grid;
  gap: 3px;
}

.worker-report-item > div span,
.worker-report-item small {
  color: var(--muted);
  font-size: 12px;
}

.worker-report-item small {
  grid-column: 1 / -1;
}

@media (max-width: 900px) {
  .worker-layout {
    grid-template-columns: 1fr;
  }

  .worker-report-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .worker-header {
    align-items: flex-start;
    padding: 12px 14px;
  }

  .worker-account > div {
    display: none;
  }

  .worker-main {
    width: min(100% - 20px, 1280px);
    padding-top: 12px;
  }

  .worker-hero {
    padding: 22px 18px;
    border-radius: 17px;
  }

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

  .worker-stats > div {
    min-width: 0;
    padding: 11px;
  }

  .worker-form-row,
  .worker-picker {
    grid-template-columns: 1fr;
  }

  .progress-input-row {
    grid-template-columns: 1fr 72px 15px;
  }
}

/* v1.5: bilingual controls, photos and shared work categories */
.language-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  gap: 2px;
}
.language-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 800;
}
.language-switch button.active {
  background: var(--primary);
  color: #fff;
}
.login-language {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 5;
}
.password-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
}
.password-field input {
  border-radius: 10px 0 0 10px;
}
.password-toggle {
  border: 1px solid var(--line);
  border-left: 0;
  background: #f8fafc;
  border-radius: 0 10px 10px 0;
  padding: 0 13px;
  min-width: 108px;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
}
.image-upload-field input[type="file"] {
  padding: 9px;
  background: #f8fafc;
}
.image-preview-grid,
.timeline-images,
.worker-report-images {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.image-preview-grid {
  min-height: 0;
}
.image-preview-card {
  width: 112px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #f8fafc;
}
.image-preview-card img {
  display: block;
  width: 112px;
  height: 84px;
  object-fit: cover;
}
.image-preview-card span {
  display: block;
  padding: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10px;
  color: var(--muted);
}
.image-preview-card button {
  position: absolute;
  top: 5px;
  right: 5px;
  border: 0;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: rgba(15, 23, 42, .84);
  color: #fff;
  font-size: 17px;
  line-height: 1;
}
.image-preview-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0;
}
.material-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
}
.material-thumb {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f8fafc;
}
.material-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.material-thumb.placeholder {
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
  color: var(--primary);
  background: #eef2ff;
}
.timeline-images {
  margin: 10px 0 4px;
}
.timeline-images img,
.worker-report-images img {
  width: 76px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
}
.worker-report-images {
  grid-column: 1 / -1;
  margin-top: 7px;
}
.category-manager {
  margin-bottom: 18px;
}
.category-manager .panel-head p:last-child {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.category-form {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.category-form input {
  flex: 1;
}
.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 7px 10px 7px 12px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
}
.category-chip button {
  border: 0;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: #991b1b;
  background: #fee2e2;
  font-weight: 900;
}
.worker-account .language-switch {
  margin-right: 8px;
}

@media (max-width: 640px) {
  .language-switch button { padding: 6px 8px; }
  .worker-account { gap: 7px; }
  .worker-account > div:not(.language-switch) span { display: none; }
  .password-field { grid-template-columns: minmax(0, 1fr) auto; }
  .password-toggle { min-width: 84px; padding: 0 8px; }
  .category-form { flex-direction: column; }
  .image-preview-card, .image-preview-card img { width: 96px; }
  .image-preview-card img { height: 72px; }
}

/* v1.6: mobile responsiveness and touch ergonomics */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
}

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

button,
.btn,
.table-action,
.nav-item {
  min-height: 44px;
}

.table-scroll {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

.modal {
  overscroll-behavior: contain;
}

@media (hover: none) {
  .btn-primary:hover,
  .worker-project-card:hover {
    transform: none;
  }
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: auto;
    padding: 10px 12px 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand account"
      "nav nav";
    gap: 8px 12px;
    box-shadow: 0 8px 26px rgba(15, 23, 42, 0.22);
  }

  .brand {
    grid-area: brand;
    min-width: 0;
    margin: 0;
    gap: 9px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    flex: 0 0 38px;
  }

  .brand h1 {
    font-size: 17px;
  }

  .brand p {
    display: none;
  }

  .nav {
    grid-area: nav;
    display: flex;
    gap: 5px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    padding: 0 0 2px;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    min-height: 40px;
    white-space: nowrap;
    scroll-snap-align: center;
    padding: 9px 12px;
    font-size: 13px;
  }

  .account-card {
    grid-area: account;
    margin: 0;
    padding: 0;
    border: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    white-space: nowrap;
  }

  .account-card > span:first-child {
    display: none;
  }

  .account-card strong {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .account-card .role-badge {
    margin: 0;
  }

  .account-card form,
  .account-card button {
    margin: 0;
  }

  .account-card button {
    min-height: 38px;
    padding: 6px 8px;
  }

  .main {
    padding-top: 22px;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 18px 12px 28px;
  }

  .topbar {
    margin-bottom: 18px;
  }

  .topbar h2 {
    font-size: clamp(23px, 7vw, 28px);
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
    align-items: stretch;
  }

  .topbar-actions .language-switch {
    flex: 0 0 auto;
  }

  .topbar-actions .btn {
    flex: 1 1 140px;
  }

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

  .stat-card {
    min-width: 0;
    padding: 15px;
    border-radius: 14px;
  }

  .stat-card strong {
    font-size: clamp(25px, 8vw, 33px);
  }

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

  .panel-head {
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
  }

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

  .inventory-toolbar {
    gap: 10px;
  }

  .inventory-toolbar input,
  .inventory-toolbar select {
    height: 50px;
  }

  .search-control input {
    font-size: 16px;
  }

  /* Dense desktop tables become readable cards on phones and small tablets. */
  .table-panel {
    padding: 0;
    overflow: visible;
    background: transparent;
    box-shadow: none;
  }

  .table-scroll {
    overflow: visible;
  }

  .responsive-table {
    min-width: 0;
    display: block;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table tbody {
    display: grid;
    gap: 12px;
  }

  .responsive-table tr {
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  }

  .responsive-table td {
    display: grid;
    grid-template-columns: minmax(100px, 34%) minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    padding: 11px 13px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }

  .responsive-table td:last-child {
    border-bottom: 0;
  }

  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.35;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  .responsive-table td.table-empty-cell {
    display: block;
    padding: 28px 14px;
  }

  .responsive-table td.table-empty-cell::before {
    content: none;
  }

  .responsive-table .action-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .responsive-table .table-action {
    width: 100%;
    padding: 9px 8px;
  }

  .material-cell {
    align-items: flex-start;
  }

  .project-actions,
  .project-actions-wrap {
    flex-wrap: wrap;
  }

  .project-actions .table-action,
  .project-actions-wrap .table-action {
    flex: 1 1 120px;
  }

  .assignment-field-head {
    flex-direction: column;
    gap: 4px;
  }

  .category-chip {
    max-width: 100%;
  }

  .report-builder,
  .category-manager {
    overflow: hidden;
  }
}

@media (max-width: 640px) {
  .sidebar {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .account-card strong,
  .account-card .role-badge {
    display: none;
  }

  .account-card button {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 9px;
    padding: 6px 9px;
  }

  .main {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }

  .topbar {
    gap: 14px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .topbar-actions .btn {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }

  .location-row {
    align-items: start;
  }

  .location-row strong {
    font-size: 16px;
  }

  .modal-backdrop {
    place-items: end center;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 96dvh;
    border-radius: 20px 20px 0 0;
    padding: 22px 14px max(18px, env(safe-area-inset-bottom));
  }

  .modal-close {
    position: sticky;
    z-index: 3;
    top: 0;
    margin-left: auto;
    display: grid;
    place-items: center;
  }

  .modal-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 4px -2px -2px;
    padding: 12px 2px 2px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, .82), #fff 24%);
  }

  .modal-actions .btn {
    flex: 1 1 0;
    min-width: 0;
  }

  .form-grid {
    gap: 13px;
  }

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

  .image-preview-grid,
  .timeline-images,
  .worker-report-images {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
  }

  .image-preview-card,
  .timeline-images a,
  .worker-report-images a {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  .login-body {
    align-items: start;
    padding: 74px 12px max(20px, env(safe-area-inset-bottom));
  }

  .login-language {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }

  .login-card {
    padding: 24px 18px;
    border-radius: 18px;
  }

  .login-card .brand {
    display: flex;
  }

  .worker-header {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 62px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .worker-brand > div:last-child {
    display: none;
  }

  .worker-account form .btn {
    min-height: 40px;
    padding: 8px 10px;
  }

  .worker-main {
    width: min(100% - 20px, 1280px);
    padding-bottom: max(30px, env(safe-area-inset-bottom));
  }

  .worker-hero h1 {
    font-size: clamp(27px, 9vw, 38px);
  }

  .worker-report-panel,
  .worker-side .panel {
    padding: 16px;
  }

  .worker-submit {
    width: 100%;
    min-height: 52px;
    font-size: 16px;
  }

  .worker-project-card {
    min-height: 48px;
  }

  .worker-report-item {
    overflow: hidden;
  }
}

@media (max-width: 430px) {
  .topbar-actions {
    grid-template-columns: auto 1fr;
  }

  .topbar-actions #openAddBtn {
    grid-column: 1 / -1;
  }

  .responsive-table td {
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 9px;
    padding: 10px 11px;
  }

  .responsive-table .action-group {
    grid-template-columns: 1fr;
  }

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

  .worker-stats strong {
    font-size: 22px;
  }

  .progress-input-row {
    grid-template-columns: minmax(0, 1fr) 66px 14px;
    gap: 7px;
  }
}

@media (max-width: 360px) {
  .stats-grid,
  .stats-grid-five,
  .worker-stats {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    grid-template-columns: 1fr 1fr;
  }

  .topbar-actions .language-switch {
    grid-column: 1 / -1;
    width: fit-content;
  }

  .responsive-table td {
    grid-template-columns: 1fr;
  }

  .responsive-table td::before {
    margin-bottom: -4px;
  }
}

/* v1.6 audit refinements */
.modal-backdrop {
  z-index: 100;
}

input[type="file"]::file-selector-button {
  min-height: 38px;
  margin-right: 10px;
  border: 0;
  border-radius: 8px;
  padding: 8px 11px;
  background: #e8edff;
  color: var(--primary);
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 760px) {
  .stats-grid-five > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .worker-account > .language-switch {
    display: inline-flex !important;
    margin-right: 0;
  }
}

@media (max-width: 430px) {
  .responsive-table td {
    grid-template-columns: 100px minmax(0, 1fr);
  }
}

@media (max-width: 360px) {
  .stats-grid-five > :last-child:nth-child(odd) {
    grid-column: auto;
  }
}
