* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --border: #e5eaf3;
  --border-strong: #d9e1ec;

  --text: #111827;
  --text-soft: #667085;
  --text-muted: #7a8699;

  --neutral-bg: #f3f5f8;
  --neutral-border: #dbe2ea;
  --neutral-text: #344054;

  --primary: #111827;
  --primary-soft: #eef2f7;

  --blue-bg: #e8f1ff;
  --blue-border: #c9ddff;
  --blue-text: #175cd3;

  --green-bg: #eaf8ef;
  --green-border: #ccefd8;
  --green-text: #137333;

  --amber-bg: #fff3e6;
  --amber-border: #ffd8b5;
  --amber-text: #b54708;

  --red-bg: #ffe8e8;
  --red-border: #ffc9c9;
  --red-text: #b42318;

  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-card: 0 10px 28px rgba(15, 23, 42, 0.07);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, #f7f9ff 0%, #f4f6fb 42%, #f2f4f9 100%);
  color: var(--text);
}

/* Top header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.header-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.header button,
.header a.header-btn {
  width: auto;
  min-width: 96px;
  padding: 12px 16px;
  font-size: 18px;
  font-weight: 800;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--primary-soft);
  color: var(--text);
  text-decoration: none;
  text-align: center;
  box-shadow: 0 2px 10px rgba(17, 24, 39, 0.04);
}

/* Main page container */
.container {
  padding: 18px;
  max-width: 760px;
  margin: 0 auto;
}

/* Page titles */
.title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 19px;
  color: var(--text-soft);
  margin-bottom: 18px;
  line-height: 1.5;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
}

.card-accent-blue {
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
  border-color: #dbe8ff;
}

.card-accent-green {
  background: linear-gradient(180deg, #f7fff9 0%, #ffffff 100%);
  border-color: #d9f0df;
}

.card-accent-amber {
  background: linear-gradient(180deg, #fffaf3 0%, #ffffff 100%);
  border-color: #ffe5c2;
}

.section-title {
  font-size: 22px;
  font-weight: 900;
  margin: 0 0 8px 0;
  color: var(--text);
}

.section-subtitle {
  font-size: 16px;
  color: var(--text-soft);
  margin: 0 0 18px 0;
  line-height: 1.5;
}

/* Labels */
label {
  display: block;
  font-size: 21px;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--text);
}

/* Inputs */
input,
select,
textarea {
  width: 100%;
  padding: 18px;
  font-size: 21px;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: #fff;
  margin-bottom: 16px;
  outline: none;
  transition: 0.18s ease;
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #98a2b3;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #94b6ff;
  box-shadow: 0 0 0 4px rgba(23, 92, 211, 0.08);
}

/* Buttons */
button {
  width: 100%;
  padding: 18px;
  font-size: 21px;
  font-weight: 900;
  border-radius: 18px;
  border: none;
  cursor: pointer;
  transition: 0.16s ease;
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.08);
}

button:active {
  transform: scale(0.985);
}

