:root {
  color-scheme: light;
  --blue: #0057ad;
  --blue-dark: #003b7a;
  --ink: #0d1b2f;
  --muted: #5b6b82;
  --line: #d8e1ec;
  --soft: #f4f7fb;
  --card: #ffffff;
  --green: #16813b;
  --orange: #b65c00;
  --red: #b42318;
  --shadow: 0 18px 40px rgba(15, 42, 74, 0.13);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--soft);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.mobile-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  background: linear-gradient(180deg, #ffffff 0%, #f3f7fc 100%);
}

.mobile-login,
.mobile-boot {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 28px;
}

.boot-card {
  display: grid;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.boot-card strong {
  font-size: 1.35rem;
}

.boot-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--blue);
  font-size: 1.2rem;
  font-weight: 800;
}

.brand-lockup img {
  width: 132px;
  height: auto;
}

.mobile-login h1,
.mobile-header h1 {
  margin: 0;
  font-size: clamp(2rem, 9vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
}

.mobile-login p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.mobile-form {
  display: grid;
  gap: 14px;
}

.mobile-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.mobile-form input,
.search-box input {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
}

.primary-button,
.ghost-button,
.icon-button,
.bottom-nav a,
.bottom-nav button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(0, 87, 173, 0.25);
}

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

.form-error {
  padding: 12px;
  border: 1px solid #f2b8ac;
  border-radius: 8px;
  color: var(--red);
  background: #fff7f5;
}

.mobile-app {
  min-height: 100vh;
  padding: 18px 16px 96px;
}

.mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 16px;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-weight: 800;
}

.icon-button {
  width: 52px;
  background: var(--blue);
  color: #fff;
  font-size: 1.35rem;
}

.status-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.connection-pill,
.sync-notice,
.filter-chip {
  white-space: nowrap;
  border-radius: 999px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 800;
}

.connection-pill.online {
  color: var(--green);
  background: #eaf8ef;
}

.connection-pill.offline {
  color: var(--orange);
  background: #fff3df;
}

.sync-notice {
  color: var(--muted);
  background: #e9eef6;
}

.offline-sync-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #f5d08c;
  border-radius: 8px;
  background: #fff8e8;
}

.offline-sync-panel strong {
  color: var(--orange);
}

.offline-sync-panel p {
  margin: 3px 0 0;
  color: var(--muted);
  line-height: 1.3;
}

.offline-sync-panel .ghost-button {
  min-height: 40px;
  padding: 0 12px;
  white-space: nowrap;
}

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

.summary-grid article,
.assignment-card,
.detail-panel,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 8px 22px rgba(15, 42, 74, 0.07);
}

.summary-grid article {
  padding: 14px;
}

.summary-grid small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.summary-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.8rem;
}

.quick-filter {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 16px 0 10px;
}

.filter-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.filter-chip.active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.assignment-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.assignment-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

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

.assignment-card h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.2;
}

.assignment-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.state-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--blue-dark);
  background: #eaf2ff;
  font-size: 0.78rem;
  font-weight: 800;
}

.state-chip.done {
  color: var(--green);
  background: #eaf8ef;
}

.state-chip.warn {
  color: var(--orange);
  background: #fff3df;
}

.state-chip.danger {
  color: var(--red);
  background: #fff0ed;
}

.state-chip.syncing {
  color: var(--blue);
  background: #eaf2ff;
}

.state-chip.error {
  color: var(--red);
  background: #fff0ed;
}

.card-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

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

.card-actions button {
  min-height: 48px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  color: var(--blue);
  background: #fff;
  font-weight: 800;
}

.empty-state {
  margin-top: 18px;
  padding: 22px;
  text-align: center;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
}

.detail-panel {
  position: fixed;
  left: 50%;
  right: 0;
  bottom: 0;
  z-index: 20;
  width: min(100%, 520px);
  max-height: 86vh;
  transform: translateX(-50%);
  overflow: auto;
  padding: 18px;
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow);
}

.detail-type {
  display: inline-block;
  margin-top: 14px;
  color: var(--blue);
  font-weight: 800;
}

.detail-panel h2 {
  margin: 8px 0 14px;
}

.detail-panel dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-panel div {
  display: grid;
  gap: 4px;
}

.detail-panel dt {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.detail-panel dd {
  margin: 0;
}

.detail-description {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.activity-location-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #bdd7f4;
  border-radius: 8px;
  background: #eef6ff;
}

.activity-location-panel h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.activity-location-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.detail-actions,
.report-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}

.report-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.report-panel h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

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

.report-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.report-form input,
.report-form select,
.report-form textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  resize: vertical;
}

.attendance-panel,
.consumption-panel,
.sample-panel,
.issue-panel,
.evidence-panel,
.issue-evidence-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.attendance-header,
.consumption-header,
.sample-header,
.issue-header,
.evidence-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.attendance-header h3,
.consumption-header h3,
.sample-header h3,
.issue-header h3,
.evidence-header h4 {
  margin: 0;
  font-size: 1rem;
}

