/* Shared styles for all pages. Mobile-first. */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5; color: #1a1a1a; font-size: 14px;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 1rem; }
.center { max-width: 420px; margin: 0 auto; padding: 2rem 1rem; }

h1 { font-size: 18px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
a { color: #1a56c4; }

/* Header — branded hero */
.topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 1.2rem; background: var(--brand,#16a34a); border-radius: 20px; padding: 16px 20px; box-shadow: 0 8px 22px rgba(0,0,0,.16); }
.topbar h1 { color: #fff; font-weight: 900; text-transform: uppercase; letter-spacing: .5px; margin: 0; }
.topbar .muted { color: rgba(255,255,255,.72) !important; }
.topbar .btn.red { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.5); }
.logochip { display: inline-flex; background: #fff; border-radius: 10px; padding: 5px; line-height: 0; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.logochip:empty { display: none; }
.muted { color: #888; font-size: 12px; }

/* Nav tabs */
nav { display: flex; gap: 4px; margin-bottom: 1rem; flex-wrap: wrap; }
nav button { padding: 10px 18px; border: 1px solid #ccc; border-radius: 8px; background: #fff; cursor: pointer; font-size: 14px; -webkit-tap-highlight-color: transparent; }
nav button.on { background: var(--brand,#16a34a); color: #fff; border-color: var(--brand,#16a34a); font-weight: 700; }
.page { display: none; }
.page.active { display: block; }

/* Cards */
.card { background: #fff; border-radius: 12px; padding: 1rem; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.flex { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* Inputs */
input[type=text], input[type=number], input[type=date], input[type=time],
input[type=email], input[type=password], select {
  padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; background: #fff; -webkit-appearance: none;
}
label.fld { display: block; font-size: 12px; color: #888; margin: 12px 0 4px; }
.full { width: 100%; }

/* Buttons */
.btn { padding: 10px 16px; border: 1px solid #ccc; border-radius: 8px; background: #fff; cursor: pointer; font-size: 14px; -webkit-tap-highlight-color: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.green { background: var(--brand-tint,#dcfce7); border-color: var(--brand,#16a34a); color: var(--brand-ink,#15803d); }
.btn.red { background: #fdecea; border-color: #c0392b; color: #7b1a14; }
.btn.blue { background: #e8f0fb; border-color: #1a56c4; color: #0d3a8a; }
.btn.orange { background: #fff3e0; border-color: #e65100; color: #e65100; }
.btn.dark { background: #1a1a1a; border-color: #1a1a1a; color: #fff; }
.btn.big { width: 100%; padding: 16px; font-size: 16px; font-weight: 700; border-radius: 12px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px; border-bottom: 1px solid #eee; text-align: left; }
.scroll { overflow-x: auto; }

/* Metrics row */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 1rem; }
.metric { background: var(--brand-tint,#eef6f0); border-top: 3px solid var(--brand,#16a34a); border-radius: 12px; padding: 1rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); text-align: center; }
.metric .lbl { font-size: 11px; color: #777; text-transform: uppercase; letter-spacing: .3px; }
.metric .val { font-size: 24px; font-weight: 800; color: var(--brand-ink,#15803d); }

/* Status / feedback */
.empty { color: #aaa; text-align: center; padding: 2rem; }
.err { color: #c0392b; font-size: 13px; }
.ok { color: #1a4f1a; font-size: 13px; }
.note { background: #e8f0fb; border-radius: 8px; padding: 8px 12px; font-size: 13px; color: #0d3a8a; }

/* Photo grid */
.pcount { display: inline-block; background: var(--brand,#16a34a); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
/* Multi-select dropdown */
.msdrop { position: relative; display: inline-block; }
.msbtn { min-width: 190px; text-align: left; padding: 10px 12px; border: 1px solid #d5d9e0; border-radius: 10px; background: #fff; font-size: 14px; cursor: pointer; }
.mspanel { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 220px; max-height: 280px; overflow-y: auto; background: #fff; border: 1px solid #d5d9e0; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 6px; }
.msopt { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.msopt:hover { background: #f1f5f9; }
.msopt input { width: 16px; height: 16px; flex-shrink: 0; }
.mssearch { width: 100%; box-sizing: border-box; padding: 8px 10px; margin-bottom: 6px; border: 1px solid #d5d9e0; border-radius: 8px; font-size: 14px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: #cbd5e1; transition: .2s; border-radius: 999px; }
.switch .slider:before { content: ""; position: absolute; height: 22px; width: 22px; left: 3px; bottom: 3px; background: #fff; transition: .2s; border-radius: 50%; }
.switch input:checked + .slider { background: var(--brand,#16a34a); }
.switch input:checked + .slider:before { transform: translateX(22px); }
.mediagrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.mediacard { background: #fff; border-radius: 12px; padding: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.pgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.pgrid img, .pgrid video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }

/* Period filter + prev/next navigation */
.pfilter { display: flex; gap: 4px; background: #eee; padding: 4px; border-radius: 10px; margin-bottom: .75rem; }
.pfilter button { flex: 1; padding: 9px 4px; border: none; background: transparent; border-radius: 7px; font-size: 13px; font-weight: 700; color: #666; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pfilter button.on { background: #fff; color: #1a1a1a; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.navrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 1rem; }
.navrow .nav-label { font-weight: 700; font-size: 15px; text-align: center; flex: 1; }
.navbtn { padding: 8px 14px; border: 1px solid #ddd; border-radius: 10px; background: #fff; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.navbtn:disabled { opacity: .4; cursor: default; }

/* Role-based UI gating (owner dashboard) — data-role is set on <body> at boot.
   Elements tagged .admin-only are hidden for non-admin roles. */
body[data-role="manager"] .admin-only,
body[data-role="payroll"] .admin-only,
body[data-role="viewer"]  .admin-only { display: none !important; }
/* A small role badge could be styled here later. */
.role-pill { font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: .3px; background: #eef2ff; color: #4338ca; }
/* Capability gates for static controls. */
body[data-role="payroll"] .cap-manageworkers,
body[data-role="viewer"]  .cap-manageworkers { display: none !important; }
body[data-role="viewer"]  .cap-anyedit { display: none !important; }