.primary {
  background: linear-gradient(180deg, #111827 0%, #1f2937 100%);
  color: #fff;
}

.secondary {
  background: linear-gradient(180deg, #eef2f7 0%, #e7ecf3 100%);
  color: var(--text);
}

.success-btn {
  background: linear-gradient(180deg, #137333 0%, #0f8a2f 100%);
  color: #fff;
}

.warning-btn {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

/* Button groups */
.grid-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.inline-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.inline-actions > * {
  flex: 1;
  min-width: 140px;
}

/* Links styled as buttons */
a.button-link {
  display: block;
  text-decoration: none;
}

.summary-link {
  color: var(--text);
  font-weight: 800;
  text-decoration: underline;
}

/* Dashboard Summary */
.dashboard-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.summary-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 112px;
  border-radius: 22px;
  padding: 18px;
  border: 1px solid transparent;
  text-decoration: none;
  transition: 0.15s ease;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.summary-link-box:active {
  transform: scale(0.98);
}

.summary-label {
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 10px;
}

.summary-value {
  font-size: 28px;
  font-weight: 900;
  line-height: 1.2;
  word-break: break-word;
}

.summary-total {
  background: #f4f6f9;
  border-color: #dce3ea;
  color: #344054;
}

.summary-present {
  background: #eaf8ef;
  border-color: #ccefd8;
  color: #137333;
}

.summary-scanned {
  background: #e8f1ff;
  border-color: #c9ddff;
  color: #175cd3;
}

.summary-meals {
  background: #fff8ef;
  border-color: #ffe1bf;
  color: #8a4b08;
}

/* Hero / page intro */
.page-hero {
  background: linear-gradient(135deg, #111827 0%, #1f2937 55%, #334155 100%);
  color: #fff;
  border-radius: 28px;
  padding: 24px 22px;
  margin-bottom: 18px;
  box-shadow: 0 16px 36px rgba(17, 24, 39, 0.16);
}

.page-hero .title {
  color: #fff;
  margin-bottom: 8px;
}

.page-hero .subtitle {
  color: rgba(255, 255, 255, 0.82);
  margin-bottom: 0;
}

.hero-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
}

/* Scanner / status cards */
.scanner-shell {
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #101828 0%, #1f2937 100%);
  padding: 16px;
}

.scanner-shell label {
  color: #fff;
}

.scanner-note {
  color: rgba(255, 255, 255, 0.75);
  margin: 10px 0 0;
  font-size: 15px;
}

.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  margin-bottom: 16px;
}

.info-banner strong {
  display: block;
  margin-bottom: 3px;
  font-size: 16px;
}

.info-banner p {
  margin: 0;
  font-size: 15px;
  color: var(--text-soft);
  line-height: 1.5;
}

.info-banner.blue {
  background: #f4f8ff;
  border-color: #dbe8ff;
}

.info-banner.green {
  background: #f5fcf7;
  border-color: #d8f0df;
}

.info-banner.amber {
  background: #fff8ef;
  border-color: #ffe2bf;
}

/* Result text */
.result p {
  font-size: 21px;
  margin: 12px 0;
  line-height: 1.5;
}

.result b {
  font-weight: 900;
}

.result-grid {
  display: grid;
  gap: 12px;
  margin-top: 6px;
}

.result-item {
  background: #f8faff;
  border: 1px solid #e8edf6;
  border-radius: 18px;
  padding: 14px 16px;
}

.result-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.result-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 19px;
  font-weight: 900;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.present {
  background: #dff6e3;
  color: #0b7a28;
  border-color: #ccefd8;
}

.absent {
  background: #fff0f0;
  color: #b42318;
  border-color: #ffd3d3;
}

/* Meal section */
.meal-section {
  margin-top: 20px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fffaf3 0%, #ffffff 100%);
  border: 1px solid #ffe4c2;
}

.meal-label {
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 12px;
}

.radio-group {
  display: flex;
  gap: 14px;
  flex-wrap: nowrap;
  margin-bottom: 8px;
}

.radio-option {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid #e1e7f0;
  border-radius: 18px;
  padding: 14px 18px;
  min-width: 130px;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 0;
  flex: 0 0 auto;
  box-shadow: 0 4px 12px rgba(17, 24, 39, 0.04);
}

.radio-option input[type="radio"] {
  width: 24px;
  height: 24px;
  margin: 0;
  flex: 0 0 auto;
}

.radio-option span {
  line-height: 1;
}

/* Checkbox card */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 800;
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: #f7fbf8;
  border: 1px solid #d9ede0;
}

.checkbox-row input[type="checkbox"] {
  width: 26px;
  height: 26px;
  margin: 0;
  flex: 0 0 auto;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.tab-btn {
  width: auto;
  min-width: 160px;
  padding: 14px 18px;
  border-radius: 14px;
  background: #eef2f7;
  color: #111;
  font-size: 18px;
  font-weight: 800;
}

.tab-btn.active {
  background: #111;
  color: #fff;
}

/* Legend */
.legend-wrap {
  margin-bottom: 14px;
}

.legend-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 10px;
  color: #444;
}

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

/* Metric chips */
.metric-pair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.metric-separator {
  font-weight: 800;
  color: #7a8699;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  border: 1px solid transparent;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  border: 1px solid transparent;
}

.neutral-pill {
  background: #f3f5f8;
  color: #344054;
  border-color: #dbe2ea;
}

.scan-pill {
  background: #e8f1ff;
  color: #175cd3;
  border-color: #c9ddff;
}

.present-pill {
  background: #e7f7ec;
  color: #0b7a28;
  border-color: #ccefd8;
}

.confirm-pill {
  background: #eaf8ef;
  color: #137333;
  border-color: #ccefd8;
}

.unconfirm-pill {
  background: #fff3e6;
  color: #b54708;
  border-color: #ffd8b5;
}

/* Report Table */
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.report-scroll-wrap {
  max-height: 70vh;
  border: 1px solid #e7ebf3;
  border-radius: 16px;
}

.report-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

.compact-report-table th,
.compact-report-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e7ebf3;
  border-right: 1px solid #f0f3f8;
  text-align: left;
  font-size: 16px;
  vertical-align: middle;
  white-space: nowrap;
  background: #fff;
}

/* ? Roomwise / report headings centered */
.compact-report-table th {
  background: #f7f9fc;
  font-weight: 800;
  position: sticky;
  top: 0;
  z-index: 3;
  text-align: center;
}

.compact-report-table th:first-child,
.compact-report-table td:first-child {
  min-width: 110px;
  max-width: 170px;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fcfdff !important;
  box-shadow: 2px 0 0 #eef2f7;
}

.compact-report-table thead .sticky-col {
  z-index: 5;
  background: #f7f9fc !important;
  text-align: center;
}

.compact-report-table tfoot .sticky-col {
  z-index: 4;
  background: #eef3f8 !important;
}

.row-label-cell {
  font-weight: 800;
  color: #1f2937;
}

.totals-row td {
  background: #eef3f8 !important;
  font-weight: 800;
  position: sticky;
  bottom: 0;
  z-index: 2;
}

.empty-cell {
  text-align: center;
  color: #777;
  padding: 24px 12px;
}

/* Utility */
.small {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.5;
}

.success {
  color: #0b7a28;
  font-weight: 800;
  background: #edf9f0;
  border: 1px solid #d5efd9;
  padding: 14px 16px;
  border-radius: 16px;
  margin-top: 14px;
}

.error {
  color: #b42318;
  font-weight: 800;
  background: #fff1f1;
  border: 1px solid #ffd7d7;
  padding: 14px 16px;
  border-radius: 16px;
  margin-top: 14px;
}

.hidden {
  display: none !important;
}

/* Camera wrapper */
#reader,
#reader2 {
  width: 100%;
  overflow: hidden;
  border-radius: 18px;
  background: #000;
  margin-top: 12px;
}

