/*
 * Campaign Dashboard, in ScaleAppz branding: navy #0F172A, logo orange #FF8A3D (navy text on orange buttons),
 * warm page #F6F4F1. Each campaign adds its party colour as --accent. Phone first: bottom tabs on phones,
 * sidebar from 960px. Headings Plus Jakarta Sans, text Inter, Telugu Noto Sans Telugu.
 */
:root {
  --navy: #0f172a;
  --navy-2: #18213a;
  --navy-3: #232e4a;
  --orange: #ff8a3d;
  --orange-2: #ff9d52;
  --orange-ink: #ba4609;
  --orange-tint: #fff4ea;
  --accent: #f47216;
  --page: #f6f4f1;
  --card: #ffffff;
  --line: #e7e2db;
  --line-2: #d4dae3;
  --text: #334155;
  --muted: #64748b;
  --ink: #0f172a;
  --ok: #15803d;
  --ok-tint: #e7f6ec;
  --info: #1d4ed8;
  --info-tint: #e8efff;
  --warn: #9a5800;
  --warn-tint: #fff3d6;
  --grey-tint: #eef0f3;
  --error: #b42318;
  --error-tint: #fdecea;
  --wa: #128c4a;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.05), 0 6px 20px -8px rgb(15 23 42 / 0.12);
  --font: 'Inter', 'Noto Sans Telugu', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --side-w: 252px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); color: var(--ink); letter-spacing: -0.015em; text-wrap: balance; }
a { color: var(--orange-ink); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: #fff; padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--orange-ink); }
[hidden] { display: none !important; }

/* ----- buttons and inputs ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s; }
.btn-primary { background: var(--orange); color: var(--navy); }
.btn-primary:hover { background: var(--orange-2); }
.btn-ghost { background: #fff; border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-wa:hover { background: #0f7a40; }
.btn-block { width: 100%; }
.linkish { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font-size: inherit; }
.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.inp { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; }
textarea.inp { min-height: 90px; resize: vertical; }
select.inp { padding-right: 32px; appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; }
.err { color: var(--error); font-size: 13px; margin-top: 4px; }

/* ----- top bar (phones) and sidebar ----- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); background: var(--navy); color: #fff; }
.topbar-logo img { display: block; height: 22px; width: auto; }
.topbar-campaign { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: #cbd5e1; padding-left: 12px; border-left: 1px solid rgb(255 255 255 / 0.15); }
.topbar-menu { margin-left: auto; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: rgb(255 255 255 / 0.08); color: #fff; cursor: pointer; }

.shell { display: block; }
.sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(86vw, var(--side-w)); transform: translateX(-100%); transition: transform 0.2s; display: flex; flex-direction: column; gap: 18px; padding: 20px 14px max(20px, env(safe-area-inset-bottom)); background: var(--navy); color: #cbd5e1; overflow-y: auto; }
.sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgb(15 23 42 / 0.45); }
.side-logo img { display: block; height: 26px; width: auto; margin: 2px 8px 0; }
.side-campaign { display: flex; gap: 10px; align-items: flex-start; padding: 14px 12px; border-radius: 12px; background: var(--navy-2); }
.side-dot { flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgb(255 255 255 / 0.06); }
.side-name { color: #fff; font-weight: 700; font-family: var(--font-display); line-height: 1.3; }
.side-head { font-size: 13px; color: #94a3b8; margin-top: 2px; }
.side-switch select { width: 100%; min-height: 38px; border-radius: 10px; border: 1px solid var(--navy-3); background: var(--navy-2); color: #fff; padding: 0 10px; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #cbd5e1; text-decoration: none; font-weight: 500; }
.side-nav a:hover { background: var(--navy-2); color: #fff; }
.side-nav a[aria-current='page'] { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 var(--orange); }
.side-nav svg, .tabbar svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--orange); color: var(--navy); font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.side-user { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid var(--navy-3); }
.side-user-name { color: #fff; font-weight: 600; }
.side-user-role { font-size: 13px; color: #94a3b8; }
.side-user-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 13px; }
.side-user-links a, .side-user-links .linkish { color: #cbd5e1; }
.side-user-links form { display: inline; }

.main { padding: 20px max(16px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); max-width: 1240px; outline: none; }
.foot { display: flex; align-items: center; gap: 8px; margin-top: 36px; font-size: 13px; color: var(--muted); }
.foot img { height: 16px; width: auto; }

/* bottom tabs on phones */
.tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); background: rgb(255 255 255 / 0.97); border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
.tabbar a { position: relative; display: grid; justify-items: center; gap: 2px; padding: 6px 4px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; }
.tabbar a[aria-current='page'] { color: var(--orange-ink); background: var(--orange-tint); }
.tabbar .count { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; min-width: 18px; height: 18px; font-size: 11px; padding: 0 5px; }

