* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: #f3f4f6; color: #111827; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: #6b7280; font-size: 0.9em; }
.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; padding: 8px 10px; border-radius: 8px; font-size: 0.9em; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; width: 100%; }
textarea { min-height: 64px; resize: vertical; }
label { display: block; font-size: 0.85em; font-weight: 600; color: #374151; margin: 10px 0 4px; }
label input, label select, label textarea { margin-top: 4px; font-weight: 400; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: #111827; }
.login-card { background: #fff; border-radius: 16px; padding: 28px 24px; width: 100%; max-width: 380px; }
.login-logo { font-size: 1.5em; font-weight: 800; }
.login-sub { color: #6b7280; margin-bottom: 8px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.8em; }

/* Buttons */
.btn { border: 1px solid #d1d5db; background: #fff; color: #111827; border-radius: 9px; padding: 8px 14px; font-weight: 600; font-size: 0.92em; }
.btn.primary { background: #111827; color: #fff; border-color: #111827; }
.btn.green { background: #059669; border-color: #059669; color: #fff; }
.btn.blue { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn.danger { background: #fff; color: #b91c1c; border-color: #fca5a5; }
.btn.small { padding: 5px 10px; font-size: 0.85em; }
.btn.big { width: 100%; padding: 12px; margin-top: 14px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn { background: none; border: none; font-size: 1.15em; position: relative; padding: 6px; }

/* Shell */
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }
.topbar-title { font-weight: 800; font-size: 1.05em; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.whoami { font-size: 0.85em; color: #4b5563; font-weight: 600; }
.badge { position: absolute; top: 0; right: 0; background: #dc2626; color: #fff; border-radius: 999px; font-size: 0.62em; padding: 1px 5px; font-weight: 700; }
main { padding: 14px 14px 96px; max-width: 860px; margin: 0 auto; }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #111827; display: flex; padding-bottom: env(safe-area-inset-bottom); }
.nav-btn { flex: 1; background: none; border: none; color: #9ca3af; padding: 8px 2px 10px; font-size: 1.15em; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.nav-btn span { font-size: 0.58em; font-weight: 600; }
.nav-btn.active { color: #fff; }

/* Cards & sections */
.card { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 12px; border: 1px solid #e5e7eb; }
.section-title { font-size: 1.02em; font-weight: 800; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 2px; }
.count-pill { background: #111827; color: #fff; border-radius: 999px; font-size: 0.72em; padding: 1px 8px; font-weight: 700; }
.count-pill.red { background: #dc2626; }
.count-pill.amber { background: #d97706; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.case-title { font-weight: 700; }
.case-sub { color: #4b5563; font-size: 0.9em; }
.note-line { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 8px; padding: 6px 9px; font-size: 0.88em; margin-top: 8px; }
.overdue { color: #b91c1c; font-weight: 700; }
.stage-chip { display: inline-block; border-radius: 999px; color: #fff; font-size: 0.75em; font-weight: 700; padding: 2px 9px; white-space: nowrap; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid #d1d5db; background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 0.85em; font-weight: 600; }
.chip.on { background: #111827; color: #fff; border-color: #111827; }
.empty { color: #6b7280; background: #fff; border: 1px dashed #d1d5db; border-radius: 12px; padding: 16px; text-align: center; }

/* Sheet */
.backdrop { position: fixed; inset: 0; background: rgba(17,24,39,0.5); z-index: 40; }
.sheet { position: fixed; z-index: 41; background: #fff; left: 0; right: 0; bottom: 0; top: 6vh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; }
@media (min-width: 760px) { .sheet { left: 50%; right: auto; transform: translateX(-50%); width: 680px; top: 4vh; border-radius: 18px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #e5e7eb; }
.sheet-title { font-weight: 800; font-size: 1.05em; }
.sheet-body { overflow-y: auto; padding: 14px 16px 30px; }

/* Forms & pickers */
.notes-panel { background: #fffbeb; border: 1px solid #f59e0b; border-radius: 12px; padding: 10px 12px; margin: 12px 0; }
.notes-panel .np-title { font-weight: 800; color: #92400e; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.03em; }
.setpick { border: 1px solid #e5e7eb; border-radius: 10px; max-height: 260px; overflow-y: auto; }
.setpick-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid #f3f4f6; }
.setpick-row:last-child { border-bottom: none; }
.setpick-row input[type="checkbox"] { width: auto; }
.setpick-row .qty { width: 62px; }
.search-input { margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 118px 1fr; gap: 4px 10px; font-size: 0.94em; }
.kv dt { color: #6b7280; font-weight: 600; }
.kv dd { margin: 0; }
.stepper { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0; }
.step { font-size: 0.72em; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #e5e7eb; color: #6b7280; }
.step.done { background: #111827; color: #fff; }
.step.now { outline: 2px solid #111827; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photo-cell { border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; background: #fff; }
.photo-cell img { width: 100%; height: 100px; object-fit: cover; display: block; }
.photo-cell .pc-body { padding: 6px 8px; font-size: 0.8em; }
.approved-tag { color: #059669; font-weight: 700; }
.pending-tag { color: #d97706; font-weight: 700; }
.timeline { border-left: 2px solid #e5e7eb; margin-left: 6px; padding-left: 14px; }
.timeline .tl-item { margin-bottom: 10px; font-size: 0.9em; }
.timeline .tl-when { color: #6b7280; font-size: 0.8em; }

/* Assets */
.asset-row { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-bottom: 1px solid #f3f4f6; background: #fff; }
.asset-row input[type="checkbox"] { width: auto; }
.loc-group-title { font-weight: 800; margin: 14px 0 6px; font-size: 0.95em; }
.bulkbar { position: sticky; bottom: 84px; z-index: 20; background: #111827; color: #fff; border-radius: 12px; padding: 10px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bulkbar .btn { border-color: #374151; }
select.inline { width: auto; }

/* Calendar */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: 0.72em; font-weight: 700; color: #6b7280; text-align: center; padding: 4px 0; }
.cal-cell { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; min-height: 74px; padding: 4px; font-size: 0.72em; }
.cal-cell.dim { opacity: 0.45; }
.cal-cell .dnum { font-weight: 700; font-size: 1.05em; }
.cal-case { border-radius: 5px; color: #fff; padding: 1px 5px; margin-top: 3px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }

/* Toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 92px; z-index: 60; background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 0.92em; max-width: 92vw; box-shadow: 0 6px 24px rgba(0,0,0,0.25); }
.toast.err { background: #b91c1c; }
.list-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid #f3f4f6; }
.list-row:last-child { border-bottom: none; }
.notif-unread { background: #eff6ff; }
h3.view-title { margin: 2px 0 12px; font-size: 1.2em; }
details.more-sec { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 6px 14px 12px; margin-bottom: 12px; }
details.more-sec summary { font-weight: 800; padding: 8px 0; cursor: pointer; }
