/* ========== Branch App Styles ========== */
* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:'Sarabun','Inter',sans-serif; background:#f0f4f8; color:#1e293b; min-height:100vh; padding-bottom:24px; }

/* Header */
.app-header { background:linear-gradient(135deg,#1e3a5f 0%,#2563eb 100%); color:#fff; padding:14px 20px; display:flex; align-items:center; justify-content:space-between; position:sticky; top:0; z-index:50; }
.app-header h1 { font-size:18px; font-weight:700; }
.header-user { display:flex; align-items:center; gap:8px; font-size:14px; }
.header-badge { font-size:18px; }

/* Container */
.container { max-width:500px; margin:0 auto; padding:16px; }

/* App title (login page) */
.app-title { text-align:center; padding:32px 0 24px; }
.app-icon { font-size:48px; margin-bottom:8px; }
.app-title h1 { font-size:24px; font-weight:800; color:#1e3a5f; }
.app-subtitle { color:#64748b; font-size:14px; }

/* Section labels */
.section-label { font-size:13px; font-weight:600; color:#64748b; text-transform:uppercase; letter-spacing:0.5px; margin:16px 0 8px; }
.section-header { background:linear-gradient(135deg,#1e3a5f,#334155); color:#fff; padding:10px 16px; border-radius:10px; margin:20px 0 8px; font-weight:700; font-size:14px; }

/* Menu cards */
.menu-card { display:flex; align-items:center; gap:14px; background:#fff; border-radius:14px; padding:16px; margin-bottom:10px; cursor:pointer; transition:transform .15s,box-shadow .15s; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.menu-card:active { transform:scale(.97); }
.mc-icon { width:44px; height:44px; border-radius:12px; display:flex; align-items:center; justify-content:center; font-size:22px; background:#f1f5f9; flex-shrink:0; }
.mc-body { flex:1; min-width:0; }
.mc-name { font-weight:700; font-size:16px; }
.mc-role { font-size:12px; color:#64748b; }
.mc-desc { font-size:13px; color:#64748b; margin-top:2px; }
.menu-feature { border-left-width:4px; border-left-style:solid; }

/* Branch title */
.branch-title { display:flex; align-items:center; gap:12px; margin-bottom:20px; padding:8px 0; }
.bt-icon { font-size:32px; }
.branch-title h2 { font-size:22px; font-weight:800; color:#1e3a5f; }

/* Back button */
.back-btn { background:none; border:none; color:#2563eb; font-size:14px; font-weight:600; cursor:pointer; padding:4px 0; font-family:inherit; }

/* Week / Period tabs */
.week-tabs { display:flex; gap:6px; margin-bottom:16px; }
.week-tab { flex:1; padding:10px 4px; border-radius:10px; border:2px solid #e2e8f0; background:#fff; font-weight:600; font-size:14px; cursor:pointer; text-align:center; transition:all .15s; color:#64748b; font-family:inherit; }
.week-tab.active { background:#1e3a5f; color:#fff; border-color:#1e3a5f; }

/* Metric cards */
.metric-card { background:#fff; border-radius:12px; padding:14px; margin-bottom:10px; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.metric-top { display:flex; align-items:center; justify-content:space-between; margin-bottom:4px; }
.metric-name { font-weight:600; font-size:15px; }
.status-dot { font-size:11px; padding:3px 10px; border-radius:20px; color:#fff; font-weight:700; }
.metric-target { font-size:12px; color:#64748b; margin-bottom:10px; }
.metric-input-row { display:flex; gap:6px; align-items:center; }
.metric-input { flex:1; padding:8px 10px; border:1.5px solid #e2e8f0; border-radius:8px; font-size:15px; font-family:inherit; }
.metric-input:focus { border-color:#2563eb; outline:none; }
.metric-status { width:100px; padding:8px 6px; border:1.5px solid #e2e8f0; border-radius:8px; font-size:13px; font-family:inherit; background:#fff; }
.metric-photo-row { margin-top:8px; }
.metric-thumb { width:60px; height:60px; border-radius:8px; object-fit:cover; margin-top:6px; border:1px solid #e2e8f0; cursor:pointer; }

/* Receiving */
.rcv-summary { background:#fff; border-radius:12px; padding:16px; margin-bottom:16px; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.rcv-sum-row { display:flex; justify-content:space-between; padding:6px 0; font-size:15px; }
.rcv-total { border-top:2px solid #e2e8f0; margin-top:8px; padding-top:10px; font-size:17px; }
.rcv-date-header { display:flex; justify-content:space-between; align-items:center; padding:10px 4px 4px; font-weight:700; font-size:13px; color:#64748b; border-bottom:1px solid #e2e8f0; margin-top:8px; }
.rcv-day-total { color:#1e3a5f; }
.rcv-item { display:flex; align-items:center; gap:8px; background:#fff; border-radius:10px; padding:12px; margin-top:6px; box-shadow:0 1px 2px rgba(0,0,0,.04); }
.rcv-item-body { flex:1; min-width:0; }
.rcv-supplier { font-weight:600; font-size:14px; }
.rcv-invoice { font-size:11px; color:#94a3b8; }
.rcv-amount { font-weight:700; font-size:15px; color:#059669; white-space:nowrap; }
.rcv-del { background:none; border:none; color:#ef4444; font-size:16px; cursor:pointer; padding:4px 8px; opacity:.5; }
.rcv-del:hover { opacity:1; }

/* Yield table */
.yield-table { background:#fff; border-radius:12px; overflow:hidden; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.yield-row { display:flex; align-items:center; padding:8px 12px; border-bottom:1px solid #f1f5f9; }
.yield-header { background:#f8fafc; font-weight:700; font-size:12px; color:#64748b; }
.yield-avg-row { background:#f0f9ff; border-top:2px solid #bfdbfe; }
.yield-col { padding:4px; }
.yc-name { flex:2; font-size:14px; font-weight:500; }
.yc-num { flex:1.5; }
.yc-yield { flex:1; text-align:right; }
.yield-input { width:100%; padding:6px 8px; border:1.5px solid #e2e8f0; border-radius:6px; font-size:14px; font-family:inherit; text-align:right; }
.yield-input:focus { border-color:#7c3aed; outline:none; }
.yield-pct { font-size:14px; color:#94a3b8; font-weight:600; }
.yield-pct.has-value { color:#7c3aed; }
.avg-pct { font-size:16px; }
.avg-pct.has-value { color:#1e3a5f; font-weight:800; }

.yield-summary-card { background:linear-gradient(135deg,#7c3aed 0%,#a78bfa 100%); border-radius:14px; padding:16px 20px; margin-bottom:16px; color:#fff; display:flex; align-items:center; justify-content:space-between; }
.ys-main { }
.ys-num { font-size:36px; font-weight:900; line-height:1; }
.ys-label { font-size:12px; opacity:.7; margin-top:4px; }
.ys-info { display:flex; flex-direction:column; gap:4px; font-size:13px; opacity:.85; text-align:right; }

.yield-week-badge { display:inline-block; padding:2px 8px; border-radius:6px; background:#7c3aed; color:#fff; font-size:11px; font-weight:700; vertical-align:middle; }
.yield-week-badge.lg { font-size:13px; padding:3px 10px; }
.yield-week-info { font-size:12px; color:#64748b; margin-top:6px; display:flex; align-items:center; gap:6px; }
.yield-actions { }

/* External link */
.link-section { text-align:center; }
.external-link { color:#2563eb; text-decoration:none; font-size:14px; font-weight:500; }

/* Dash header */
.dash-header { display:flex; align-items:center; gap:12px; margin-bottom:16px; }
.dash-header h2 { font-size:18px; font-weight:700; }

/* Buttons */
.btn { display:inline-flex; align-items:center; justify-content:center; padding:10px 20px; border:none; border-radius:10px; font-size:15px; font-weight:600; cursor:pointer; font-family:inherit; transition:transform .1s; }
.btn:active { transform:scale(.97); }
.btn-primary { background:#1e3a5f; color:#fff; }
.btn-secondary { background:#e2e8f0; color:#475569; }
.btn-sm { padding:6px 12px; font-size:13px; border-radius:8px; }
.btn-block { width:100%; }
.btn-lg { padding:14px 24px; font-size:17px; }
.btn:disabled { opacity:.5; pointer-events:none; }

/* Forms */
.form-group { margin-bottom:12px; }
.form-label { display:block; font-size:13px; font-weight:600; color:#475569; margin-bottom:4px; }
.form-input { width:100%; padding:10px 12px; border:1.5px solid #e2e8f0; border-radius:10px; font-size:15px; font-family:inherit; }
.form-input:focus { border-color:#2563eb; outline:none; }

/* Modal */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:100; display:flex; align-items:flex-end; justify-content:center; }
.modal-box { background:#fff; border-radius:20px 20px 0 0; padding:20px; width:100%; max-width:500px; max-height:85vh; overflow-y:auto; animation:slideUp .25s; }
@keyframes slideUp { from { transform:translateY(100%); } to { transform:translateY(0); } }
.modal-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; }
.modal-head strong { font-size:17px; }
.modal-close { background:none; border:none; font-size:20px; cursor:pointer; color:#94a3b8; }
.modal-body { }
.modal-actions { display:flex; gap:10px; margin-top:16px; }
.modal-actions .btn { flex:1; }

/* Toast */
#toast { position:fixed; bottom:80px; left:50%; transform:translateX(-50%); padding:10px 24px; border-radius:12px; font-size:14px; font-weight:600; z-index:200; opacity:0; transition:opacity .3s; pointer-events:none; background:#1e293b; color:#fff; }
#toast.show { opacity:1; }
#toast.success { background:#059669; }
#toast.error { background:#ef4444; }

/* Lightbox */
.lightbox-overlay { position:fixed; inset:0; background:rgba(0,0,0,.85); z-index:150; display:flex; align-items:center; justify-content:center; cursor:pointer; }
.lightbox-img { max-width:95%; max-height:90vh; border-radius:8px; }

/* Utilities */
.loading { text-align:center; padding:60px 20px; color:#64748b; }
.spinner { width:32px; height:32px; border:3px solid #e2e8f0; border-top-color:#2563eb; border-radius:50%; animation:spin .7s linear infinite; margin:0 auto 12px; }
@keyframes spin { to { transform:rotate(360deg); } }
.empty-state { text-align:center; padding:40px; color:#94a3b8; font-size:14px; }
.hidden { display:none!important; }
.mb-8 { margin-bottom:8px; }
.mb-16 { margin-bottom:16px; }
.mt-16 { margin-top:16px; }

/* ========== Report (iPad meeting view) ========== */
.rpt-container { max-width:780px; margin:0 auto; padding:16px; }

.rpt-header { display:flex; align-items:center; gap:14px; margin-bottom:12px; }
.rpt-title { font-size:20px; font-weight:800; color:#1e3a5f; }
.rpt-subtitle { font-size:13px; color:#64748b; font-weight:500; }

.rpt-month-nav { display:flex; align-items:center; justify-content:center; gap:16px; margin-bottom:16px; }
.rpt-nav-btn { background:none; border:2px solid #e2e8f0; border-radius:10px; width:40px; height:40px; font-size:16px; cursor:pointer; color:#475569; font-family:inherit; transition:all .15s; }
.rpt-nav-btn:active { background:#e2e8f0; }
.rpt-month-label { font-size:22px; font-weight:800; color:#1e3a5f; min-width:120px; text-align:center; }

.rpt-score-card { background:linear-gradient(135deg,#1e3a5f 0%,#2563eb 100%); border-radius:16px; padding:20px; margin-bottom:20px; color:#fff; display:flex; align-items:center; justify-content:space-between; }
.rpt-score-main { text-align:left; }
.rpt-score-num { font-size:48px; font-weight:900; line-height:1; }
.rpt-score-label { font-size:13px; opacity:.7; margin-top:4px; font-weight:500; }
.rpt-score-pills { display:flex; gap:8px; flex-wrap:wrap; }
.rpt-pill { padding:6px 14px; border-radius:20px; font-size:14px; font-weight:700; white-space:nowrap; }

.rpt-sec-header { color:#fff; padding:10px 16px; border-radius:12px 12px 0 0; margin-top:20px; font-weight:700; font-size:14px; display:flex; justify-content:space-between; align-items:center; }
.rpt-sec-status { font-size:11px; padding:3px 10px; border-radius:20px; color:#fff; font-weight:600; }

.rpt-table { background:#fff; border-radius:0 0 12px 12px; overflow:hidden; box-shadow:0 2px 8px rgba(0,0,0,.06); margin-bottom:4px; }
.rpt-row { display:flex; align-items:center; border-bottom:1px solid #f1f5f9; padding:0 4px; min-height:44px; }
.rpt-row:last-child { border-bottom:none; }
.rpt-thead { background:#f8fafc; font-weight:700; font-size:11px; color:#64748b; text-transform:uppercase; letter-spacing:.3px; min-height:36px; }
.rpt-cell { padding:8px 6px; font-size:13px; text-align:center; }
.rpt-cell-name { flex:3; text-align:left; min-width:0; }
.rpt-cell-target { flex:1.5; font-size:12px; color:#64748b; font-weight:600; }
.rpt-cell-wk { flex:1; font-size:13px; }
.rpt-cell-actual { flex:1.5; font-size:14px; }
.rpt-cell-status { flex:0.5; display:flex; justify-content:center; }
.rpt-metric-name { display:block; font-weight:600; font-size:13px; line-height:1.3; }
.rpt-metric-unit { display:block; font-size:10px; color:#94a3b8; }
.rpt-status-dot { width:12px; height:12px; border-radius:50%; display:inline-block; }

.rpt-footer { text-align:center; padding:20px; font-size:11px; color:#94a3b8; display:flex; justify-content:space-between; }

@media (max-width:600px) {
  .rpt-container { padding:10px; }
  .rpt-cell-wk { font-size:11px; }
  .rpt-cell-name { flex:2.5; }
  .rpt-score-num { font-size:36px; }
  .rpt-score-card { flex-direction:column; gap:12px; align-items:flex-start; }
}

/* ========== Admin Panel ========== */
.adm-container { max-width:560px; margin:0 auto; padding:0 16px 24px; }

.adm-tabs { display:flex; gap:4px; padding:12px 0 4px; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.adm-tab { padding:8px 14px; border-radius:10px; border:2px solid #e2e8f0; background:#fff; font-weight:600; font-size:13px; cursor:pointer; white-space:nowrap; font-family:inherit; color:#64748b; transition:all .15s; }
.adm-tab.active { background:#1e3a5f; color:#fff; border-color:#1e3a5f; }

.adm-content { padding-top:12px; }

.adm-tab-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; margin-bottom:12px; }
.adm-tab-header h3 { font-size:18px; font-weight:700; color:#1e3a5f; }
.adm-tab-desc { font-size:13px; color:#64748b; width:100%; }

.adm-item { display:flex; align-items:center; gap:10px; background:#fff; border-radius:12px; padding:14px; margin-bottom:8px; cursor:pointer; transition:transform .15s,box-shadow .15s; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.adm-item:active { transform:scale(.98); }
.adm-item-body { flex:1; min-width:0; }
.adm-item-name { font-weight:600; font-size:15px; }
.adm-item-detail { font-size:12px; color:#64748b; margin-top:2px; }
.adm-chevron { color:#cbd5e1; font-size:16px; font-weight:700; }
.adm-badge { font-size:11px; padding:2px 8px; border-radius:8px; background:#f1f5f9; color:#64748b; font-weight:600; white-space:nowrap; }
.adm-badge.inactive { background:#fef2f2; color:#dc2626; }

.adm-check-label { display:block; padding:6px 0; font-size:14px; cursor:pointer; }
.adm-check-label input { margin-right:8px; }

.adm-list-editor { background:#fff; border-radius:12px; padding:12px; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.adm-list-row { display:flex; align-items:center; gap:10px; padding:10px 4px; border-bottom:1px solid #f1f5f9; }
.adm-list-row:last-of-type { border-bottom:none; }
.adm-list-num { width:24px; height:24px; border-radius:50%; background:#f1f5f9; display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; color:#64748b; flex-shrink:0; }
.adm-list-text { flex:1; font-size:14px; font-weight:500; }
.adm-add-row { display:flex; gap:8px; align-items:center; padding-top:12px; border-top:1px solid #e2e8f0; margin-top:8px; }
.adm-add-row .form-input { flex:1; padding:8px 10px; font-size:14px; }

/* ========== Daily Check Module ========== */
.dc-score-display { text-align:center; padding:16px 0 8px; }
.dc-score-num { font-size:52px; font-weight:800; color:#1e3a5f; transition:color .2s; }
.dc-score-max { font-size:22px; color:#94a3b8; font-weight:600; margin-left:4px; }

.dc-slider {
  -webkit-appearance:none; appearance:none;
  width:100%; height:10px; border-radius:6px;
  background:linear-gradient(to right, #ef4444 0%, #eab308 60%, #059669 100%);
  outline:none; margin:8px 0 4px;
}
.dc-slider::-webkit-slider-thumb {
  -webkit-appearance:none; appearance:none;
  width:32px; height:32px; border-radius:50%;
  background:#fff; border:3px solid var(--pct-color, #94a3b8);
  box-shadow:0 2px 6px rgba(0,0,0,.15);
  cursor:pointer;
}
.dc-slider::-moz-range-thumb {
  width:32px; height:32px; border-radius:50%;
  background:#fff; border:3px solid var(--pct-color, #94a3b8);
  box-shadow:0 2px 6px rgba(0,0,0,.15);
  cursor:pointer;
}

.dc-quick-row { display:flex; gap:6px; justify-content:center; margin-top:8px; flex-wrap:wrap; }
.dc-quick-btn {
  padding:6px 14px; border-radius:8px; border:1.5px solid #e2e8f0;
  background:#fff; font-weight:600; font-size:14px; cursor:pointer;
  color:#64748b; font-family:inherit; transition:all .15s;
}
.dc-quick-btn:active { background:#f1f5f9; transform:scale(.95); }

.dc-photo-list { display:flex; gap:10px; flex-wrap:wrap; }
.dc-photo-wrap { position:relative; width:80px; height:80px; border-radius:10px; overflow:hidden; box-shadow:0 2px 6px rgba(0,0,0,.1); }
.dc-photo-thumb { width:100%; height:100%; object-fit:cover; cursor:pointer; }
.dc-photo-del {
  position:absolute; top:2px; right:2px;
  width:22px; height:22px; border-radius:50%;
  background:rgba(0,0,0,.55); color:#fff;
  border:none; font-size:12px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
}
.dc-photo-add {
  width:80px; height:80px; border-radius:10px;
  border:2px dashed #cbd5e1; display:flex; flex-direction:column;
  align-items:center; justify-content:center; cursor:pointer;
  background:#f8fafc; transition:all .15s;
}
.dc-photo-add:active { background:#f1f5f9; border-color:#94a3b8; }
.dc-photo-add-icon { font-size:24px; }
.dc-photo-add-text { font-size:11px; color:#94a3b8; font-weight:600; margin-top:2px; }

/* Photo-first gallery (BOH-04) */
.dc-pg-section { background:#fff; border-radius:16px; padding:16px; box-shadow:0 2px 8px rgba(0,0,0,.06); margin-bottom:16px; }
.dc-pg-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.dc-pg-title { font-weight:700; font-size:16px; color:#1e3a5f; }
.dc-pg-count { font-weight:700; font-size:15px; }
.dc-pg-grid { display:grid; grid-template-columns:repeat(3, 1fr); gap:10px; }
.dc-pg-cell { position:relative; aspect-ratio:1; border-radius:12px; overflow:hidden; box-shadow:0 2px 8px rgba(0,0,0,.1); }
.dc-pg-img { width:100%; height:100%; object-fit:cover; cursor:pointer; display:block; }
.dc-pg-del {
  position:absolute; top:4px; right:4px; width:26px; height:26px; border-radius:50%;
  background:rgba(0,0,0,.6); color:#fff; border:none; font-size:14px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; backdrop-filter:blur(4px);
}
.dc-pg-del:active { background:rgba(220,38,38,.8); }
.dc-pg-add {
  aspect-ratio:1; border-radius:12px; border:2.5px dashed #cbd5e1; background:#f8fafc;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px;
  cursor:pointer; transition:all .15s; min-height:100px;
}
.dc-pg-add:active { background:#e0f2fe; border-color:#2563eb; transform:scale(.95); }
.dc-pg-add-text { font-size:11px; color:#64748b; font-weight:600; text-align:center; line-height:1.3; }
.dc-pg-score-row { display:flex; gap:6px; flex-wrap:wrap; justify-content:center; margin-bottom:8px; }
.dc-pg-score-btn {
  width:38px; height:38px; border-radius:10px; border:2px solid #e2e8f0; background:#fff;
  font-weight:700; font-size:15px; color:#64748b; cursor:pointer; font-family:inherit; transition:all .15s;
}
.dc-pg-score-btn:active { transform:scale(.9); }
.dc-pg-score-btn.active { background:#059669; color:#fff; border-color:#059669; }
.dc-pg-score-label { display:block; text-align:center; font-weight:800; font-size:22px; margin-top:4px; transition:color .2s; }

/* Checklist scorebar */
.dc-cl-scorebar { background:#fff; border-radius:14px; padding:14px 16px; box-shadow:0 2px 8px rgba(0,0,0,.06); margin-bottom:12px; }
.dc-cl-score-top { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
.dc-cl-score-label { font-weight:600; font-size:14px; color:#64748b; }
.dc-cl-score-num { font-weight:800; font-size:20px; color:#1e3a5f; }
.dc-cl-score-pct { font-weight:700; font-size:16px; margin-left:auto; }
.dc-cl-progress { height:8px; border-radius:4px; background:#e2e8f0; overflow:hidden; }
.dc-cl-progress-fill { height:100%; border-radius:4px; transition:width .3s, background .3s; }

/* Checklist actions */
.dc-cl-actions { display:flex; gap:8px; margin-bottom:12px; }
.dc-cl-action-btn { flex:1; padding:8px; border-radius:10px; border:1.5px solid #e2e8f0; background:#fff; font-size:13px; font-weight:600; color:#64748b; cursor:pointer; font-family:inherit; transition:all .15s; }
.dc-cl-action-btn:active { background:#f1f5f9; transform:scale(.97); }

/* Checklist groups */
.dc-cl-list { display:flex; flex-direction:column; gap:10px; margin-bottom:16px; }
.dc-cl-group { background:#fff; border-radius:14px; overflow:hidden; box-shadow:0 1px 4px rgba(0,0,0,.05); }
.dc-cl-group-header { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; background:#f8fafc; border-bottom:1px solid #f1f5f9; }
.dc-cl-group-name { font-weight:700; font-size:14px; color:#1e3a5f; }
.dc-cl-group-count { font-weight:700; font-size:13px; }

/* Checklist items */
.dc-cl-item { display:flex; align-items:center; gap:10px; padding:12px 16px; border-bottom:1px solid #f8fafc; cursor:pointer; transition:background .15s; -webkit-user-select:none; user-select:none; }
.dc-cl-item:last-child { border-bottom:none; }
.dc-cl-item:active { background:#f0f9ff; }
.dc-cl-item.checked { background:#f0fdf4; }
.dc-cl-item input[type="checkbox"] { display:none; }
.dc-cl-checkbox { font-size:20px; flex-shrink:0; width:24px; text-align:center; }
.dc-cl-item-text { font-size:14px; color:#334155; line-height:1.4; }
.dc-cl-item.checked .dc-cl-item-text { color:#15803d; }