/* ----- page parts ----- */
.flashes { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 10px; background: var(--ok-tint); color: var(--ok); font-weight: 500; }
.flash-warning { background: var(--warn-tint); color: var(--warn); }
.flash-error { background: var(--error-tint); color: var(--error); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; line-height: 1.2; margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.page-head .muted { margin-top: 4px; }
.back { margin-bottom: 10px; font-size: 14px; }
.back a { text-decoration: none; font-weight: 600; }
.back a::before { content: '‹ '; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-title { font-size: 16px; }
.card-title { margin-bottom: 10px; }
.card-title:not(:first-child) { margin-top: 18px; }
.see-all { font-size: 14px; font-weight: 600; text-decoration: none; }
.grid-2 { display: grid; gap: 16px; margin-bottom: 16px; }
.empty { text-align: center; padding: 40px 20px; }
.empty h2 { font-size: 18px; margin-bottom: 6px; }
.empty-inline { color: var(--muted); padding: 10px 0; }
.narrow { max-width: 460px; }
.stack-form { display: grid; gap: 14px; }

/* key numbers */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: grid; gap: 2px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.kpi:hover { border-color: var(--line-2); }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi-value { font: 800 30px/1.1 var(--font-display); color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-alert { background: linear-gradient(135deg, var(--navy), var(--navy-3)); border-color: var(--navy); }
.kpi-alert .kpi-label, .kpi-alert .kpi-sub { color: #cbd5e1; }
.kpi-alert .kpi-value { color: var(--orange); }

/* 14-day chart */
.legend { display: flex; align-items: center; gap: 6px 10px; font-size: 12px; color: var(--muted); }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.lg-m, .bar-m { background: var(--orange); }
.lg-v, .bar-v { background: var(--navy-3); }
.chart { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; height: 190px; padding-top: 18px; background: repeating-linear-gradient(to top, transparent 0 calc(25% - 1px), var(--grey-tint) calc(25% - 1px) 25%) 0 0 / 100% calc(100% - 22px) no-repeat; }
.chart-col { display: grid; grid-template-rows: 1fr 22px; min-width: 0; }
.chart-bars { display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.bar { position: relative; width: min(12px, 42%); min-height: 0; border-radius: 3px 3px 0 0; }
.bar em { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font: 600 10px/1.6 var(--font); font-style: normal; color: var(--muted); }
.chart-x { text-align: center; font-size: 11px; color: var(--muted); padding-top: 4px; font-variant-numeric: tabular-nums; }
.chart-today { color: var(--ink); font-weight: 700; }

/* horizontal bars and lists */
.hbars { list-style: none; padding: 0; display: grid; gap: 4px; }
.hbars a { display: grid; grid-template-columns: 9.5em 1fr auto; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 8px; text-decoration: none; color: var(--text); font-size: 14px; }
.hbars a:hover { background: var(--page); }
.hbar-track { height: 10px; border-radius: 999px; background: var(--grey-tint); overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: inherit; background: var(--orange); }
.hbar-n { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
.hbar-n small { font-weight: 500; color: var(--muted); }
.sub-h { font-size: 14px; margin: 18px 0 8px; }
.area-list { list-style: none; padding: 0; display: grid; gap: 2px; }
.area-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 4px; border-bottom: 1px dashed var(--line); font-size: 14px; }
.area-list a { color: var(--text); text-decoration: none; }
.area-list span { font-weight: 700; color: var(--ink); }
.mini-list { list-style: none; padding: 0; }
.mini-list li + li { border-top: 1px solid var(--line); }
.mini-list a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 2px; text-decoration: none; color: var(--text); }
.mini-list a:hover strong { color: var(--orange-ink); }
.mini-main { min-width: 0; font-size: 14px; }
.mini-main strong { color: var(--ink); }
.mini-side { display: grid; justify-items: end; align-content: start; gap: 4px; flex: none; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* status badges and tags */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--grey-tint); color: var(--muted); }
.badge-lg { font-size: 13px; padding: 4px 12px; font-family: var(--font); letter-spacing: 0; }
.s-new { background: var(--warn-tint); color: var(--warn); }
.s-in_progress, .s-contacted { background: var(--info-tint); color: var(--info); }
.s-resolved, .s-active { background: var(--ok-tint); color: var(--ok); }
.role-owner { background: var(--orange-tint); color: var(--orange-ink); }
.role-manager { background: var(--info-tint); color: var(--info); }
.tag { display: inline-block; padding: 1px 8px; margin: 0 4px 4px 0; border-radius: 6px; background: var(--page); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--ink); }
.tag-photo { background: var(--orange-tint); border-color: #ffd9bd; color: var(--orange-ink); }
.tag-lg { font-size: 14px; padding: 4px 10px; }

/* filters, tables, bulk bar */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; margin-bottom: 10px; align-items: center; }
.filter-search { position: relative; grid-column: 1 / -1; }
.filter-search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; }
.filter-search .inp { padding-left: 38px; }
.filters .clear { font-size: 14px; font-weight: 600; }
.result-count { font-size: 13px; color: var(--muted); margin: 0 2px 8px; }
.table-card { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: #faf9f7; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--orange); }
.col-check { width: 44px; }
.col-check input { width: 18px; height: 18px; accent-color: var(--orange-ink); }
.col-ref a { font-weight: 700; white-space: nowrap; }
.col-person strong { display: block; color: var(--ink); }
.col-person .muted { font-size: 13px; }
.col-text { max-width: 420px; }
.col-text .clamp { margin-top: 2px; color: var(--text); }
.col-date { white-space: nowrap; color: var(--muted); }
.bulkbar { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--navy); color: #fff; box-shadow: var(--shadow); }
.bulkbar .inp { width: auto; flex: 1; min-width: 180px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; font-size: 14px; color: var(--muted); }

/* detail pages */
.detail { display: grid; gap: 16px; }
.detail-main, .detail-side { display: grid; gap: 16px; align-content: start; }
.message-text { font-size: 16px; line-height: 1.65; color: var(--ink); white-space: normal; }
.photo { display: grid; gap: 6px; margin-top: 14px; text-decoration: none; font-size: 13px; font-weight: 600; }
.photo img { border-radius: 12px; border: 1px solid var(--line); max-height: 420px; width: auto; object-fit: contain; background: var(--page); }
.person-name { font: 700 18px/1.3 var(--font-display); color: var(--ink); }
.person-phone { font-size: 16px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.contact-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 14px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.inline-form + .inline-form { margin-top: 14px; }
.inline-form .lbl { grid-column: 1 / -1; margin-bottom: 0; }
.timeline { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.timeline li { position: relative; padding: 10px 12px 10px 14px; border-radius: 10px; background: var(--page); border-left: 3px solid var(--orange); }
.timeline li.tl-status { background: transparent; border-left-color: var(--line-2); padding-top: 4px; padding-bottom: 4px; }
.tl-status .tl-text { font-size: 13px; color: var(--muted); }
.tl-text { color: var(--ink); }
.tl-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.note-form { display: grid; gap: 8px; margin-top: 8px; }
.note-form .btn { justify-self: start; }

/* campaign picker and team */
.campaign-grid { display: grid; gap: 12px; }
.campaign-card { position: relative; display: grid; gap: 4px; text-decoration: none; color: inherit; overflow: hidden; }
.campaign-card-bar { position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--accent); }
.campaign-card h2 { font-size: 18px; }
.campaign-card-stats { margin-top: 8px; font-size: 14px; }
.roles { margin-top: 16px; }

/* sign-in page */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); background: radial-gradient(70% 60% at 100% 0%, rgb(255 138 61 / 0.18), transparent 60%), radial-gradient(60% 50% at 0% 100%, rgb(255 180 92 / 0.14), transparent 60%), #fff9f3; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 60px -24px rgb(15 23 42 / 0.25); padding: 28px 24px; }
.auth-logo { display: block; height: 30px; width: auto; }
.auth-card h1 { font-size: 24px; margin-top: 22px; }
.auth-sub { color: var(--muted); margin: 6px 0 20px; font-size: 14px; }
.auth-card form { display: grid; gap: 4px; }
.auth-card .inp { margin-bottom: 12px; }
.auth-card .flash { margin-bottom: 12px; }
.auth-card .btn { margin-top: 6px; min-height: 46px; font-size: 15px; }
.auth-help { margin-top: 16px; font-size: 13px; color: var(--muted); text-align: center; }

/* phones: tables become cards */
@media (max-width: 719px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { position: relative; padding: 12px 14px 12px 50px; border-bottom: 1px solid var(--line); }
  .table tr:last-child { border-bottom: 0; }
  .table td { padding: 0; border: 0; }
  .table td + td { margin-top: 4px; }
  .table .col-check { position: absolute; left: 14px; top: 14px; width: auto; }
  .table tr.is-new td:first-child { box-shadow: none; }
  .table tr.is-new { box-shadow: inset 3px 0 0 var(--orange); }
  .col-ref { font-size: 13px; }
  .col-date { font-size: 12px; }
  .table:not(:has(.col-check)) tr { padding-left: 14px; }
}

@media (min-width: 560px) {
  .filters { grid-template-columns: 1fr 1fr 1fr auto auto; }
  .filter-search { grid-column: 1 / -1; }
  .campaign-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .main { padding-top: 28px; }
  .page-head h1 { font-size: 30px; }
  .card { padding: 20px 22px; }
  .table-card { padding: 0; }
}

@media (min-width: 960px) {
  .topbar, .tabbar, .topbar-menu { display: none; }
  .shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; background: linear-gradient(90deg, var(--navy) var(--side-w), transparent 0); }
  .sidebar { position: sticky; top: 0; height: 100vh; transform: none; width: var(--side-w); box-shadow: none; }
  .main { padding: 32px 36px 40px; }
  .bulkbar { bottom: 16px; }
  .grid-2 { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .detail { grid-template-columns: minmax(0, 1fr) 340px; }
  .filters { grid-template-columns: minmax(220px, 2fr) 1fr 1fr 1fr auto auto; }
  .filter-search { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