.attendance-header p,
.attendance-empty,
.consumption-header p,
.consumption-empty,
.sample-header p,
.sample-empty,
.issue-header p,
.issue-empty,
.evidence-header p,
.evidence-help,
.evidence-empty {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.attendance-module-panel {
  background: #fff;
}

.attendance-assignment-picker {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.attendance-assignment-picker select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

.attendance-count,
.consumption-count,
.sample-count,
.issue-count,
.evidence-count {
  display: inline-grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  color: var(--blue);
  background: #eaf2ff;
  font-weight: 900;
}

.attendance-form,
.consumption-form,
.sample-form,
.issue-form {
  display: grid;
  gap: 12px;
}

.attendance-form[hidden],
.consumption-form[hidden],
.sample-form[hidden],
.issue-form[hidden] {
  display: none;
}

.attendance-form label,
.consumption-form label,
.sample-form label,
.issue-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.attendance-form input,
.attendance-form select,
.attendance-form textarea,
.consumption-form input,
.consumption-form select,
.consumption-form textarea,
.sample-form input,
.sample-form select,
.sample-form textarea,
.issue-form input,
.issue-form select,
.issue-form textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  resize: vertical;
}

.sample-field-data {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #cfe0f7;
  border-radius: 14px;
  background: #f7fbff;
}

.sample-field-data h4 {
  margin: 0;
  font-size: 15px;
}

.sample-field-data p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.sample-field-note {
  padding: 10px 12px;
  border-radius: 12px;
  background: #eef6ff;
  color: #1d4f91;
  font-weight: 800;
}

.attendance-time-grid,
.consumption-amount-grid,
.attendance-quick-actions,
.attendance-gps-actions,
.consumption-actions,
.sample-depth-grid,
.attendance-actions,
.sample-actions,
.issue-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.attendance-list,
.consumption-list,
.sample-list,
.issue-list {
  display: grid;
  gap: 10px;
}

.attendance-card,
.consumption-card,
.sample-card,
.issue-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.attendance-card header,
.consumption-card header,
.sample-card header,
.issue-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.attendance-card strong,
.consumption-card strong,
.sample-card strong,
.issue-card strong {
  overflow-wrap: anywhere;
}

.attendance-card p,
.attendance-card small,
.consumption-card p,
.consumption-card small,
.sample-card p,
.sample-card small,
.issue-card p,
.issue-card small {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.attendance-card-actions,
.consumption-card-actions,
.sample-card-actions,
.issue-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attendance-card-actions button,
.consumption-card-actions button,
.sample-card-actions button,
.issue-card-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--blue);
  background: #fff;
  font-weight: 800;
}

.attendance-card-actions button[data-delete-attendance],
.consumption-card-actions button[data-delete-consumption],
.sample-card-actions button[data-delete-sample] {
  color: var(--red);
}

.issue-card-actions button[data-delete-issue],
.issue-card-actions button[data-close-issue] {
  color: var(--red);
}

.sample-visual-data {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.sample-visual-data h4 {
  margin: 0;
  color: var(--ink);
}

.sample-visual-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.mobile-color-field {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.mobile-color-swatch {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #594630;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.mobile-color-field select {
  min-width: 0;
  width: 100%;
}

.sample-visual-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sample-visual-options label {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7fbff;
  font-weight: 800;
}

.severity-low {
  color: var(--green);
  background: #eaf8ef;
}

.severity-medium {
  color: var(--blue-dark);
  background: #eaf2ff;
}

.severity-high {
  color: var(--orange);
  background: #fff3df;
}

.severity-critical {
  color: var(--red);
  background: #fff0ed;
}

.evidence-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.evidence-list {
  display: grid;
  gap: 10px;
}

.evidence-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.evidence-thumb {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--blue);
  background: #eaf2ff;
  font-weight: 900;
  overflow: hidden;
}

.evidence-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.evidence-info {
  min-width: 0;
}

.evidence-info strong {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.evidence-info span,
.evidence-info small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.85rem;
}

.evidence-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.evidence-card-actions a,
.evidence-card-actions button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--blue);
  background: #fff;
  text-decoration: none;
  font-weight: 800;
}

.sync-panel {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.sync-panel-header {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(15, 42, 74, 0.07);
}

.sync-panel-header h2 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.1;
}

.sync-panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

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

.sync-summary-grid article,
.sync-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(15, 42, 74, 0.07);
}

.sync-summary-grid article {
  padding: 12px;
}

.sync-summary-grid small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.sync-summary-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.55rem;
}

.sync-queue-list {
  display: grid;
  gap: 10px;
}

.sync-item {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.sync-item header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.sync-item strong {
  overflow-wrap: anywhere;
}

.sync-item p,
.sync-item small {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.sync-item-error {
  padding: 10px;
  border: 1px solid #f2b8ac;
  border-radius: 8px;
  color: var(--red);
  background: #fff7f5;
}

.sync-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sync-item-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--blue);
  background: #fff;
  font-weight: 800;
}

.sync-item-actions button[data-discard-queue] {
  color: var(--red);
}

.gps-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.finish {
  background: var(--green);
  box-shadow: 0 10px 22px rgba(22, 129, 59, 0.2);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: min(100%, 520px);
  transform: translateX(-50%);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.bottom-nav a,
.bottom-nav button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  background: #fff;
  font-weight: 800;
}

.bottom-nav .active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.mobile-toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  z-index: 30;
  width: min(calc(100% - 24px), 480px);
  transform: translateX(-50%);
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
}

@media (min-width: 640px) {
  body {
    background: #eaf0f8;
  }

  .mobile-shell {
    min-height: calc(100vh - 32px);
    margin-top: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow);
  }
}

@media (min-width: 440px) {
  .detail-actions,
  .report-actions,
  .sample-depth-grid,
  .sample-actions,
  .issue-actions,
  .gps-grid,
  .evidence-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .gps-grid label:last-child,
  .report-actions .finish,
  .evidence-actions button:last-child {
    grid-column: 1 / -1;
  }
}
