* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { background: #f2f3f7; color: #222; font-size: 16px; -webkit-text-size-adjust: 100%; }

a { color: #3f51b5; text-decoration: none; }
.muted { color: #767a86; }
.small { font-size: 13px; }
.empty { padding: 18px; text-align: center; }

/* App shell */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; }
.content { padding: 14px 14px calc(40px + env(safe-area-inset-bottom, 0px)); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  background: #3f51b5; color: #fff;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.topbar .brand { flex: 1; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; text-decoration: none; }
.menu-btn, .avatar-link, .home-btn { background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; padding: 4px; text-decoration: none; line-height: 1; }
.clock-bar {
  background: #283593; color: #cdd4ff; font-size: 11px;
  text-align: right; padding: 3px 14px; letter-spacing: .3px;
}

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.drawer-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.4); opacity: 0; transition: opacity .2s; }
.drawer-menu {
  position: absolute; top: 0; left: 0; bottom: 0; width: 260px;
  background: #fff; list-style: none; padding: 20px 0;
  transform: translateX(-100%); transition: transform .22s ease;
  box-shadow: 2px 0 10px rgba(0,0,0,.2);
}
.drawer.open { pointer-events: auto; }
.drawer.open .drawer-overlay { opacity: 1; }
.drawer.open .drawer-menu { transform: translateX(0); }
.drawer-menu li a { display: block; padding: 14px 20px; color: #333; font-size: 16px; border-bottom: 1px solid #f0f0f0; }
.drawer-menu li a:active { background: #f0f0f0; }

/* Cards */
.card { background: #fff; border-radius: 14px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 14px; }
.list .card { display: block; }
.task-card { display: block; }
.task-title { font-weight: 600; font-size: 16px; line-height: 1.35; }
.task-meta { font-size: 13px; color: #767a86; margin-top: 3px; }
.task-card.late { border-left: 4px solid #e53935; }
.late-tag { color: #e53935; font-weight: 600; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { text-align: center; padding: 18px 10px; }
.stat-num { display: block; font-size: 30px; font-weight: 700; color: #3f51b5; }
.stat-label { color: #767a86; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }

/* Buttons */
.btn {
  display: inline-block; border: none; cursor: pointer; border-radius: 10px;
  padding: 12px 16px; font-size: 15px; text-align: center; font-weight: 600;
  transition: transform .05s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: #3f51b5; color: #fff; }
.btn-outline { background: #fff; color: #3f51b5; border: 2px solid #3f51b5; }
.btn-block { display: block; width: 100%; }
.btn-lg { padding: 15px; font-size: 16px; }
.btn-small { padding: 9px 12px; font-size: 13px; min-height: 36px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.quick-actions .btn { flex: 1 1 40%; min-width: 108px; }

/* Alerts */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.alert-success { background: #e8f5e9; color: #1b5e20; }
.alert-error { background: #fdecea; color: #b71c1c; }

/* Section titles */
.section-title { font-size: 15px; color: #5a5e6a; margin: 20px 0 10px; text-transform: uppercase; letter-spacing: .4px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 10px; }
.field-label { font-size: 13px; color: #767a86; margin-bottom: 2px; text-transform: uppercase; letter-spacing: .4px; }
input, select, textarea {
  width: 100%; padding: 12px; border: 1.5px solid #d5d8e0; border-radius: 10px;
  font-size: 16px; background: #fff; color: #222;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #3f51b5; }
textarea { resize: vertical; }
.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }
.form .field-row > div { display: flex; flex-direction: column; gap: 6px; }

/* Login */
.login-body { background: linear-gradient(160deg,#3f51b5,#5c6bc0); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border-radius: 18px; padding: 32px 24px; width: 100%; max-width: 360px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.login-logo { font-size: 52px; margin-bottom: 6px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card form { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.code-input { text-align: center; font-size: 30px; letter-spacing: 12px; padding: 12px; }

/* Person cards */
.person-card { display: flex; flex-direction: column; gap: 10px; }
.person-avatar {
  width: 44px; height: 44px; border-radius: 50%; background: #3f51b5; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; flex-shrink: 0;
}
.person-avatar.big { width: 56px; height: 56px; font-size: 26px; }
.person-info { flex: 1; min-width: 0; }
.profile-head { display: flex; align-items: center; gap: 14px; }

/* Progress */
.progress { height: 6px; background: #ececf1; border-radius: 6px; margin: 8px 0; overflow: hidden; }
.progress-fill { height: 100%; background: #3f51b5; }

/* Badges & chips */
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; text-transform: uppercase; }
.badge-pending { background: #fff3cd; color: #856404; }
.badge-progress { background: #cfe2ff; color: #084298; }
.badge-done { background: #d1e7dd; color: #0f5132; }
.chip { display: inline-block; background: #f0f1f5; color: #3f3f46; font-size: 13px; padding: 4px 10px; border-radius: 20px; margin-right: 6px; }
.info-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

/* Filter bar */
.filter-bar { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }

/* Voice */
.voice-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #eef1ff; border: 2px solid #d6dcff; }
.mic-btn {
  width: 56px; height: 56px; border-radius: 50%; border: none; background: #3f51b5; color: #fff;
  font-size: 26px; cursor: pointer; flex-shrink: 0;
}
.mic-btn.listening { background: #e53935; animation: pulse 1s infinite; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(229,57,53,.5);} 100%{box-shadow:0 0 0 16px rgba(229,57,53,0);} }
.voice-info { flex: 1; min-width: 200px; }
.voice-transcript { flex-basis: 100%; background: #fff; border-radius: 10px; padding: 10px; font-size: 15px; }
.voice-assigned-chip { display: inline-block; background: #3f51b5; color: #fff; font-size: 13px; padding: 4px 10px; border-radius: 20px; margin: 4px 4px 0 0; }

/* Photos */
.file-input { padding: 10px; }
.photo-preview { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-preview .ph { position: relative; width: 88px; height: 88px; }
.photo-preview .ph img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-item { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.photo-item img { width: 100%; height: 150px; object-fit: cover; display: block; }
.photo-item figcaption { padding: 8px; }
.gps-link { color: #3f51b5; word-break: break-all; }

/* Users & logs */
.user-card { display: flex; flex-direction: column; gap: 10px; }
.user-info { display: flex; align-items: center; gap: 12px; }
.user-body { flex: 1; min-width: 0; }
.user-actions { width: 100%; }
.user-actions summary { list-style: none; }
.user-actions summary::-webkit-details-marker { display: none; }
.inline-form { margin-top: 8px; padding: 10px; background: #f7f8fb; border-radius: 10px; display: flex; flex-direction: column; gap: 6px; }
.inline-form input[type=text], .inline-form input[type=password] { font-size: 14px; padding: 9px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 4px 0; }
.check input { width: auto; }
.log-item { padding: 12px 14px; }
.log-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-action { display: inline-block; background: #eef1ff; color: #3f51b5; font-weight: 600; font-size: 12px; padding: 2px 8px; border-radius: 20px; text-transform: uppercase; }
.log-who { font-weight: 600; }
.log-time { margin-top: 4px; word-break: break-word; }

/* WhatsApp button */
.wa-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #25D366; color: #fff; border-radius: 10px;
  padding: 10px 14px; font-size: 14px; font-weight: 600; text-decoration: none;
  border: none; cursor: pointer; line-height: 1;
}
.wa-btn:hover { background: #1ebe57; color: #fff; }
.wa-btn:active { transform: scale(.97); }
.wa-blank { background: #fff; color: #128C7E; border: 2px solid #25D366; }
.wa-blank:hover { background: #e9fbf0; color: #128C7E; }
.wa-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.task-link { display: block; text-decoration: none; color: inherit; }

/* Search & filters */
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input { flex: 1; }
.search-bar .btn { flex-shrink: 0; }
.person-filter { margin-bottom: 14px; }
.person-filter select { width: 100%; }

/* Delete / inline action buttons */
.del-btn { border-color: #e53935; color: #e53935; }
.inline-del { margin: 0; }
.person-actions { width: 100%; }
.person-actions summary { list-style: none; }
.person-actions summary::-webkit-details-marker { display: none; }
.person-actions .inline-form { min-width: 220px; }

/* Card header row + compact icon actions (visual hygiene) */
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-title-wrap { flex: 1; min-width: 0; }
.card-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.icon-btn {
  width: 34px; height: 34px; padding: 0; border: none; border-radius: 8px;
  background: #f0f1f5; color: #3f3f46; font-size: 15px; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.icon-btn:hover { background: #e2e4ea; }
.icon-btn.danger { color: #d32f2f; }
.icon-btn.danger:hover { background: #fdecea; }
.edit-panel { margin-top: 10px; }
.edit-panel[hidden] { display: none; }

/* Task updates / thread */
.thread { margin-top: 6px; }
.update-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f0f0f2; }
.update-item:last-child { border-bottom: none; }
.update-bubble { flex: 1; background: #f4f6fb; border-radius: 12px; padding: 10px 12px; }
.update-item.mine { flex-direction: row-reverse; }
.update-item.mine .update-bubble { background: #e6f6ee; }
.update-author { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.update-time { font-size: 12px; color: #9aa0ad; margin-top: 2px; }
.update-body { margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.update-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.update-photos img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; }

/* Priority badges */
.badge.pri-low, .pri-low { background: #d1e7dd; color: #0f5132; }
.badge.pri-medium, .pri-medium { background: #cfe2ff; color: #084298; }
.badge.pri-high, .pri-high { background: #ffe8cc; color: #b25e00; }
.badge.pri-urgent, .pri-urgent { background: #f8d7da; color: #b02a37; }
.btn.pri-low { background: #d1e7dd; color: #0f5132; border: 1px solid #a3cfbb; }
.btn.pri-medium { background: #cfe2ff; color: #084298; border: 1px solid #a9c7ff; }
.btn.pri-high { background: #ffe8cc; color: #b25e00; border: 1px solid #ffd08a; }
.btn.pri-urgent { background: #f8d7da; color: #b02a37; border: 1px solid #f2a6ad; }
.btn.pri-low.on, .btn.pri-medium.on, .btn.pri-high.on, .btn.pri-urgent.on { outline: 2px solid #3f51b5; }

/* Tags */
.tags { margin-top: 6px; }
.tag { display: inline-block; background: #eef1ff; color: #3f51b5; font-size: 12px; padding: 2px 8px; border-radius: 20px; margin: 2px 2px 0 0; }

/* One-tap status tabs */
.status-tabs { display: flex; gap: 6px; margin-top: 8px; }
.status-tabs .smini { margin: 0; }
.status-tabs .smini button { padding: 6px 8px; font-size: 12px; }

/* Kanban board */
.board { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; align-items: start; }
.board-col { background: #eceef3; border-radius: 12px; padding: 8px; }
.board-col-title { font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: #5a5e6a; margin-bottom: 8px; }
.board-card { background: #fff; border-radius: 10px; padding: 10px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.board-card .task-title { font-size: 14px; }
.board-moves { display: flex; gap: 6px; margin-top: 8px; }
.bmove { margin: 0; }

/* Photo lightbox */
.lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 100; align-items: center; justify-content: center; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 94vw; max-height: 90vh; border-radius: 6px; }
.lightbox .lb-close { position: absolute; top: 12px; right: 16px; color: #fff; font-size: 30px; cursor: pointer; background: none; border: none; }
img.lb { cursor: zoom-in; }

/* Small screens: board stacks vertically */
@media (max-width: 640px) {
  .board { grid-template-columns: 1fr; }
}

/* Small phones: stack two-column rows, tighten spacing, avoid cramped touch targets */
@media (max-width: 400px) {
  .content { padding-left: 12px; padding-right: 12px; }
  .card { padding: 14px; }
  .field-row { flex-direction: column; }
  .field-row > div { width: 100%; }
  .stats-grid { gap: 8px; }
  .photo-grid { gap: 8px; }
  .login-card { padding: 28px 20px; }
  .wa-btn { padding: 12px 14px; }
}
