* { 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; display: block; text-decoration: none; }
/* CRM pipeline board */
.crm-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.crm-col { flex: 0 0 250px; min-width: 250px; background: var(--wa-panel2); border-radius: 12px; padding: 8px; }
.crm-col-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 13px; padding: 4px 8px 8px; }
.crm-col-cards { display: flex; flex-direction: column; gap: 8px; }
.crm-card { background: var(--wa-panel); border: 1px solid var(--wa-border); border-radius: 10px; padding: 10px; }
.crm-card .task-title { font-size: 14px; margin-bottom: 2px; }
.crm-col-count { background: var(--wa-panel); color: var(--wa-muted); font-size: 12px; font-weight: 700; border-radius: 20px; padding: 1px 8px; }
.crm-empty { color: var(--wa-muted); font-size: 12px; border: 1px dashed var(--wa-border); border-radius: 8px; padding: 12px; text-align: center; }
.crm-meta { font-size: 12px; color: var(--wa-muted); margin-top: 3px; }
.crm-meta b { color: var(--wa-text); }
.crm-follow { color: var(--wa-green); }
.crm-follow.overdue { color: #c0392b; }
.small-select { padding: 4px 6px; font-size: 12px; border-radius: 8px; border: 1px solid var(--wa-border); background: var(--wa-panel); color: var(--wa-text); }

/* ---------- CRM page: desktop-first clean layout ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .page-title { font-size: 20px; font-weight: 800; color: var(--wa-text); }
.page-head .page-sub { font-size: 13px; color: var(--wa-muted); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.crm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.crm-stats.crm-dash { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 0; }
.crm-stat { background: var(--wa-panel); border: 1px solid var(--wa-border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; transition: box-shadow .12s; }
.crm-stat:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.crm-stat .v { font-size: 26px; font-weight: 800; color: var(--wa-green); line-height: 1; }
.crm-stat .l { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--wa-muted); }
.crm-stat.warn .v { color: #ef6c00; }
.crm-stat.blue .v { color: #3f51b5; }

.crm-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px 12px; }
/* Filters form: each control shares the available row width evenly (search is wider), so
   nothing grows into one giant element and controls sit side-by-side on desktop. */
.crm-toolbar .crm-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }
.crm-toolbar select { padding: 9px 10px; border-radius: 10px; border: 1px solid var(--wa-border); background: var(--wa-panel); color: var(--wa-text); font-size: 14px; }
.crm-toolbar .crm-filters select { flex: 1 1 120px; }
.crm-toolbar .crm-filters .btn { flex: 0 1 auto; }
.crm-toolbar .search { flex: 2 1 200px; max-width: 320px; min-width: 160px; }
.crm-toolbar input[type="search"] { width: 100%; box-sizing: border-box; }
.crm-toolbar .toolbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
/* CRM deal form: Company & Contact sit side-by-side on desktop (compact), stack on small screens */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.grid-2 .grid-cell { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.grid-2 select,
.grid-2 input[type="text"],
.grid-2 input[type="email"],
.grid-2 input[type="tel"] { width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--wa-border); background: var(--wa-panel); color: var(--wa-text); font-size: 14px; }
.grid-2 .mini-row { display: flex; gap: 8px; }
.grid-2 .mini-row input { flex: 1 1 120px; min-width: 0; }
.grid-2 .hint { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--wa-muted); margin-top: 6px; }
@media (max-width: 620px) { .grid-2 .mini-row { flex-direction: column; } }
/* Compact inline "add" forms (e.g. Add contact): fields flow in a row on desktop, wrap on small screens */
.quick-add { margin-top: 8px; padding: 10px; background: #f7f8fb; border-radius: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.quick-add input, .quick-add select { flex: 1 1 150px; min-width: 0; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--wa-border); background: #fff; color: var(--wa-text); font-size: 14px; box-sizing: border-box; }
.quick-add .btn { flex: 0 0 auto; }
@media (max-width: 620px) { .quick-add { flex-direction: column; align-items: stretch; } .quick-add input, .quick-add select { width: 100%; } }
.seg { display: inline-flex; background: var(--wa-panel2); border: 1px solid var(--wa-border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg a { padding: 6px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--wa-muted); text-decoration: none; white-space: nowrap; }
.seg a.on { background: var(--wa-panel); color: var(--wa-green); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.crm-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; font-size: 14px; color: var(--wa-text); margin-bottom: 10px; }
.crm-section-head .count { font-size: 12px; color: var(--wa-muted); font-weight: 600; }

.follow-cols { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.follow-sec-title { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; color: var(--wa-muted); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.follow-sec-title .pill { background: var(--wa-panel2); color: var(--wa-muted); border-radius: 20px; padding: 1px 8px; font-size: 11px; }
.follow-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--wa-border); border-radius: 10px; margin-bottom: 8px; background: var(--wa-panel); }
.follow-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: #c0392b; }
.follow-item .dot.up { background: #ef6c00; }
.follow-body { flex: 1; min-width: 0; }
.follow-body .t { font-weight: 700; font-size: 14px; color: var(--wa-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.follow-body .s { font-size: 12px; color: var(--wa-muted); margin-top: 1px; }
.follow-item .btn { flex-shrink: 0; }

.crm-table-wrap { overflow-x: auto; }
.crm-table { width: 100%; border-collapse: collapse; }
.crm-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--wa-muted); border-bottom: 2px solid var(--wa-border); padding: 8px 10px; white-space: nowrap; }
.crm-table td { padding: 12px 10px; border-bottom: 1px solid var(--wa-border); font-size: 14px; vertical-align: middle; color: var(--wa-text); }
.crm-table tbody tr:hover { background: var(--wa-panel2); }
.crm-table .cell-title { font-weight: 700; color: var(--wa-green); text-decoration: none; }
.crm-table .value { font-weight: 700; white-space: nowrap; }
.crm-table .muted2 { color: var(--wa-muted); font-size: 13px; }
.crm-table .row-actions { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.stage-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.stage-pill i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
/* Public-holiday calendar */
.cal-wrap { overflow-x: auto; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(72px, 1fr)); gap: 4px; min-width: 540px; }
.cal-h { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--wa-muted); text-align: center; padding: 4px 0; }
.cal-cell { min-height: 62px; border: 1px solid var(--wa-border); border-radius: 8px; padding: 4px; background: var(--wa-panel); display: flex; flex-direction: column; align-items: center; }
.cal-cell.cal-off { opacity: .45; background: transparent; }
.cal-cell.cal-hol { border-color: var(--wa-green); background: #e7f9e7; }
.cal-day { font-size: 14px; font-weight: 600; }
.cal-name { font-size: 10px; line-height: 1.1; text-align: center; color: #0f5132; }
.cal-add, .cal-x { border: none; border-radius: 6px; cursor: pointer; font-size: 11px; padding: 1px 6px; background: #eef1ff; color: #3f51b5; }
.cal-x { background: #f8d7da; color: #b02a37; }
.cal-add:hover { background: #d6dcff; }
.cal-x:hover { background: #f1aeb5; }
.stat:hover .stat-num { text-decoration: underline; }
.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-flex; align-items: center; justify-content: center; gap: 6px; 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, select, textarea, button { font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #3f51b5; }
textarea { resize: vertical; }
.field-row { display: flex; flex-wrap: wrap; gap: 10px; }
.field-row > div { flex: 1 1 160px; }
.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; }
.task-count-link { color: #3f51b5; font-weight: 600; text-decoration: none; }
.task-count-link:hover { text-decoration: underline; }

/* 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; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 6px; }
.mic-btn {
  width: 42px; height: 42px; border-radius: 50%; border: none; background: var(--wa-green); color: #fff;
  font-size: 20px; cursor: pointer; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
}
.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 { margin-top: 4px; font-size: 14px; color: var(--wa-green); padding: 0; }
.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: 7px; font-size: 14px; margin: 4px 0; line-height: 1.4; }
.check input { width: auto; flex-shrink: 0; margin: 0; }
.check > span { min-width: 0; }
.check-row { padding: 8px 0 2px; border-bottom: 1px solid var(--wa-border); margin-bottom: 4px; }
.check-row:last-child { border-bottom: 0; }
/* Segmented role picker (Team member / Manager / Admin) */
.role-picker { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.role-picker > label { flex: 1 1 auto; min-width: 96px; text-align: center; border: 1px solid var(--wa-border); border-radius: 10px; padding: 9px 6px; cursor: pointer; font-size: 13px; background: #fff; position: relative; }
.role-picker > label:hover { border-color: var(--wa-green); }
.role-picker input { position: absolute; opacity: 0; pointer-events: none; }
.role-picker > label:has(input:checked) { background: var(--wa-soft); border-color: var(--wa-green); font-weight: 600; }
.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; }
.header-count { font-size: 12px; font-weight: 400; opacity: .85; }
.ic { display: inline-block; vertical-align: -0.18em; flex-shrink: 0; }
.ic-btn { display: inline-flex; align-items: center; justify-content: center; border: none; background: none; color: inherit; cursor: pointer; padding: 6px; border-radius: 8px; }
.ic-btn:hover { background: rgba(0,0,0,.06); }
.sidebar-links li a { display: flex; align-items: center; gap: 10px; }
.sidebar-links li a.active { background: var(--wa-green); color: #fff; }
.sidebar-links li a.active .ic { color: #fff; }
.sidebar-links li a .ic { color: var(--wa-green); }

/* Accordion sidebar groups */
.sidebar-links .group { border-bottom: 1px solid #f0f0f0; }
.group-toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px 20px; background: none; border: none; cursor: pointer; font-size: 15px; font-weight: 600; color: #333; text-align: left; }
.group-toggle:hover { background: #f4f6fb; }
.group-toggle .ic { color: var(--wa-green); }
.group-toggle .group-chevron { margin-left: auto; color: var(--wa-green); transition: transform .22s ease; }
.sidebar-links li.group.open .group-toggle .group-chevron { transform: rotate(180deg); }
.group-links { list-style: none; margin: 0; padding: 0; }
.group-links[hidden] { display: none; }
/* Section labels inside an expanded sidebar group (e.g. Social Media) */
.group-links .nav-subhead {
  display: block; padding: 13px 20px 3px; font-size: 11px; line-height: 1.2;
  font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--wa-muted);
}
.group-links .nav-subhead:first-child { padding-top: 8px; }
.group-links .nav-subhead + li { margin-top: 0; }

/* Friendlier task form */
.big-input { font-size: 18px; padding: 14px 16px; }
.chip-check { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.chip-check-item { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--wa-border); border-radius: 18px; padding: 5px 11px; cursor: pointer; font-size: 13px; background: #fff; user-select: none; white-space: nowrap; flex: 0 0 auto; max-width: 100%; }
.chip-check-item:hover { border-color: var(--wa-green); }
.chip-check-item input { margin: 0; accent-color: var(--wa-green); }
.chip-check-item:has(input:checked) { background: var(--wa-soft); border-color: var(--wa-green); font-weight: 600; }
.assign-head { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 2px; }
.assign-count { font-size: 12px; color: var(--wa-muted); font-weight: 600; }
.assign-org { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--wa-muted); margin: 8px 0 1px; }
.assign-org:first-child { margin-top: 0; }
.assign-list { margin-top: 4px; }
.assign-row { display: block; padding: 5px 0; font-size: 14px; color: var(--wa-text); cursor: pointer; line-height: 1.3; }
.assign-row + .assign-row { border-top: 1px solid var(--wa-border); }
.assign-row input { width: 17px; height: 17px; margin: 0 7px 0 0; vertical-align: -2px; accent-color: var(--wa-green); }
/* Scope checkbox resets for inline rows where the global input rule would otherwise
   stretch the box (width:100% + big padding). Used on workflow/checklist rows. */
.wf-check { width: 17px; height: 17px; flex-shrink: 0; margin: 3px 0 0 0; padding: 0; border: none; border-radius: 3px; accent-color: var(--wa-green); }
.wf-row { display: flex; align-items: flex-start; gap: 9px; padding: 6px 2px; border-bottom: 1px dashed var(--wa-border); }
.wf-row:last-child { border-bottom: none; }
.wf-row .wf-title { flex: 1; min-width: 0; line-height: 1.35; font-size: 14px; }
.chat-details { overflow-x: hidden; }
.advanced summary { cursor: pointer; font-weight: 600; color: var(--wa-green); padding: 10px 0 4px; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 6px; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced-body { margin-top: 10px; border-top: 1px dashed var(--wa-border); padding-top: 14px; }
/* The HTML `hidden` attribute must always win over any display rule */
[hidden] { display: none !important; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--wa-muted); }
.empty-icon { font-size: 44px; margin-bottom: 10px; opacity: .5; }
.empty-state .btn { margin-top: 10px; }

/* Toast notifications (auto-converted from any .alert) */
.toast-wrap { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 0; right: 0; z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 14px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 460px; width: 100%; background: #333; color: #fff; border-radius: 10px; padding: 12px 14px; box-shadow: 0 4px 14px rgba(0,0,0,.25); font-size: 14px; line-height: 1.4; animation: toastIn .2s ease; cursor: pointer; }
.toast.alert-success { background: #0b8457; }
.toast.alert-error { background: #c0392b; }
.toast.alert-info { background: #2c3e50; }
.toast a { color: #fff; text-decoration: underline; }
@keyframes toastIn { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
.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; cursor: zoom-in; transition: transform .2s ease; }
.lightbox img.zoomed { transform: scale(1.6); cursor: zoom-out; }
.lightbox .lb-close { position: absolute; top: 12px; right: 16px; color: #fff; font-size: 30px; cursor: pointer; background: none; border: none; z-index: 2; }
.lightbox .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; font-size: 26px; line-height: 1; background: rgba(0,0,0,.45); border: none; border-radius: 50%; width: 44px; height: 44px; cursor: pointer; z-index: 2; }
.lightbox .lb-prev { left: 12px; }
.lightbox .lb-next { right: 12px; }
.lightbox .lb-count { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #fff; font-size: 14px; opacity: .85; z-index: 2; }
img.lb { cursor: zoom-in; }

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

/* ============================================================
   WhatsApp theme
   ============================================================ */
:root {
  --wa-bg: #ece5dd;          /* app background */
  --wa-panel: #ffffff;       /* cards / panels */
  --wa-panel2: #f0f2f5;      /* secondary panel */
  --wa-green: #008069;       /* primary green */
  --wa-green-dark: #075e54;  /* dark green header */
  --wa-green-bright: #25d366;
  --wa-soft: #d9fdd3;        /* soft green (outgoing bubble) */
  --wa-text: #111b21;
  --wa-muted: #667781;
  --wa-border: #e9edef;
  --wa-sidebar: #111b21;     /* desktop sidebar */
  --wa-sidebar-hover: #202c33;
}

body { background: var(--wa-bg); }
a { color: var(--wa-green); }
.muted { color: var(--wa-muted); }

/* Header + clock */
.topbar { background: var(--wa-green); }
.topbar .brand { color: #fff; }
.clock-bar { background: var(--wa-green-dark); color: #cfe6e0; }

/* Buttons */
.btn-primary { background: var(--wa-green); color: #fff; border: 1px solid var(--wa-green); }
.btn-primary:hover { background: #017561; }
.btn-outline { background: #fff; color: var(--wa-green); border: 1px solid var(--wa-green); }
.btn-small { padding: 9px 12px; font-size: 13px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.del-btn { border-color: #e53935; color: #e53935; }
.btn.pri-low, .pri-low, .badge.pri-low { background: #d1e7dd; color: #0f5132; }
.btn.pri-medium, .pri-medium, .badge.pri-medium { background: #cfe2ff; color: #084298; }
.btn.pri-high, .pri-high, .badge.pri-high { background: #ffe8cc; color: #b25e00; }
.btn.pri-urgent, .pri-urgent, .badge.pri-urgent { background: #f8d7da; color: #b02a37; }

/* Cards & accents */
.card { background: var(--wa-panel); }
.stat-num { color: var(--wa-green); }
.gps-link, .task-count-link, .tag, .log-action { color: var(--wa-green); }
.log-action { background: var(--wa-soft); color: #0b6e4f; }
.progress-fill { background: var(--wa-green); }
.alert-success { background: #e7f9e7; color: #0b6e4f; }
.voice-card { background: #e7f9e7; border-color: #b9e4bb; }
.wa-blank { background: #fff; color: #128c7e; border-color: var(--wa-green-bright); }

/* Sidebar brand/foot (hidden on mobile, shown in desktop sidebar) */
.sidebar-brand { display: none; }
.sidebar-foot { display: none; }

/* Login page */
.login-body { background: linear-gradient(160deg, #075e54, #008069); }
.login-card h1 { color: #075e54; }
.login-logo { color: #008069; }

/* ---------- Desktop: two-pane WhatsApp-style layout ---------- */
@media (min-width: 900px) {
  .app { display: flex; align-items: stretch; max-width: none; width: 100%; min-height: 100vh; }
  .topbar { display: none; }
  .clock-bar { display: none; }

  .drawer {
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    flex: 0 0 300px; width: 300px; pointer-events: auto; z-index: 10;
    background: var(--wa-sidebar);
  }
  .drawer-overlay { display: none; }
  .drawer-menu {
    position: static; transform: none; width: 100%; height: 100%;
    background: transparent; box-shadow: none; padding: 0;
    display: flex; flex-direction: column;
  }
  .drawer-menu .sidebar-brand {
    display: flex; align-items: center; padding: 22px 20px;
    font-size: 20px; font-weight: 700; color: #fff;
    background: var(--wa-green); letter-spacing: .3px;
  }
  .drawer-menu .sidebar-links { flex: 1; list-style: none; margin: 0; padding: 8px 0; }
  .drawer-menu .sidebar-links li a {
    color: #aebac1; border-bottom: 1px solid #202c33; padding: 13px 20px; font-size: 15px;
  }
  .drawer-menu .sidebar-links li a:hover { background: var(--wa-sidebar-hover); color: #fff; }
  .sidebar-links .group { border-bottom: 1px solid #202c33; }
  .group-toggle { color: #aebac1; }
  .group-toggle:hover { background: var(--wa-sidebar-hover); color: #fff; }
  .group-toggle:hover .ic, .group-toggle:hover .group-chevron { color: #fff; }
  .drawer-menu .sidebar-foot {
    display: block; padding: 14px 20px; color: #8696a0; font-size: 13px;
    border-top: 1px solid #202c33; background: #162023;
  }
  .content { flex: 1; min-width: 0; border-left: 1px solid #000; padding: 22px 28px 50px; }
}

/* ============================================================
   WhatsApp-style list rows & chat
   ============================================================ */
.wa-list { background: var(--wa-panel); border-radius: 0; box-shadow: none; padding: 0; }
.wa-row-item { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--wa-border); text-decoration: none; color: inherit; }
.wa-row-item:last-child { border-bottom: none; }
.wa-row-item:hover { background: #f0f2f5; }
.wa-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--wa-green); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; flex-shrink: 0; }
.wa-avatar.group { background: #dfe5e7; color: #54656f; }
.wa-row-body { flex: 1; min-width: 0; }
.wa-row-title { font-weight: 600; color: var(--wa-text); }
.wa-row-sub { font-size: 13px; color: var(--wa-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-project { font-size: 12px; color: var(--wa-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-project-none { color: var(--wa-muted); font-style: italic; opacity: .7; }
.wa-row-meta { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.wa-row-right { color: var(--wa-muted); font-size: 12px; flex-shrink: 0; }
.wa-chevron { color: #8696a0; font-size: 20px; margin-left: 4px; }
.wa-row-actions { padding: 12px 16px; background: #f7f8fa; border-top: 1px solid var(--wa-border); }
.wa-row-actions[hidden] { display: none; }
.wa-row-actions .inline-form input, .wa-row-actions .inline-form textarea, .wa-row-actions select { width: 100%; }
.wa-member-chip { display: inline-flex; align-items: center; gap: 6px; margin: 2px 4px 2px 0; }
.wa-quick { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.quick-btn { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; text-decoration: none; background: #eef2f3; color: var(--wa-green); }
.quick-btn:active { background: #d7e3e6; }
.unread-badge { background: #25d366 !important; color: #fff; border-radius: 12px; min-width: 18px; height: 18px; line-height: 18px; padding: 0 6px; font-size: 11px; font-weight: 700; text-align: center; }

/* Chat view */
.chat-head { display: flex; align-items: center; gap: 10px; background: var(--wa-panel); padding: 10px 12px; border-bottom: 1px solid var(--wa-border); position: sticky; top: 0; z-index: 5; }
.chat-back { font-size: 26px; color: var(--wa-green); text-decoration: none; line-height: 1; padding: 2px 4px; }
.chat-title-wrap { flex: 1; min-width: 0; }
.chat-thread { padding: 14px 14px 90px; background: rgba(236,229,221,.35); }
.chat-bubble { max-width: 82%; padding: 7px 11px; border-radius: 12px; margin-bottom: 10px; word-break: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.chat-bubble.in { background: #fff; border-top-left-radius: 2px; }
.chat-bubble.out { background: var(--wa-soft); border-top-right-radius: 2px; margin-left: auto; }
.chat-author { font-size: 12px; font-weight: 700; color: var(--wa-green); margin-bottom: 2px; }
.chat-body { white-space: pre-wrap; font-size: 14.5px; color: var(--wa-text); }
.chat-body a { color: #0b57d0; text-decoration: underline; word-break: break-all; }
.chat-time { font-size: 11px; color: var(--wa-muted); text-align: right; margin-top: 4px; }
.chat-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chat-photos img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; }
.chat-bar { position: sticky; bottom: 0; background: var(--wa-panel); padding: 10px 12px; border-top: 1px solid var(--wa-border); display: flex; align-items: flex-end; gap: 8px; z-index: 5; }
.chat-bar textarea { flex: 1; border-radius: 22px; padding: 10px 14px; resize: none; min-height: 42px; max-height: 120px; border: 1px solid var(--wa-border); }
.chat-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--wa-green); color: #fff; border: none; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; flex-shrink: 0; text-decoration: none; }
.chat-icon.ghost { background: transparent; color: var(--wa-muted); font-size: 22px; }
.chat-details { padding: 14px; background: var(--wa-panel); border-bottom: 1px solid var(--wa-border); }
.chat-details[hidden] { display: none; }
.chat-actionbar { padding: 8px 12px; background: var(--wa-panel); border-bottom: 1px solid var(--wa-border); }
.chat-actionbar form { margin: 0; }
.chat-actionbar .btn { width: 100%; }
.done-pill { text-align: center; color: #0b8457; font-weight: 600; background: var(--wa-soft); border-radius: 22px; padding: 11px; }
.chat-empty { text-align: center; color: var(--wa-muted); padding: 40px 16px; }

/* On mobile, pin the chat header just below the sticky topbar */
@media (max-width: 899px) {
  .chat-head { top: 68px; }
}


/* Small phones: stack two-column rows, tighten spacing, avoid cramped touch targets */
@media (max-width: 620px) {
  .field-row { flex-direction: column; }
  .field-row > div { width: 100%; flex: 1 1 100%; }
  .crm-stats { grid-template-columns: 1fr 1fr; }
  .follow-cols { grid-template-columns: 1fr; }
  .crm-toolbar .toolbar-right { margin-left: 0; }
}
@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; }
}

/* ---------- Task details panel polish ---------- */
.chat-details { padding: 16px 16px 22px; background: linear-gradient(180deg, var(--wa-panel), var(--wa-panel2)); }
.chat-details .details-title { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 700; color: var(--wa-green); margin-bottom: 12px; }
.chat-details .form { gap: 5px; }
.chat-details .form input, .chat-details .form select, .chat-details .form textarea {
  width: 100%; box-sizing: border-box; padding: 11px 13px; border-radius: 12px;
  border: 1px solid var(--wa-border); background: var(--wa-panel); font-size: 14.5px; color: var(--wa-text);
}
.chat-details .form input:focus, .chat-details .form select:focus, .chat-details .form textarea:focus {
  border-color: var(--wa-green); outline: none; box-shadow: 0 0 0 3px rgba(0,128,105,.12);
}
.chat-details .chip { background: var(--wa-panel2); color: var(--wa-muted); display: inline-flex; align-items: center; gap: 5px; }
.chat-details .wa-btn { border-radius: 12px; padding: 11px 14px; }
.chat-details .section-title { font-size: 14px; margin: 16px 0 8px; }
.chat-details .photo-grid { gap: 8px; }

/* ---------- Readability pass ---------- */
body { font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
.task-title, .wa-row-title { font-weight: 600; letter-spacing: -.1px; }
.wa-row-sub { font-weight: 400; }
.section-title { font-weight: 700; }
.field-label { font-size: 12px; font-weight: 600; letter-spacing: .2px; color: var(--wa-muted); }
.org-head { display: flex; align-items: center; gap: 6px; padding: 14px 16px 6px; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--wa-green); }
.dept-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  --wa-bg: #0b141a;
  --wa-panel: #111b21;
  --wa-panel2: #202c33;
  --wa-soft: #005c4b;
  --wa-text: #e9edef;
  --wa-muted: #8696a0;
  --wa-border: #2a3942;
}
[data-theme="dark"] body { background: var(--wa-bg); color: var(--wa-text); }
[data-theme="dark"] .muted { color: var(--wa-muted); }
[data-theme="dark"] .card { background: var(--wa-panel); color: var(--wa-text); box-shadow: 0 1px 3px rgba(0,0,0,.5); }
[data-theme="dark"] .task-title, [data-theme="dark"] .section-title { color: var(--wa-text); }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { background: #202c33; color: var(--wa-text); border: 1px solid #2a3942; }
[data-theme="dark"] input::placeholder, [data-theme="dark"] textarea::placeholder { color: #667781; }
[data-theme="dark"] .wa-list { background: var(--wa-panel); }
[data-theme="dark"] .wa-row-item:hover { background: #202c33; }
[data-theme="dark"] .wa-row-actions { background: #0f1a20; border-top: 1px solid var(--wa-border); }
[data-theme="dark"] .chat-head, [data-theme="dark"] .chat-bar, [data-theme="dark"] .chat-details { background: var(--wa-panel); border-color: var(--wa-border); }
[data-theme="dark"] .chat-thread { background: rgba(0,0,0,.28); }
[data-theme="dark"] .chat-bubble.in { background: #202c33; color: var(--wa-text); }
[data-theme="dark"] .chat-bubble.out { background: var(--wa-soft); color: #e9edef; }
[data-theme="dark"] .chat-time { color: rgba(255,255,255,.5); }
/* ===== WhatsApp-style task chat (body.wa-chat) ===== */
/* Shared scroll-region look (both mobile phone-frame and desktop pane) */
body.wa-chat .wa-scroll {
  background-color: #efeae2;
  background-image: radial-gradient(rgba(141,129,113,.18) 1px, transparent 1px);
  background-size: 22px 22px; }
body.wa-chat .chat-thread { background: none; }
body.wa-chat .wa-scroll::-webkit-scrollbar { width: 6px; }
body.wa-chat .wa-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); border-radius: 3px; }

body.wa-chat[data-theme="dark"] .wa-scroll {
  background-color: #0b141a;
  background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px);
}
body.wa-chat[data-theme="dark"] .chat-bubble.in { background: #202c33; }

/* Mobile phone-frame (<900px): the whole app fills the viewport, composer pinned to the bottom */
@media (max-width: 899px) {
  body.wa-chat .app { height: 100vh; height: -webkit-fill-available; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  body.wa-chat { height: 100%; overscroll-behavior: none; }
  body.wa-chat .topbar, body.wa-chat .clock-bar { flex: 0 0 auto; }
  body.wa-chat .content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
    padding: 0 0 env(safe-area-inset-bottom, 0px); }
  body.wa-chat .content > .alert { flex: 0 0 auto; margin: 8px 10px 0; }
  body.wa-chat .chat-head { position: relative; top: auto; flex: 0 0 auto; border-radius: 0; }
  body.wa-chat .chat-actionbar { flex: 0 0 auto; border-radius: 0; }
  body.wa-chat .wa-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.22) transparent; }
  body.wa-chat .chat-empty { padding: 60px 16px; }
  body.wa-chat .chat-bar { position: relative; bottom: auto; flex: 0 0 auto; border-radius: 0; }
}


/* ===== WhatsApp-accurate recalibration (task chat) ===== */
body.wa-chat .chat-head,
body.wa-chat .chat-actionbar,
body.wa-chat .chat-bar { background: #f0f2f5; border-color: #e9edef; }
body.wa-chat .chat-head { padding: 8px 14px; }
body.wa-chat .chat-back { font-size: 22px; color: #54656f; }
body.wa-chat .task-title { font-size: 16px; color: #111b21; }
body.wa-chat .task-meta { font-size: 12.5px; }
body.wa-chat .chat-actionbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 12px; }
body.wa-chat .chat-actionbar .btn { padding: 5px 12px; font-size: 12.5px; min-height: 30px; border-radius: 18px; }
body.wa-chat .chat-actionbar form { margin: 0; }
body.wa-chat .done-pill { padding: 5px 12px; font-size: 12.5px; border-radius: 18px; margin: 0; }

body.wa-chat .chat-thread { padding: 10px 10px 14px; }
body.wa-chat .chat-bubble { max-width: 75%; padding: 6px 9px; border-radius: 9px; margin-bottom: 3px; box-shadow: none; }
body.wa-chat .chat-bubble.in { background: #ffffff; border-top-left-radius: 2px; }
body.wa-chat .chat-bubble.out { background: #d9fdd3; border-top-right-radius: 2px; margin-left: auto; }
body.wa-chat .chat-body { font-size: 14.2px; line-height: 1.4; color: #111b21; }
body.wa-chat .chat-author { font-size: 13px; line-height: 1.2; margin-bottom: 1px; }
body.wa-chat .chat-time { font-size: 11px; line-height: 1; margin-top: 3px; color: #667781; }

body.wa-chat .chat-bar { padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px)); gap: 6px; }
body.wa-chat .chat-bar textarea { font-size: 15px; line-height: 1.3; padding: 8px 14px; min-height: 38px; max-height: 120px; border-radius: 20px; background: #ffffff; }
body.wa-chat .chat-icon { width: 40px; height: 40px; font-size: 18px; }
body.wa-chat .chat-icon.ghost { width: 34px; height: 34px; background: transparent; color: #54656f; font-size: 20px; }

body.wa-chat[data-theme="dark"] .chat-head,
body.wa-chat[data-theme="dark"] .chat-actionbar,
body.wa-chat[data-theme="dark"] .chat-bar { background: #111b21; border-color: #2a3942; }
body.wa-chat[data-theme="dark"] .task-title,
body.wa-chat[data-theme="dark"] .chat-body,
body.wa-chat[data-theme="dark"] .chat-bar textarea { color: #e9edef; }
body.wa-chat[data-theme="dark"] .chat-back { color: #8696a0; }
body.wa-chat[data-theme="dark"] .chat-bubble.in { background: #202c33; color: #e9edef; }
body.wa-chat[data-theme="dark"] .chat-bubble.out { background: #005c4b; color: #e9edef; }
body.wa-chat[data-theme="dark"] .chat-time { color: #8696a0; }
body.wa-chat[data-theme="dark"] .chat-bar textarea { background: #2a3942; }
body.wa-chat[data-theme="dark"] .chat-icon.ghost { color: #8696a0; }

/* Desktop (>=900px): keep the two-pane layout (left sidebar + right pane).
   Fill the content pane edge-to-edge and pin the composer to the bottom of that pane. */
@media (min-width: 900px) {
  body.wa-chat .content { display: flex; flex-direction: column; height: 100vh; min-height: 0;
    overflow: hidden; padding: 0; }
  body.wa-chat .content > .alert { flex: 0 0 auto; margin: 10px 16px 0; }
  body.wa-chat .chat-head { flex: 0 0 auto; position: static; top: auto; border-radius: 0; }
  body.wa-chat .chat-actionbar { flex: 0 0 auto; }
  body.wa-chat .wa-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.22) transparent; }
  body.wa-chat .chat-thread { padding: 12px 18px 16px; }
  body.wa-chat .chat-empty { padding: 60px 24px; }
  body.wa-chat .chat-bar { flex: 0 0 auto; position: static; }
}

/* Chats nav unread pill */
.sidebar-links li a .nav-unread {
  float: right; margin-top: 2px; min-width: 16px; padding: 0 7px; box-sizing: border-box;
  background: var(--wa-accent, #25d366); color: #fff; border-radius: 10px;
  font-size: 11px; line-height: 16px; font-weight: 700; text-align: center;
}

/* New-chat contact picker */
.picker-box { border: 1px solid var(--wa-border); border-radius: 10px; overflow: hidden; background: var(--wa-panel); }
.picker-search { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--wa-border);
  background: var(--wa-panel); color: var(--wa-text); font-size: 14px; outline: none; }
.picker-search:focus { box-shadow: none; border-bottom-color: var(--wa-accent); }
.picker-scroll { max-height: 44vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.picker-item[hidden] { display: none; }

/* Read-receipt ticks (WhatsApp-style) on outgoing bubbles */
body.wa-chat .chat-time { display: inline-flex; align-items: center; justify-content: flex-end; gap: 3px; width: 100%; margin-top: 3px; line-height: 1; }
.tick { display: inline-flex; line-height: 0; color: #8696a0; }
.tick.read { color: #53bdeb; }
.tick-svg { width: 16px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body.wa-chat[data-theme="dark"] .tick { color: #8696a0; }

/* Turn-a-message-into-a-task action (subtle until hover) */
.chat-bubble { position: relative; }
.msg-task { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: #8696a0; text-decoration: none;
  opacity: .55; background: transparent; }
.msg-task:hover { opacity: 1; background: rgba(0,0,0,.06); color: var(--wa-accent); }
[data-theme="dark"] .msg-task:hover { background: rgba(255,255,255,.08); }

/* Message quick tools + replies (shown subtly, full on hover) */
.msg-tools { position: absolute; top: 3px; right: 6px; display: flex; gap: 2px; align-items: center;
  opacity: .4; transition: opacity .12s; }
.chat-bubble:hover .msg-tools, .chat-bubble:focus-within .msg-tools { opacity: 1; }
.msg-tool { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border: 0; background: transparent; border-radius: 6px; cursor: pointer; color: #8696a0; padding: 0; }
.msg-tool:hover { background: rgba(0,0,0,.06); color: var(--wa-accent); }
[data-theme="dark"] .msg-tool:hover { background: rgba(255,255,255,.1); }
.chat-quote { border-left: 3px solid var(--wa-accent); background: rgba(0,0,0,.05); border-radius: 6px;
  padding: 4px 8px; margin-bottom: 4px; font-size: 12.5px; color: var(--wa-muted); overflow: hidden; }
.chat-deleted { color: var(--wa-muted); font-style: italic; font-size: 13px; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--wa-accent-soft, #e0f2ec);
  border-top: 1px solid var(--wa-border); font-size: 12.5px; }
.reply-label { color: var(--wa-accent-strong, #005c4b); }
.reply-snip { display: block; color: var(--wa-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="dark"] .reply-bar { background: #202c33; }

/* WhatsApp-style message selection + header action bar */
/* WhatsApp-style message selection: action bar shown above the composer */
#selBar { display: none; align-items: center; gap: 4px; padding: 6px 10px;
  background: var(--wa-panel); border-top: 1px solid var(--wa-border); }
#selBar .sel-count { font-weight: 600; color: var(--wa-text); margin: 0 6px; font-size: 14px; white-space: nowrap; }
.sel-act { width: 38px; height: 38px; border: 0; background: transparent; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: var(--wa-accent); cursor: pointer; flex-shrink: 0; }
.sel-act:hover { background: rgba(0,0,0,.06); }
.sel-act:disabled { opacity: .35; cursor: not-allowed; }
.sel-cancel { color: #667781; }
.sel-danger { color: #c0392b; }
.chat-bubble.sel { outline: 2px solid var(--wa-accent); outline-offset: -2px; }
[data-theme="dark"] .sel-act:hover { background: rgba(255,255,255,.08); }
.edited-note { color: var(--wa-muted); font-size: 10px; font-style: italic; margin-right: 2px; line-height: 1; }
.chat-toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: rgba(0,0,0,.82); color: #fff; padding: 8px 16px; border-radius: 20px; font-size: 13px;
  z-index: 60; opacity: 0; transition: opacity .15s; pointer-events: none; }
.chat-toast.show { opacity: 1; }
[data-theme="dark"] .chat-toast { background: rgba(255,255,255,.92); color: #111b21; }

/* ---- Soft, polished forms (Scheduled messages page, mobile-first) ---- */
body.sch-page { color: var(--wa-text); -webkit-font-smoothing: antialiased; }
body.sch-page .page-title { font-size: 22px; font-weight: 700; letter-spacing: -.2px; color: var(--wa-text); }
body.sch-page .page-sub { font-size: 13.5px; color: #7a8690; line-height: 1.45; }
body.sch-page .card { border: 1px solid #eef0f4; border-radius: 16px; box-shadow: 0 1px 2px rgba(20,32,44,.04), 0 6px 20px rgba(20,32,44,.05); background: var(--wa-panel); }
body.sch-page .section-title { font-size: 13px; color: #6a7580; font-weight: 600; letter-spacing: .2px; margin: 14px 0 4px; }
body.sch-page .field-label { text-transform: none; letter-spacing: 0; font-size: 13px; color: #59636d; font-weight: 600; margin-bottom: 2px; }
body.sch-page input, body.sch-page select, body.sch-page textarea {
  font-family: inherit; font-size: 15.5px; line-height: 1.45; color: var(--wa-text);
  background: #fff; border: 1px solid #e0e4ea; border-radius: 10px; padding: 11px 13px;
  box-shadow: inset 0 1px 2px rgba(20,32,44,.03);
}
body.sch-page input::placeholder, body.sch-page textarea::placeholder { color: #9aa3ab; }
body.sch-page input:focus, body.sch-page select:focus, body.sch-page textarea:focus {
  border-color: var(--wa-accent); box-shadow: 0 0 0 3px rgba(0,128,105,.12); outline: none;
}
body.sch-page .seg { border-radius: 11px; background: #eef1f4; }
body.sch-page .seg a { border-radius: 9px; color: #66707a; font-size: 13.5px; }
body.sch-page .seg a.on { background: #fff; color: var(--wa-accent); box-shadow: 0 1px 3px rgba(20,32,44,.1); font-weight: 600; }
body.sch-page .chip-check-item { border-color: #e2e6ec; background: #fff; font-size: 13.5px; color: #3f4953; border-radius: 20px; }
body.sch-page .chip-check-item:has(input:checked) { background: var(--wa-accent-soft, #e0f2ec); border-color: var(--wa-accent); font-weight: 600; color: var(--wa-accent-strong, #005c4b); }
body.sch-page .btn { border-radius: 10px; }
body.sch-page .btn-primary { background: var(--wa-accent); border-color: var(--wa-accent); }
body.sch-page .wa-row-title { font-size: 15px; }
body.sch-page .wa-row-sub { font-size: 12.5px; }
body.sch-page .wa-row-item { padding: 12px 14px; }
[data-theme="dark"] body.sch-page input, [data-theme="dark"] body.sch-page select,
[data-theme="dark"] body.sch-page textarea { background: var(--wa-panel2); border-color: var(--wa-border); color: var(--wa-text); }
[data-theme="dark"] body.sch-page .seg { background: #202c33; }
[data-theme="dark"] body.sch-page .seg a.on { background: var(--wa-panel); color: var(--wa-focus); }
[data-theme="dark"] body.sch-page .chip-check-item { background: var(--wa-panel2); border-color: var(--wa-border); color: var(--wa-text); }

/* ---- Topbar: consistent vertical & horizontal alignment (esp. mobile) ---- */
.topbar { align-items: center; }
.topbar > .menu-btn, .topbar > .home-btn, .topbar > .avatar-link,
.topbar > .notif-link {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; margin: 0; flex: 0 0 auto;
  min-width: 44px; min-height: 44px; line-height: 1;
}
.topbar .menu-btn .ic, .topbar .home-btn .ic, .topbar .avatar-link .ic { display: block; }
.topbar .theme-toggle { font-size: 20px; line-height: 1; }
.topbar .notif-link { position: relative; }
/* ---- Desktop & tablet design-system polish (>=900px) ---- */
@media (min-width: 900px) {
  .content { padding: 26px 32px 60px; }
  .page-head { margin-bottom: 20px; }
  .page-title, .page-head .page-title, h1.page-title { font-size: 24px; letter-spacing: -.3px; }
  .page-sub { font-size: 14px; }
  .card { border-radius: 16px; }
  .btn { border-radius: 10px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
  .empty-state { padding: 60px 24px; }
  .wa-row-item { padding: 14px 18px; }
  .wa-avatar { width: 48px; height: 48px; font-size: 20px; }
  .crm-toolbar, .crm-filters { align-items: center; }
  .section-title { font-size: 15px; }
  .field-label { font-size: 12.5px; }
}


/* ---- Mobile drawer: clean, elegant navigation ---- */
@media (max-width: 899px) {
  .drawer-menu { width: min(86vw, 320px); padding: 0; background: var(--wa-panel); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .drawer-menu .sidebar-brand { display: none; }
  .drawer-menu .sidebar-links { list-style: none; margin: 0; padding: 10px 0 18px; }
  .drawer-menu .sidebar-links li a,
  .drawer-menu .sidebar-links li .group-toggle {
    display: flex; align-items: center; gap: 12px; width: 100%; box-sizing: border-box;
    padding: 14px 18px; font-size: 15px; font-weight: 500; color: #3c4450;
    border: none; border-bottom: 1px solid #f0f2f5; background: none; text-align: left;
  }
  .drawer-menu .sidebar-links li a:hover, .drawer-menu .sidebar-links li a:active { background: #f3f5f7; }
  .drawer-menu .sidebar-links li a.active { background: var(--wa-accent-soft, #e0f2ec); color: var(--wa-accent-strong, #005c4b); font-weight: 600; }
  .drawer-menu .sidebar-links li.group .group-links { list-style: none; margin: 0; padding: 0 0 4px 14px; }
  .drawer-menu .sidebar-links li.group .group-links li a { padding-left: 14px; }
  .drawer-menu .group-links .nav-subhead { padding-left: 28px; }
  .group-chevron { margin-left: auto; transition: transform .2s ease; }
  .drawer-menu .sidebar-links li.group.open .group-chevron { transform: rotate(180deg); }
}
@media (max-width: 899px) {
  [data-theme="dark"] .drawer-menu .sidebar-links li a,
  [data-theme="dark"] .drawer-menu .sidebar-links li .group-toggle { color: var(--wa-text); border-bottom-color: var(--wa-border); }
  [data-theme="dark"] .drawer-menu .sidebar-links li a:hover,
  [data-theme="dark"] .drawer-menu .sidebar-links li a:active { background: #202c33; }
  [data-theme="dark"] .drawer-menu .sidebar-links li a.active { background: #20312b; color: var(--wa-focus); }
}
/* Allow the nav to scroll when a section expands */
.drawer { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.drawer-menu .sidebar-links, .drawer-menu .group-links { max-height: none; overflow: visible; }
@media (max-width: 899px) {
  .drawer-menu { height: 100dvh; max-height: 100dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
}
/* Page headers on mobile: hide the subtitle; keep action buttons on the title line, right-aligned */
@media (max-width: 899px) {
  .page-head { gap: 10px; margin-bottom: 12px; }
  .page-head .page-title, .page-head h1.page-title { font-size: 19px; font-weight: 700; letter-spacing: -.2px; }
  .page-head .page-sub { display: none !important; }
  .page-head > .page-actions { margin-left: auto; justify-content: flex-end; }
  .page-head > .page-actions .btn { white-space: nowrap; }
  .page-head > a.btn, .page-head > button, .page-head > form { white-space: nowrap; flex: 0 0 auto; }
}
/* Mobile: keep text boxes slim/not bloated (16px font stops iOS zoom, compact padding) */
@media (max-width: 899px) {
  input, select, textarea {
    box-sizing: border-box; padding: 8px 10px !important; font-size: 16px !important;
    line-height: 1.3 !important; min-height: 0;
  }
  textarea { line-height: 1.5 !important; }  /* keep the WhatsApp chat composer as its own compact pill */
  body.wa-chat .chat-bar textarea { padding: 8px 14px !important; font-size: 15px !important; line-height: 1.3 !important; min-height: 38px; }
  /* tighten stacked forms so the whole form isn't vertically large */
  .card.form { gap: 6px; }
  .quick-add { gap: 6px 8px; padding: 8px; }
  .wa-row-actions { padding: 10px 12px; }
  .wa-row-actions .inline-form { display: flex; flex-direction: column; gap: 6px; }
  .field-label { margin-bottom: 1px; }
  .field-row { gap: 6px 8px; }
  .section-title { margin: 10px 0 2px; }
}







/* ---- Mobile: Work / Tasks module ---- */
@media (max-width: 899px) {
  .filter-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 2px 0 8px; scrollbar-width: none; }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-bar .btn { flex: 0 0 auto; white-space: nowrap; }
  .person-filter select { width: 100%; box-sizing: border-box; }
  .search-bar input { min-width: 0; }
  .board-col { min-width: 78vw; }
  .task-title, .wa-row-title, .board-card .task-title { overflow-wrap: anywhere; }
  .wa-member-chip, .tag, .badge { max-width: 100%; }
}
/* ---- Mobile: People & HR module ---- */
@media (max-width: 899px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .filter-grid { display: flex; flex-direction: column; gap: 6px; }
  .filter-actions { flex-wrap: wrap; }
  .profile-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .profile-head-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .ts-submit { flex-wrap: wrap; }
  .pager, .crm-filters, .role-picker { flex-wrap: wrap; }
  .crm-table-wrap { -webkit-overflow-scrolling: touch; }
  .crm-table { min-width: 640px; }
  .stat { padding: 12px; }
}
/* ---- Mobile: CRM & Sales module ---- */
@media (max-width: 899px) {
  .crm-board { -webkit-overflow-scrolling: touch; }
  .crm-col { flex: 0 0 auto; width: 82vw; min-width: 260px; }
  .form-grid { grid-template-columns: 1fr !important; gap: 8px; }
  .crm-table-wrap { -webkit-overflow-scrolling: touch; }
  .crm-table { min-width: 680px; }
  .crm-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .crm-toolbar { align-items: stretch; }
  .crm-toolbar .search, .crm-toolbar select { width: 100%; }
  .toolbar-right { margin-left: 0 !important; }
}
/* ---- Mobile: Reports & Admin module ---- */
@media (max-width: 899px) {
  .log-item { flex-wrap: wrap; gap: 4px 8px; }
  .log-who, .log-main { min-width: 0; }
  .check-row { flex-wrap: wrap; }
  .progress { min-width: 60px; }
  .crm-toolbar select, .crm-toolbar input[type="search"] { width: 100%; }
}
/* ---- Mobile: Marketing & Misc module ---- */
@media (max-width: 899px) {
  .crm-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .crm-table-wrap { -webkit-overflow-scrolling: touch; }
  .crm-table { min-width: 640px; }
  .form-grid { grid-template-columns: 1fr !important; gap: 8px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .wa-row-title, .wa-row-sub { overflow-wrap: anywhere; }
}
[data-theme="dark"] .chip-check-item { background: #202c33; border-color: var(--wa-border); color: var(--wa-text); }
[data-theme="dark"] .chip-check-item:has(input:checked) { background: #005c4b; border-color: var(--wa-green-bright); }
[data-theme="dark"] .btn-outline { background: transparent; color: var(--wa-green-bright); border-color: var(--wa-green); }
[data-theme="dark"] .empty-state { color: var(--wa-muted); }
[data-theme="dark"] .drawer-menu { background: var(--wa-panel); }
[data-theme="dark"] .drawer-menu li a { color: var(--wa-text); border-color: var(--wa-border); }
[data-theme="dark"] .sidebar-links .group { border-color: var(--wa-border); }
[data-theme="dark"] .group-toggle { color: var(--wa-text); }
[data-theme="dark"] .group-toggle:hover { background: var(--wa-sidebar-hover); color: #fff; }
[data-theme="dark"] .progress { background: #202c33; }
[data-theme="dark"] .icon-btn { color: var(--wa-muted); }
[data-theme="dark"] .alert-success { background: #0b8457; color: #fff; }
[data-theme="dark"] .alert-error { background: #b02a37; color: #fff; }
[data-theme="dark"] .alert-info { background: #2c3e50; color: #fff; }
[data-theme="dark"] .wa-member-chip { color: var(--wa-text); }

/* Desktop two-pane (three-pane with the sidebar) */
.panes { display: block; }
.pane-detail { display: none; }
@media (min-width: 900px) {
  .panes { display: flex; align-items: stretch; gap: 0; }
  .pane-list { flex: 1 1 400px; min-width: 0; border-right: 1px solid var(--wa-border); padding-right: 20px; }
  .pane-detail { flex: 1 1 auto; min-width: 0; display: none; padding-left: 20px; }
  .pane-detail iframe { width: 100%; height: calc(100vh - 100px); border: none; border-radius: 12px; background: var(--wa-bg); }
}

/* ============================================================
   UI/UX consolidation & accessibility pass (single source of accent)
   ============================================================ */
:root {
  --wa-accent: #008069;          /* primary brand/action */
  --wa-accent-strong: #005c4b;
  --wa-accent-soft: #e0f2ec;
  --wa-link: #0b7f59;
  --wa-danger: #b02a37;
  --wa-warning: #b7791f;
  --wa-success: #1b8a5a;
  --wa-focus: #25d366;
}

/* ---- Consistent link colour (contrast-safe accent) ---- */
a { color: var(--wa-link); }

/* ---- Visible, consistent focus states ---- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--wa-focus); outline-offset: 2px; border-radius: 4px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--wa-accent);
  box-shadow: 0 0 0 3px rgba(0,128,105,.16);
}

/* ---- Consistent primary/outline actions (accent, not indigo) ---- */
.btn-primary { background: var(--wa-accent); border-color: var(--wa-accent); color: #fff; }
.btn-primary:hover { background: var(--wa-accent-strong); }
.btn-primary:disabled, .btn-outline:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--wa-accent); border: 2px solid var(--wa-accent); }
.btn-outline:hover { background: var(--wa-accent-soft); }
.btn.pri-low.on, .btn.pri-medium.on, .btn.pri-high.on, .btn.pri-urgent.on { outline-color: var(--wa-accent); }

/* ---- Accent numbers, progress, avatars, tags, links ---- */
.stat-num { color: var(--wa-accent); }
.crm-stat.blue .v { color: var(--wa-accent); }
.progress-fill { background: var(--wa-accent); }
.person-avatar, .voice-assigned-chip { background: var(--wa-accent); color: #fff; }
.task-count-link, .gps-link, .cal-add, .cal-x { color: var(--wa-accent); }
.cal-add, .cal-x { background: var(--wa-accent-soft); }
.cal-add:hover { background: #cde9e0; }
.log-action, .tag { background: var(--wa-accent-soft); color: var(--wa-accent-strong); }
.voice-card { background: var(--wa-accent-soft); border-color: #bce4d9; }

/* ---- Focus + disabled on form controls ---- */
button:disabled, [aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

/* ---- Adequate touch targets for icon/ghost buttons ---- */
.quick-btn, .chat-icon, .menu-btn, .avatar-link, .home-btn,
.lightbox .lb-nav, .lb-close, .icon-btn {
  min-width: 44px; min-height: 44px;
}

/* ---- Brand surfaces unify to the accent (topbar + login) ---- */
.topbar { background: var(--wa-accent); }
.clock-bar { background: var(--wa-accent-strong); }
.login-body { background: linear-gradient(160deg, #009688, var(--wa-accent-strong)); }
.drawer-menu .sidebar-brand { background: var(--wa-accent); }

/* ---- Contrast & legibility ---- */
.muted, .task-meta { color: #5b626b; }
.field-label { color: #4d5560; letter-spacing: .4px; }
.badge, .stage-pill, .pill { font-size: 12px; }
.small { font-size: 13px; }
body { line-height: 1.5; }

/* ---- Dark-theme safe overrides (keep text on colored accents legible) ---- */
[data-theme="dark"] a { color: #4adea2; }
[data-theme="dark"] .btn-outline { background: transparent; color: var(--wa-focus); border-color: var(--wa-green); }
[data-theme="dark"] .stat-num, [data-theme="dark"] .crm-stat.blue .v { color: var(--wa-focus); }
[data-theme="dark"] .muted, [data-theme="dark"] .field-label { color: var(--wa-muted); }
[data-theme="dark"] .log-action, [data-theme="dark"] .tag,
[data-theme="dark"] .person-avatar, [data-theme="dark"] .task-count-link { color: var(--wa-focus); }
[data-theme="dark"] .tag, [data-theme="dark"] .log-action { background: #202c33; }
[data-theme="dark"] .progress-fill { background: var(--wa-green); }
[data-theme="dark"] .btn-primary { background: var(--wa-accent); }

/* ---- Reveal helper: subtle loading on submit buttons ---- */
.btn.is-loading { pointer-events: none; opacity: .7; }

/* ---- Styled confirmation dialog (replaces native confirm()) ---- */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.confirm-overlay.open { display: flex; }
.confirm-box { background: #fff; border-radius: 14px; max-width: 380px; width: 100%; padding: 20px; box-shadow: 0 12px 34px rgba(0,0,0,.28); }
.confirm-box .title { font-weight: 600; font-size: 16px; margin-bottom: 6px; color: var(--wa-text); }
.confirm-box p { margin-bottom: 16px; color: #5b626b; font-size: 14px; line-height: 1.45; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
[data-theme="dark"] .confirm-box { background: var(--wa-panel); }
[data-theme="dark"] .confirm-box p { color: var(--wa-muted); }

/* ---- Field-level inline error ---- */
.field-error { color: var(--wa-danger); font-size: 13px; font-weight: 500; }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--wa-danger); box-shadow: 0 0 0 3px rgba(176,42,55,.12); }

/* ---- Consistent page headings ---- */
h1.page-title { font-size: 20px; font-weight: 700; letter-spacing: -.2px; margin-bottom: 2px; }

/* ---- CRUD list pages (Projects, People, Companies, Contacts, Departments): clear card hierarchy ----
   Rows become distinct white cards on a slightly separate page background, instead of pale flat rows. */
.list { display: block; }
.list .wa-list-item {
  background: #fff;
  border: 1px solid var(--wa-border);
  border-bottom: 1px solid var(--wa-border);
  border-radius: 12px;
  margin: 0 0 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.list .wa-list-item .wa-row-item { border-bottom: none; }
.list .wa-list-item .wa-row-actions { background: #f7f8fa; }
.list .empty-state, .pane-list .empty-state { background: #fff; border: 1px dashed var(--wa-border); border-radius: 12px; padding: 28px 16px; }
[data-theme="dark"] .list .wa-list-item { background: var(--wa-panel); box-shadow: none; }
/* Contacts/other grouped lists: items are rows inside one bordered container, not separate cards */
.wa-list .wa-list-item { background: transparent; border: 0; border-radius: 0; margin: 0; box-shadow: none; overflow: visible; }
[data-theme="dark"] .list .wa-list-item .wa-row-actions { background: #0f1a20; }
[data-theme="dark"] .list .empty-state, [data-theme="dark"] .pane-list .empty-state { background: var(--wa-panel); }
/* Inside an existing .card (e.g. reports/productivity), keep rows flat to avoid card-in-card */
.card .list .wa-list-item { background: transparent; border: none; border-bottom: 1px solid var(--wa-border); border-radius: 0; margin: 0; box-shadow: none; }
.card .list .wa-list-item .wa-row-actions { background: #f7f8fa; }
[data-theme="dark"] .card .list .wa-list-item { background: transparent; border-bottom: 1px solid var(--wa-border); }

/* ---- Task list (inside .pane-list): coloured left accent by status ---- */
.pane-list .list .wa-list-item:has(.badge-progress) { border-left: 4px solid #f0a83b; }
.pane-list .list .wa-list-item:has(.badge-done)     { border-left: 4px solid var(--wa-success); }
.pane-list .list .wa-list-item:has(.badge-pending)  { border-left: 4px solid #b8c0c7; }

/* ---- Task board: give columns and cards clear surfaces + hover ---- */
.board { display: flex; align-items: flex-start; gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.board-col { background: #eef0f3; border-radius: 14px; padding: 10px; min-width: 250px; }
.board-card { background: #fff; border: 1px solid var(--wa-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.board-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,.1); }
[data-theme="dark"] .board-col { background: var(--wa-panel2); }
[data-theme="dark"] .board-card { background: var(--wa-panel); border-color: var(--wa-border); box-shadow: none; }

/* ---- Expanded task "Actions": compact, dense controls ---- */
.task-actions { padding: 10px 12px; }
.ta-status { display: flex; gap: 0; border: 1px solid var(--wa-border); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.ta-status form { flex: 1 1 0; margin: 0; display: flex; min-width: 0; }
.ta-status .seg-btn { flex: 1 1 0; min-width: 0; border: none; background: #fff; color: var(--wa-muted); font-weight: 600; font-size: 12.5px; padding: 8px 4px; cursor: pointer; border-right: 1px solid var(--wa-border); white-space: nowrap; transition: background .12s; }
.ta-status form:last-child .seg-btn { border-right: none; }
.ta-status .seg-btn:hover { background: var(--wa-accent-soft); color: var(--wa-accent-strong); }
.ta-status .seg-btn.on { background: var(--wa-accent); color: #fff; }
.ta-status .seg-btn.on:hover { background: var(--wa-accent-strong); color: #fff; }
.ta-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ta-tools .ta-archive { margin-left: auto; }
[data-theme="dark"] .ta-status { background: var(--wa-panel2); }
[data-theme="dark"] .ta-status .seg-btn { background: var(--wa-panel2); color: var(--wa-muted); border-color: var(--wa-border); }
[data-theme="dark"] .ta-status .seg-btn:hover { color: var(--wa-focus); background: transparent; }
[data-theme="dark"] .ta-status .seg-btn.on { background: var(--wa-accent); color: #fff; }

/* ---- Productivity report: filter grid + table footers ---- */
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.filter-grid > div { min-width: 0; }
.filter-grid label { display: block; margin-bottom: 4px; }
.filter-grid input[type="date"],
.filter-grid select { width: 100%; box-sizing: border-box; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--wa-border); background: var(--wa-panel); color: var(--wa-text); font-size: 14px; }
.filter-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crm-table tfoot th { font-weight: 700; border-top: 2px solid var(--wa-border); color: var(--wa-text); }
[data-theme="dark"] .crm-table tfoot th { border-color: var(--wa-border); }

/* ---- Labelled create/edit form grid (Invoices, Campaigns, Releases & misc) ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: start; }
.form-grid > label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .2px; color: var(--wa-muted); min-width: 0; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; box-sizing: border-box; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--wa-border); background: var(--wa-panel); color: var(--wa-text); font-size: 14px; }
.form-grid textarea { min-height: 64px; resize: vertical; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { outline: none; border-color: var(--wa-green); box-shadow: 0 0 0 2px rgba(0, 128, 105, .15); }
/* Top-level panel titles used on detail/create cards (not only inside .chat-details) */
.details-title { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 700; color: var(--wa-green); margin-bottom: 12px; }

/* Topbar notification bell */
.notif-link { position: relative; text-decoration: none; }
.notif-badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 9px; background: var(--wa-danger, #e74c3c); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
.notif-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--wa-border); }
.notif-item .t { font-weight: 600; }
.notif-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: #9aa5b1; flex: 0 0 auto; }
.notif-item.unread .notif-dot { background: var(--wa-green, #008069); }

/* ---- Timesheet: labelled log-hours grid + week toolbar ---- */
.filter-grid input[type="time"],
.filter-grid input[type="number"],
.filter-grid input[type="text"],
.filter-grid textarea { width: 100%; box-sizing: border-box; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--wa-border); background: var(--wa-panel); color: var(--wa-text); font-size: 14px; }
.crm-toolbar .search input[type="date"] { width: 100%; box-sizing: border-box; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--wa-border); background: var(--wa-panel); color: var(--wa-text); font-size: 14px; }
.crm-toolbar .ts-submit { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* ---- Link-based list rows (e.g. employee register) fill width as cards ---- */
.list a.wa-list-item { display: block; color: inherit; text-decoration: none; }
.list a.wa-list-item:hover { box-shadow: 0 3px 10px rgba(0,0,0,.08); }

/* ---- Holidays: clean calendar card ---- */
.cal-wrap { overflow-x: auto; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; min-width: 620px; }
.cal-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--wa-muted); text-align: center; padding: 4px 0; }
.cal-cell { min-height: 62px; border: 1px solid var(--wa-border); border-radius: 10px; background: #fff; padding: 6px; position: relative; }
.cal-empty { background: transparent; border: none; }
.cal-cell .cal-day { font-weight: 600; font-size: 14px; }
.cal-cell.cal-off { background: #f5f6f8; }
.cal-cell.cal-off .cal-day { color: #a6adb5; }
.cal-cell.cal-hol { background: var(--wa-accent-soft); border-color: var(--wa-accent); }
.cal-name { font-size: 10px; line-height: 1.15; margin-top: 2px; padding-right: 18px; color: var(--wa-accent-strong); font-weight: 600; }
.cal-cell .cal-add, .cal-cell .cal-x { position: absolute; bottom: 5px; right: 5px; margin: 0 !important; }
.cal-cell .cal-x { color: #c0392b; background: #ffecec; }
[data-theme="dark"] .cal-cell { background: var(--wa-panel); border-color: var(--wa-border); }
[data-theme="dark"] .cal-cell.cal-off { background: var(--wa-panel2); }
[data-theme="dark"] .cal-cell.cal-hol { background: #123c33; border-color: var(--wa-green); }
[data-theme="dark"] .cal-name { color: var(--wa-focus); }

/* ---- HR profile: header + view/edit actions ---- */
.profile-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.profile-head-actions { margin-left: auto; flex-shrink: 0; display: flex; gap: 8px; }

/* ---- Sidebar "My day" quick actions (Punch / Break / Log hours) ---- */
li.myday { padding: 12px 14px 8px; border-bottom: 1px solid rgba(0,0,0,.06); }
[data-theme="dark"] li.myday, .drawer-menu .sidebar-links li.myday { border-bottom: 1px solid rgba(255,255,255,.08); }
.myday-title { color: #00897b; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; gap: 6px; margin: 0 0 8px; }
.myday-btn { display: flex; align-items: center; gap: 8px; background: #00897b; color: #fff !important; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; text-decoration: none; border: 1px solid transparent; }
.myday-btn:hover { background: #00695c; }
.myday-btn .md-ic { font-size: 15px; line-height: 1; }
/* Ensure sidebar link defaults (padding/border/colour) don't override the quick-action buttons */
.drawer-menu .sidebar-links li a.myday-btn { padding: 9px 12px; border-bottom: none; border-radius: 10px; background: #00897b; color: #fff; font-weight: 600; margin-bottom: 6px; }
.drawer-menu .sidebar-links li a.myday-btn:hover { background: #00695c; color: #fff; }

/* ---- Impersonation "previewing as" bar ---- */
.impersonate-bar { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 120; background: #1a1d21; color: #fff; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 30px; box-shadow: 0 6px 22px rgba(0,0,0,.35); font-size: 13px; }
.impersonate-bar a { color: #fff; }
[data-theme="dark"] .impersonate-bar { background: #202c33; }

/* ---- Toasts: always legible (light text on their coloured backgrounds) ---- */
.toast, .toast.alert-success, .toast.alert-error, .toast.alert-info { color: #fff; }
.toast a { color: #fff; text-decoration: underline; }

/* ---- Bottom-left subtle quick actions (above "Logged in as") ---- */
.sidebar-actions { padding: 12px 18px 6px; border-top: 1px solid rgba(0,0,0,.06); }
.sidebar-actions a { display: flex; gap: 8px; align-items: center; color: #5f6b76; font-size: 13px; font-weight: 500; padding: 5px 2px; text-decoration: none; }
.sidebar-actions a:hover { color: #00897b; }
@media (min-width: 900px) {
  .sidebar-actions { border-top: 1px solid rgba(255,255,255,.08); }
  .sidebar-actions a { color: #aebac1; }
  .sidebar-actions a:hover { color: #fff; }
}
[data-theme="dark"] .sidebar-actions a { color: #aebac1; }
[data-theme="dark"] .sidebar-actions a:hover { color: #fff; }
.sidebar-actions .sa-since { display: block; color: inherit; opacity: .75; font-size: 12px; padding: 0 2px 4px; }
.sidebar-actions .sa-timer { display: inline-flex; align-items: center; justify-content: center; margin: 6px 0; padding: 6px 10px; border-radius: 999px; background: #0b5a22; color: #fff; font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: .3px; font-size: 12px; min-width: 150px; box-sizing: border-box; }
[data-theme="dark"] .sidebar-actions .sa-timer { background: #0e7a2e; }
.sa-punchout { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; box-sizing: border-box; text-align: left; margin: 4px 0; }
.sa-punchout .sa-time { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.sa-addbreak { display: block; font-size: 12px; opacity: .85; padding: 2px 0 6px; }
.sidebar-actions a.btn.sa-punchout { color: #fff; }

/* Bold left-nav category headers */
.sidebar-links .group-toggle { font-weight: 700 !important; }

/* ---- Screens: Dashboard / Timesheet / Tasks ---- */
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
@media (max-width: 899px) {
  .quick-actions .btn { flex: 1 1 100%; justify-content: center; }
}
@media (min-width: 900px) {
  .quick-actions { gap: 10px; }
}











