/* ============================================================
   Overview page — styles lifted verbatim from
   _design/zain-os/project/Overview.html (inline <style>).
   Loaded only on #overview; classes are overview-scoped.
   ============================================================ */

.greeting {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.greeting h1 { font-size: 22px; font-weight: 500; letter-spacing: -0.01em; }
.greeting .date { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.qa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--btn-lg);
  min-width: var(--btn-w-lg);
  padding: 0 18px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.qa-btn:hover { border-color: var(--brand-dim); color: var(--brand); }
.qa-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.qa-btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.qa-btn svg { width: 13px; height: 13px; }

.alert-strip {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  background: var(--brand-subtle);
  border: 1px solid var(--brand-dim);
  border-radius: var(--r-sm);
  margin-bottom: 18px;
  font-size: 13px;
}
.alert-strip svg { width: 15px; height: 15px; color: var(--brand); flex-shrink: 0; }
.alert-strip .body { flex: 1; color: var(--text); }
.alert-strip .body strong { color: var(--brand); font-weight: 600; }
.alert-strip .body .list { color: var(--text-secondary); margin-top: 2px; font-size: 12px; }
.alert-strip .link { color: var(--brand); font-weight: 600; font-size: 12px; text-decoration: none; flex-shrink: 0; cursor: pointer; }

/* KPI grid (4 cards) */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  position: relative;
  overflow: hidden;
}
.kpi .lbl { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi .val { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums lining-nums; line-height: 1.1; }
.kpi .sub { font-size: 11.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; display: flex; gap: 6px; flex-wrap: wrap; }
.kpi .sub .pill { display: inline-flex; align-items: center; gap: 4px; height: var(--pill-h); padding: 0 var(--pill-px); background: var(--hover); border-radius: var(--r-pill); font-size: var(--pill-fs); font-weight: var(--pill-fw); color: var(--text-secondary); }
.kpi .sub .pill .d-green  { width: 5px; height: 5px; border-radius: 50%; background: #7ab28f; }
.kpi .sub .pill .d-orange { width: 5px; height: 5px; border-radius: 50%; background: var(--brand); }
.kpi .sub .pill .d-dim    { width: 5px; height: 5px; border-radius: 50%; background: var(--text-tertiary); }
.kpi.kpi-attn { border-color: var(--brand-dim); background: linear-gradient(180deg, var(--brand-subtle) 0%, var(--card) 70%); }
.kpi.kpi-attn .val { color: var(--brand); }

/* Clickable Needs-you KPI */
.kpi-btn { font-family: inherit; text-align: left; cursor: pointer; }
.kpi-btn:hover { border-color: var(--brand); }
.kpi-btn .open-hint { position: absolute; top: 12px; right: 14px; font-size: 10px; font-weight: 600; color: var(--brand); text-transform: uppercase; letter-spacing: 0.05em; opacity: 0; transition: opacity 0.15s; display: inline-flex; align-items: center; gap: 3px; }
.kpi-btn:hover .open-hint { opacity: 1; }
.kpi-btn .open-hint svg { width: 10px; height: 10px; }

/* Revenue row (Cashflow + Profit) */
.revenue-row { display: grid; grid-template-columns: 2.225fr 1fr; gap: 14px; margin-bottom: 14px; }
.rev-card {
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
.rev-card.cashflow { padding: 16px 20px 18px; }
.rev-card .sub-inline { color: var(--text-tertiary); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 11px; margin-left: 4px; }
.rev-card .lbl { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; }
.rev-card .big { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums lining-nums; letter-spacing: -0.01em; line-height: 1; }
.rev-card .big .unit { font-size: 15px; color: var(--text-secondary); font-weight: 500; margin-left: 3px; }
.rev-card .sub { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.rev-card.owner { background: repeating-linear-gradient(45deg, var(--card) 0 20px, rgba(232,97,58,0.02) 20px 21px); }
.rev-card .owner-tag { position: absolute; top: 14px; right: 14px; font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); padding: 2px 6px; border: 1px solid var(--border); border-radius: 3px; }
.cashflow-split { display: grid; grid-template-columns: 1fr auto 1fr; gap: 22px; align-items: stretch; margin-top: 4px; }
.cf-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cf-lbl { font-size: 11px; color: var(--text-secondary); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.cf-col .big { margin-top: 2px; }
.cf-divider { width: 1px; background: var(--border-light); }

/* Three-up row */
.three-up { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.panel { background: var(--card); border: 1px solid var(--border-light); border-radius: var(--r-md); display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px 10px; }
.panel-head h3 { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel-head h3 .count { background: var(--hover); color: var(--text-secondary); font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: var(--r-pill); font-variant-numeric: tabular-nums; }
.panel-head .view-all { font-size: 11.5px; color: var(--text-secondary); text-decoration: none; font-weight: 500; cursor: pointer; }
.panel-head .view-all:hover { color: var(--brand); }

.panel-empty { padding: 30px 18px; text-align: center; color: var(--text-tertiary); font-size: 12px; }

.lead-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 10px 18px; cursor: pointer; border-top: 1px solid var(--border-light); }
.lead-row:hover { background: var(--hover); }
.lead-row .avatar-xs { width: 26px; height: 26px; border-radius: 50%; background: var(--hover); color: var(--text-secondary); font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.lead-row .name-col { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lead-row .name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-row .sub { font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-mono); }
.lead-row .score {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}

.inst-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 10px 18px; cursor: pointer; border-top: 1px solid var(--border-light); }
.inst-row:hover { background: var(--hover); }
.inst-row .num-tag { font-family: var(--font-mono); font-size: 10px; color: var(--text-secondary); background: var(--hover); padding: 2px 6px; border-radius: 3px; font-weight: 600; }
.inst-row .unit-label { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.inst-row .unit-label .type { font-size: 10px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; margin-left: 6px; }
.inst-row .amt { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums lining-nums; }
.inst-row .due { font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; min-width: 60px; text-align: right; }
.inst-row .due.soon { color: var(--brand); font-weight: 600; }

.visit-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 18px; cursor: pointer; border-top: 1px solid var(--border-light); }
.visit-row:hover { background: var(--hover); }
.visit-row.pending { background: var(--brand-subtle); }
.visit-row .time-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 44px; padding: 4px 0; background: var(--hover); border-radius: 6px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.visit-row .time-chip .d { font-size: 14px; font-weight: 700; line-height: 1; }
.visit-row .time-chip .m { font-size: 9px; color: var(--text-secondary); text-transform: uppercase; margin-top: 2px; letter-spacing: 0.05em; }
.visit-row.today .time-chip { background: var(--brand); color: #fff; }
.visit-row.today .time-chip .m { color: rgba(255,255,255,0.8); }
.visit-row .visit-info { min-width: 0; }
.visit-row .visit-info .v-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.visit-row .visit-info .v-sub { font-size: 11px; color: var(--text-secondary); font-family: var(--font-mono); }

/* Bottom row: Agent + Next post + Activity */
.bottom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 40px; align-items: stretch; }
.bottom-row .bl-col { display: grid; grid-template-rows: 1fr 1fr; gap: 14px; height: 100%; }

.agent-panel { padding: 18px 20px; background: var(--card); border: 1px solid var(--border-light); border-radius: var(--r-md); position: relative; overflow: hidden; min-height: 0; }
.agent-panel::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); }
.agent-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.agent-head .a-left { display: flex; align-items: center; gap: 10px; }
.agent-head .a-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--brand-subtle); border: 1px solid var(--brand-dim); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; }
.agent-head .a-icon svg { width: 16px; height: 16px; }
.agent-head .a-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.agent-head .a-sub { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }

.status-tag { display: inline-flex; align-items: center; gap: 5px; height: var(--pill-h); padding: 0 var(--pill-px); background: rgba(122,178,143,0.15); color: #7ab28f; font-size: var(--pill-fs); font-weight: var(--pill-fw); letter-spacing: 0.04em; text-transform: uppercase; border-radius: var(--r-pill); }
.status-tag .d { width: 5px; height: 5px; border-radius: 50%; background: #7ab28f; animation: ov-pulse 1.4s infinite ease-in-out; }
.status-tag.status-off { background: rgba(161,63,40,0.15); color: var(--danger); }
.status-tag.status-off .d { background: var(--danger); animation: none; }
@keyframes ov-pulse { 0%,100% {opacity:1} 50% {opacity:0.4} }

.range-tabs { display: flex; gap: 2px; }
.range-tabs .r-btn { padding: 4px 10px; background: transparent; border: 0; font-size: 10.5px; font-weight: 600; color: var(--text-tertiary); border-radius: 4px; cursor: pointer; font-family: inherit; letter-spacing: 0.02em; text-transform: uppercase; }
.range-tabs .r-btn.is-active { background: var(--hover); color: var(--text); }

.auto-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.auto-m { padding: 10px 12px; background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--r-sm); }
.auto-m .n { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums lining-nums; letter-spacing: -0.01em; }
.auto-m .l { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; font-weight: 600; }

.np-card { padding: 16px 18px; background: var(--card); border: 1px solid var(--border-light); border-radius: var(--r-md); min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.np-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.np-head h3 { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; display: flex; align-items: center; gap: 8px; }
.np-head h3 .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); animation: ov-pulse 1.4s infinite ease-in-out; }
.np-head .more { font-size: 11px; color: var(--text-tertiary); text-decoration: none; cursor: pointer; }
.np-head .more:hover { color: var(--brand); }
.np-body { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; flex: 1; }
.np-time { font-family: var(--font-mono); font-size: 22px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; background: var(--hover); padding: 8px 12px; border-radius: 6px; min-width: 76px; text-align: center; }
.np-time .rel { display: block; font-size: 10px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; font-weight: 500; }
.np-info { min-width: 0; }
.np-unit { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-group { font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-progress { font-size: 10.5px; color: var(--text-tertiary); font-family: var(--font-mono); margin-top: 6px; }
.np-cta { display: flex; flex-direction: column; gap: 4px; }
.np-btn { height: var(--btn-md); min-width: var(--btn-w-md); padding: 0 14px; background: var(--text); color: var(--bg); border: 0; border-radius: var(--btn-radius); font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer; white-space: nowrap; }
.np-btn:hover { background: var(--brand); }

.activity { padding: 18px 20px; background: var(--card); border: 1px solid var(--border-light); border-radius: var(--r-md); margin: 0; height: 100%; display: flex; flex-direction: column; }
.activity-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.activity-head h3 { font-size: 13px; font-weight: 600; }
.activity-head .view-all { font-size: 11.5px; color: var(--text-secondary); text-decoration: none; cursor: pointer; }
.activity-head .view-all:hover { color: var(--brand); }
.activity-list { display: flex; flex-direction: column; flex: 1; overflow-y: auto; max-height: none; }
.act-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: baseline; padding: 8px 0; font-size: 12.5px; border-bottom: 1px dashed var(--border-light); }
.act-item:last-child { border-bottom: 0; }
.act-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); margin-top: 6px; align-self: flex-start; flex-shrink: 0; }
.act-item .dot.dim { background: var(--text-tertiary); }
.act-item .txt { line-height: 1.45; color: var(--text); min-width: 0; }
.act-item .txt .who { color: var(--brand); font-weight: 500; }
.act-item .txt .subj { color: var(--text-secondary); }
.act-item .time { font-size: 10.5px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* Overview badge pills (minimal, for lead/visit rows) */
.ov-badge { display: inline-flex; align-items: center; height: var(--pill-h); padding: 0 var(--pill-px); border-radius: var(--r-pill); font-size: var(--pill-fs); font-weight: var(--pill-fw); border: 1px solid transparent; min-width: 78px; justify-content: center; }
.ov-badge.hot        { background: var(--brand); color: #fff; }
.ov-badge.qualifying { background: var(--hover); color: var(--text-secondary); }
.ov-badge.confirmed  { background: var(--brand-subtle); color: var(--brand); border-color: var(--brand-dim); }
.ov-badge.pending    { background: rgba(212,165,116,0.14); color: #d4a574; border-color: rgba(212,165,116,0.3); }
.ov-badge.today      { background: var(--brand); color: #fff; }

/* Action queue modal */
.aq-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: var(--z-modal);
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.aq-overlay.on { opacity: 1; pointer-events: auto; }
.aq-drawer {
  width: 720px; max-width: 100%; max-height: 100%;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  display: flex; flex-direction: column;
  transform: scale(0.97); transition: transform 0.18s ease;
  box-shadow: 0 30px 60px rgba(0,0,0,0.5);
  overflow: hidden;
}
.aq-overlay.on .aq-drawer { transform: scale(1); }
.aqd-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border-light); }
.aqd-head h2 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.aqd-head h2 .count { background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: var(--r-pill); font-variant-numeric: tabular-nums; }
.aqd-close { width: 30px; height: 30px; border: 0; background: var(--hover); border-radius: 50%; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.aqd-close:hover { background: var(--brand-subtle); color: var(--brand); }
.aqd-close svg { width: 13px; height: 13px; }

.aqd-tabs { display: flex; gap: 2px; padding: 12px 22px; border-bottom: 1px solid var(--border-light); }
.aqd-tabs .t { padding: 5px 12px; border: 0; background: transparent; font-size: 11.5px; font-weight: 600; color: var(--text-tertiary); border-radius: 4px; cursor: pointer; font-family: inherit; }
.aqd-tabs .t.on { background: var(--hover); color: var(--text); }
.aqd-tabs .t .b { margin-left: 6px; padding: 0 5px; background: rgba(232,97,58,0.18); color: var(--brand); font-size: 9.5px; font-weight: 700; border-radius: 8px; }

.aqd-body { flex: 1; overflow-y: auto; }
.aqd-empty { padding: 40px 22px; text-align: center; color: var(--text-tertiary); font-size: 13px; }
.aq-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 14px 22px; border-bottom: 1px solid var(--border-light); }
.aq-row .aq-kind { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0; margin-top: 2px; }
.aq-row .aq-kind svg { width: 14px; height: 14px; }
.aq-row.kind-handoff .aq-kind { background: rgba(232,97,58,0.14); color: var(--brand); }
.aq-row.kind-approval .aq-kind { background: rgba(212,165,116,0.14); color: #d4a574; }
.aq-row.kind-stale .aq-kind { background: rgba(122,178,143,0.14); color: #7ab28f; }
.aq-row .aq-body-wrap { min-width: 0; }
.aq-row .aq-title { font-size: 13px; font-weight: 500; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.aq-row .aq-title .who { font-weight: 600; }
.aq-row .aq-title .ref { color: var(--text-secondary); font-family: var(--font-mono); font-size: 11px; font-weight: 500; }
.aq-row .aq-reason { font-size: 11.5px; color: var(--text-secondary); margin-top: 4px; line-height: 1.45; }
.aq-row .aq-reason .q { font-style: italic; }
.aq-row .aq-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.aq-row .aq-age { font-size: 10px; font-weight: 600; font-family: var(--font-mono); color: var(--text-tertiary); padding: 2px 7px; background: var(--hover); border-radius: var(--r-pill); }
.aq-row .aq-age.urgent { color: var(--brand); background: var(--brand-subtle); }
.aq-row .aq-actions { display: flex; gap: 6px; flex-wrap: nowrap; justify-content: flex-end; }
.aq-row .aq-actions .aq-btn { min-width: 84px; justify-content: center; }
.aq-btn { height: var(--btn-sm); min-width: var(--btn-w-sm); padding: 0 10px; background: var(--card); border: 1px solid var(--border); border-radius: var(--btn-radius-sm); font-size: 11px; font-weight: 600; color: var(--text); cursor: pointer; font-family: inherit; }
.aq-btn:hover { border-color: var(--text-secondary); }
.aq-btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.aq-btn.primary:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.aq-btn.danger-soft { color: var(--danger); }
.aq-btn.danger-soft:hover { border-color: var(--danger); background: var(--danger-soft); }

@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .revenue-row { grid-template-columns: 1fr; }
  .cashflow-split { grid-template-columns: 1fr; }
  .cf-divider { display: none; }
  .three-up { grid-template-columns: 1fr 1fr; }
  .three-up .panel:first-child { grid-column: 1 / -1; }
  .bottom-row { grid-template-columns: 1fr; }
  .bottom-row .bl-col { grid-template-rows: auto auto; }
}

/* ============================================================
   Responsive (tablet / phone / touch) — additive, do not modify
   desktop rules above.
   ============================================================ */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .three-up { grid-template-columns: 1fr; }
  .three-up .panel:first-child { grid-column: auto; }
  .bottom-row { grid-template-columns: 1fr; }
  .bottom-row .bl-col { grid-template-rows: auto auto; }
  .auto-metrics { grid-template-columns: repeat(2, 1fr); }
  /* Hover-only "Open queue" affordance becomes visible */
  .kpi-btn .open-hint { opacity: 1; }
  /* Action-queue drawer fits viewport */
  .aq-overlay { padding: 20px 12px; }
  .aq-row { grid-template-columns: auto 1fr; gap: 10px; }
  .aq-row .aq-side { grid-column: 2; align-items: flex-start; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; }
}

@media (max-width: 640px) {
  .greeting { gap: 12px; margin-bottom: 16px; }
  .greeting h1 { font-size: 19px; }
  .quick-actions { width: 100%; }
  .qa-btn { flex: 1 1 calc(50% - 4px); min-width: 0; padding: 0 12px; }
  .alert-strip { flex-wrap: wrap; }
  .alert-strip .body { flex: 1 1 100%; }

  .kpi-grid { grid-template-columns: 1fr; gap: 10px; }
  .kpi { padding: 14px 16px; }
  .kpi .val { font-size: 22px; }

  .revenue-row { gap: 10px; }
  .rev-card { padding: 14px 16px; }
  .rev-card .big { font-size: 24px; }

  .three-up { gap: 10px; }
  .panel-head { padding: 12px 14px 8px; }
  .lead-row, .inst-row, .visit-row { padding: 10px 14px; }

  .bottom-row { gap: 10px; margin-bottom: 24px; }
  .agent-panel, .np-card, .activity { padding: 14px 16px; }
  .auto-metrics { gap: 8px; }
  .auto-m { padding: 8px 10px; }
  .auto-m .n { font-size: 17px; }

  .np-body { grid-template-columns: auto 1fr; row-gap: 8px; }
  .np-cta { grid-column: 1 / -1; flex-direction: row; }
  .np-cta .np-btn { flex: 1; }

  /* Action queue modal scales down */
  .aq-overlay { padding: 0; }
  .aq-drawer { border-radius: 0; max-height: 100vh; height: 100vh; }
  .aqd-head, .aqd-tabs { padding-left: 16px; padding-right: 16px; }
  .aq-row { padding: 12px 16px; }
  .aq-row .aq-actions { flex-wrap: wrap; }
  .aq-row .aq-actions .aq-btn { flex: 1 1 auto; min-width: 84px; }
}

@media (hover: none) and (pointer: coarse) {
  .qa-btn, .np-btn, .aq-btn { min-height: 36px; }
  .kpi-btn .open-hint { opacity: 1; }
  /* Inputs inside any overview-rendered modal (rare) avoid iOS zoom */
  .aq-drawer input, .aq-drawer select, .aq-drawer textarea { font-size: 16px; }
}

/* ============================================================
   Additional refinements — tighten narrow-viewport edge cases
   (rows that crowd, alert strip wrapping, activity timestamps).
   ============================================================ */
@media (max-width: 640px) {
  /* Alert strip: "Review all →" link wraps full-width below body */
  .alert-strip { padding: 10px 12px; gap: 8px; }
  .alert-strip .link { flex: 1 1 100%; text-align: right; }

  /* Lead row: badge wraps to its own line so name has room */
  .lead-row { grid-template-columns: auto 1fr auto; row-gap: 4px; padding: 10px 14px; }
  .lead-row .ov-badge { grid-column: 2 / -1; justify-self: start; min-width: 0; }

  /* Inst row: condense the right side */
  .inst-row { grid-template-columns: auto 1fr auto; column-gap: 8px; row-gap: 2px; }
  .inst-row .amt { font-size: 12px; }
  .inst-row .due { grid-column: 2 / -1; min-width: 0; text-align: left; font-size: 10.5px; }

  /* Activity items: prevent timestamp pushing text out */
  .act-item { grid-template-columns: auto 1fr; row-gap: 2px; }
  .act-item .time { grid-column: 2; font-size: 10px; }

  /* Visit row time chip a touch narrower so badge fits */
  .visit-row { padding: 10px 12px; }
  .visit-row .time-chip { width: 40px; }
}
