/* SSN-SNUC MUNSOC — light, mobile-first event console */
:root {
  --bg-primary: #f6f1e8;
  --bg-card: #fffdf8;
  --bg-card-hover: #f5eddd;
  --ink: #172437;
  --text-primary: #172437;
  --text-secondary: #5e6875;
  --text-muted: #8b918f;
  --line: #e3daca;
  --accent-gold: #bd8b37;
  --accent-gold-hover: #a8782c;
  --accent-blue: #bd8b37;
  --accent-blue-hover: #a8782c;
  --accent-deep: #243a58;
  --status-success-bg: #e8f3e7;
  --status-success-border: #7aa875;
  --status-success-text: #244d2d;
  --status-duplicate-bg: #fff1d9;
  --status-duplicate-border: #d59b3e;
  --status-duplicate-text: #775018;
  --status-error-bg: #fbe9e5;
  --status-error-border: #c96e5f;
  --status-error-text: #73352d;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow: 0 10px 30px rgba(35, 47, 59, .07);
  --font-stack: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: radial-gradient(circle at 100% 0, #fbf1df 0, transparent 33rem), var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-stack);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }

.container { width: min(100%, 700px); margin: 0 auto; padding: 18px 16px 28px; }

.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 18px; padding: 6px 0 16px; border-bottom: 1px solid var(--line);
}
.app-title { color: var(--accent-deep); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.2rem, 4vw, 1.55rem); letter-spacing: .02em; line-height: 1.1; }
.status-badge { display: inline-flex; align-items: center; flex: 0 0 auto; padding: 6px 9px; border: 1px solid; border-radius: 999px; font-size: .72rem; font-weight: 750; white-space: nowrap; }
.status-badge.connected { color: #356740; background: #edf6ec; border-color: #b6d4b2; }
.status-badge.connecting { color: #895a11; background: #fdf4df; border-color: #e7c883; }
.status-badge.disconnected { color: #913f34; background: #fcebe8; border-color: #e2aaa1; }

.nav-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 24px; padding: 4px; background: #ebe3d5; border-radius: var(--radius-md); }
.nav-link { display: flex; min-height: 44px; align-items: center; justify-content: center; padding: 8px 6px; border-radius: 9px; color: var(--text-secondary); font-size: .86rem; font-weight: 750; text-align: center; text-decoration: none; transition: background .18s ease, color .18s ease, box-shadow .18s ease; }
.nav-link:hover, .nav-link.active { background: var(--bg-card); box-shadow: 0 2px 8px rgba(39, 49, 57, .09); color: var(--accent-deep); }
.nav-link.active { color: var(--accent-gold); }

.section-label { margin-bottom: 9px; color: var(--accent-deep); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.day-selector-section { margin-bottom: 18px; }
.segmented-control { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #f5f0e7; overflow-x: auto; }
.segment-btn { min-height: 46px; padding: 9px 12px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: .88rem; font-weight: 750; white-space: nowrap; transition: .18s ease; }
.segment-btn:hover { color: var(--accent-deep); background: #fffaf2; }
.segment-btn.active { border-color: var(--accent-gold); background: var(--accent-gold); color: #fffdf7; box-shadow: 0 3px 8px rgba(125, 82, 20, .18); }

.camera-card, .manual-card, .metric-card, .chart-container, .table-card, .help-card { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-card); box-shadow: var(--shadow); }
.camera-card { padding: 12px; margin-bottom: 18px; }
.camera-preview-wrapper { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 12px; background: #182434; }
#camera-video { width: 100%; height: 100%; object-fit: cover; }
.scan-overlay-box { position: absolute; width: 64%; height: 62%; border: 2px solid #f7d98f; border-radius: 10px; box-shadow: 0 0 0 999px rgba(14, 22, 32, .35); pointer-events: none; }
.camera-actions { display: flex; gap: 9px; margin-top: 12px; }

.btn { display: inline-flex; width: 100%; min-height: 48px; align-items: center; justify-content: center; gap: 7px; padding: 11px 16px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-size: .92rem; font-weight: 800; line-height: 1.1; text-align: center; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 12px rgba(44, 51, 57, .13); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { cursor: not-allowed; opacity: .45; }
.btn-primary { background: var(--accent-gold); color: #fffdf8; }
.btn-primary:hover:not(:disabled) { background: var(--accent-gold-hover); }
.btn-secondary { border-color: #d4c6b1; background: #fffaf2; color: var(--accent-deep); }
.btn-secondary:hover:not(:disabled) { background: #f4eadb; }
.btn-danger { background: #b75c4f; color: #fff; }

#scan-status-notice { margin-top: 10px !important; color: var(--text-secondary) !important; text-align: center; }
.result-card { margin-bottom: 18px; padding: 18px; border: 1px solid; border-radius: var(--radius-lg); animation: fadeIn .2s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.result-card.collected { background: var(--status-success-bg); border-color: var(--status-success-border); color: var(--status-success-text); }
.result-card.duplicate { background: var(--status-duplicate-bg); border-color: var(--status-duplicate-border); color: var(--status-duplicate-text); }
.result-card.error { background: var(--status-error-bg); border-color: var(--status-error-border); color: var(--status-error-text); }
.result-badge { display: inline-block; margin-bottom: 7px; font-size: .73rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.result-name { margin-bottom: 3px; color: inherit; font-size: 1.35rem; font-weight: 850; }
.result-code { margin-bottom: 12px; font-size: 1rem; font-weight: 750; }
.food-preference { margin: -4px 0 12px; font-size: .96rem; font-weight: 700; }
.result-meta { padding-top: 9px; border-top: 1px solid currentColor; font-size: .88rem; opacity: .9; }

.manual-card { margin-bottom: 18px; padding: 16px; }
.form-group { display: flex; gap: 9px; align-items: stretch; }
.input-text { min-width: 0; min-height: 48px; flex: 1; padding: 10px 13px; border: 1px solid #cfc2b1; border-radius: 10px; background: #fffdf8; color: var(--ink); font-size: .94rem; font-weight: 650; text-transform: uppercase; }
.input-text::placeholder { color: #96948f; font-weight: 550; }
.input-text:focus { outline: 3px solid rgba(189, 139, 55, .22); border-color: var(--accent-gold); }

.metrics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.metric-card { padding: 15px; }
.metric-card.full-width { grid-column: span 2; }
.metric-val { color: var(--accent-deep) !important; font-size: 1.75rem; font-weight: 850; line-height: 1.1; }
.metric-lbl { margin-top: 5px; color: var(--text-secondary); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.chart-container { margin-bottom: 18px; padding: 16px; }
.chart-bar-row { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; font-size: .82rem; }
.chart-label { width: 80px; color: var(--text-secondary); font-size: .76rem; font-weight: 700; }
.chart-bar-bg { flex: 1; height: 10px; overflow: hidden; border-radius: 99px; background: #eee5d7; }
.chart-bar-fill { height: 100%; border-radius: inherit; background: var(--accent-gold); transition: width .3s ease; }
.chart-bar-fill.peak { background: #789b5d; }
.chart-val { width: 26px; color: var(--accent-deep); font-weight: 800; text-align: right; }

.table-card { margin-bottom: 18px; padding: 16px; overflow-x: auto; }
.table { width: 100%; min-width: 510px; border-collapse: collapse; color: var(--ink); font-size: .84rem; text-align: left; }
.table th, .table td { padding: 11px 9px; border-bottom: 1px solid #eee6da; }
.table th { color: var(--text-secondary); font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.badge-status { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: .7rem; font-weight: 800; }
.badge-status.collected { color: #356740; background: #e8f3e7; }
.badge-status.remaining { color: #697078; background: #eeeae3; }

.help-card { margin-bottom: 16px; padding: 18px; }
.help-card h2 { color: var(--accent-deep) !important; font-family: Georgia, "Times New Roman", serif; }
.help-card ol, .help-card ul, .help-card p { color: var(--text-secondary) !important; }
.help-card strong { color: var(--ink) !important; }
.code-block { border: 1px solid #eadcc6; border-radius: 7px; background: #f8f0e3 !important; color: #8a5c17 !important; }
.footer { padding: 8px 0 4px; color: var(--text-muted); font-size: .75rem; text-align: center; }

@media (max-width: 440px) {
  .container { padding: 14px 12px 24px; }
  .app-header { align-items: flex-start; }
  .status-badge { max-width: 126px; white-space: normal; text-align: right; justify-content: flex-end; }
  .form-group { flex-direction: column; }
  .form-group .btn { width: 100% !important; padding-inline: 16px !important; }
  .report-toolbar { align-items: stretch !important; flex-direction: column; }
  .report-toolbar .segmented-control { max-width: none !important; }
  .report-toolbar .btn { width: 100% !important; }
  .table-controls { flex-direction: column; }
  .table-controls select, .table-controls input { width: 100% !important; }
  .report-pagination { align-items: flex-start !important; flex-direction: column; gap: 10px; }
  .report-pagination > div { width: 100%; }
  .report-pagination .btn { flex: 1; }
}

@media (min-width: 620px) {
  .container { padding-top: 28px; }
  .camera-card, .manual-card, .chart-container, .table-card { padding: 20px; }
}