/* Dashboard cards */
.tile {
  border-radius: 20px;
  padding: 20px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

/* Result action separation */
.action-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
}

.action-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #e5eaf3, transparent);
  margin: 18px 0;
}

/* =========================
   APP MODAL SYSTEM
========================= */

.app-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 9999;
}

.app-modal-card {
  width: 100%;
  max-width: 520px;
  background: #ffffff;
  border-radius: 28px;
  border: 1px solid #e5eaf3;
  box-shadow: 0 28px 60px rgba(15, 23, 42, 0.28);
  padding: 24px 20px 20px;
  animation: modalPop 0.18s ease;
}

@keyframes modalPop {
  from {
    transform: scale(0.96) translateY(8px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.app-modal-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 900;
  margin-bottom: 14px;
  border: 1px solid transparent;
}

.modal-badge-success {
  background: #eaf8ef;
  color: #137333;
  border-color: #ccefd8;
}

.modal-badge-warning {
  background: #fff3e6;
  color: #b54708;
  border-color: #ffd8b5;
}

.modal-badge-error {
  background: #fff0f0;
  color: #b42318;
  border-color: #ffd3d3;
}

.modal-badge-neutral {
  background: #f3f5f8;
  color: #344054;
  border-color: #dbe2ea;
}

.app-modal-title {
  font-size: 28px;
  font-weight: 900;
  line-height: 1.2;
  color: #111827;
  margin-bottom: 12px;
}

.app-modal-message {
  font-size: 18px;
  line-height: 1.7;
  color: #475467;
  word-break: break-word;
}

.app-modal-input {
  width: 100%;
  padding: 18px;
  font-size: 22px;
  border-radius: 18px;
  border: 1px solid #d9e1ec;
  outline: none;
  background: #fff;
  margin: 0;
}

.app-modal-input:focus {
  border-color: #94b6ff;
  box-shadow: 0 0 0 4px rgba(23, 92, 211, 0.08);
}

.app-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 22px;
}

.app-modal-actions button {
  margin: 0;
}

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

  .header {
    padding: 14px 16px;
  }

  .header-title {
    font-size: 24px;
  }

  .title {
    font-size: 32px;
  }

  .subtitle {
    font-size: 18px;
  }

  input,
  select,
  textarea,
  button {
    font-size: 20px;
    padding: 17px;
  }

  .summary-box {
    min-height: 102px;
    padding: 16px;
  }

  .summary-label {
    font-size: 17px;
  }

  .summary-value {
    font-size: 24px;
  }

  .result p {
    font-size: 20px;
  }

  .badge {
    font-size: 18px;
  }

  .radio-group {
    flex-wrap: nowrap;
  }

  .radio-option {
    min-width: 120px;
    justify-content: flex-start;
  }

  .tabs {
    flex-direction: column;
  }

  .tab-btn {
    width: 100%;
    min-width: 0;
  }

  .compact-report-table th,
  .compact-report-table td {
    font-size: 15px;
    padding: 8px 9px;
  }

  .compact-report-table th:first-child,
  .compact-report-table td:first-child {
    min-width: 95px;
    max-width: 145px;
  }

  .metric-chip {
    min-width: 36px;
    padding: 5px 9px;
    font-size: 14px;
  }

  .mini-pill {
    font-size: 13px;
    padding: 7px 11px;
  }

  .report-scroll-wrap {
    max-height: 68vh;
  }

  .page-hero {
    padding: 22px 18px;
    border-radius: 24px;
  }

  .result-grid {
    gap: 10px;
  }

  .result-item {
    padding: 13px 14px;
  }

  .result-value {
    font-size: 18px;
  }

  .section-title {
    font-size: 21px;
  }

  .section-subtitle {
    font-size: 15px;
  }

  .app-modal-card {
    border-radius: 24px;
    padding: 22px 18px 18px;
  }

  .app-modal-title {
    font-size: 25px;
  }

  .app-modal-message {
    font-size: 18px;
  }
}