/* ── EPZH App stylesheet v2 — deep dark, bright text ──────────────────────── */
:root {
  --app-bg:        #07090f;
  --app-bg2:       #0d1117;
  --app-surface:   #111827;
  --app-surface2:  #161d2e;
  --app-card:      #1a2235;
  --app-border:    #1e293b;
  --app-border2:   #263352;
  --app-text:      #f1f5f9;
  --app-text-dim:  #94a3b8;
  --app-muted:     #64748b;
  --app-accent:    #3b82f6;
  --app-accent2:   #8b5cf6;
  --app-glow:      rgba(59,130,246,.18);
  --app-green:     #22c55e;
  --app-red:       #ef4444;
  --app-amber:     #f59e0b;
  --sidebar-w:     240px;
  --header-h:      60px;
  --radius:        10px;
  --shadow:        0 4px 24px rgba(0,0,0,.6);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
.closely-app * { font-family: 'Inter','Segoe UI',system-ui,sans-serif; }

/* ── App shell ───────────────────────────────────────────────────────────── */
.closely-app {
  display: flex; flex-direction: column; min-height: 100vh;
  background: var(--app-bg); color: var(--app-text);
  -webkit-font-smoothing: antialiased;
}

/* ── Top header bar ──────────────────────────────────────────────────────── */
.closely-header {
  height: var(--header-h); background: var(--app-bg2);
  border-bottom: 1px solid var(--app-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; position: sticky; top: 0; z-index: 200;
  flex-shrink: 0;
}
.closely-brand    { display: flex; align-items: center; gap: 10px; }
.closely-logo     { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, var(--app-accent), var(--app-accent2)); color: #fff; font-weight: 900; font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.closely-name     { color: var(--app-text); font-size: 16px; font-weight: 700; line-height: 1; }
.closely-tag      { color: var(--app-muted); font-size: 10px; margin-top: 1px; }
.closely-header-right { display: flex; align-items: center; gap: 10px; }
.closely-username { color: var(--app-text); font-size: 13px; font-weight: 500; }
.closely-userrole { color: var(--app-muted); font-size: 11px; }
.closely-logout-link { color: var(--app-muted); font-size: 17px; text-decoration: none; padding: 6px; border-radius: 6px; transition: color .15s; }
.closely-logout-link:hover { color: var(--app-text); }
.closely-header-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--app-surface); border: 1px solid var(--app-border);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; color: var(--app-muted);
  cursor: pointer; transition: border .15s;
}
.closely-header-search:hover { border-color: var(--app-border2); }
.closely-notif-btn {
  width: 34px; height: 34px; border-radius: 8px; background: var(--app-surface);
  border: 1px solid var(--app-border); color: var(--app-muted); font-size: 16px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  position: relative; transition: all .15s;
}
.closely-notif-btn:hover { border-color: var(--app-accent); color: var(--app-text); }
.closely-notif-badge {
  position: absolute; top: -3px; right: -3px; width: 16px; height: 16px;
  background: var(--app-red); border-radius: 50%; font-size: 9px; font-weight: 700;
  color: #fff; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--app-bg2);
}

/* ── Body split: sidebar + main ──────────────────────────────────────────── */
.closely-body { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.closely-sidebar {
  width: var(--sidebar-w); background: var(--app-bg2);
  border-right: 1px solid var(--app-border);
  display: flex; flex-direction: column;
  overflow-y: auto; flex-shrink: 0;
  height: calc(100vh - var(--header-h)); position: sticky;
  top: var(--header-h);
}
.closely-nav { padding: 12px 8px; flex: 1; }
.closely-nav-section { margin-bottom: 4px; }
.closely-nav-section-label {
  font-size: 10px; font-weight: 600; color: var(--app-muted);
  letter-spacing: .08em; text-transform: uppercase;
  padding: 10px 10px 4px;
}
.closely-nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px; font-size: 13px;
  color: var(--app-text-dim); font-weight: 500; text-decoration: none;
  transition: all .15s; cursor: pointer; margin-bottom: 1px; border: none;
  background: none; width: 100%; text-align: left;
}
.closely-nav-item .nav-icon { font-size: 15px; flex-shrink: 0; opacity: .7; }
.closely-nav-item .nav-badge {
  margin-left: auto; background: var(--app-red); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px;
  border-radius: 10px; min-width: 18px; text-align: center;
}
.closely-nav-item .nav-badge.amber { background: var(--app-amber); }
.closely-nav-item .nav-badge.blue  { background: var(--app-accent); }
.closely-nav-item:hover { background: var(--app-surface); color: var(--app-text); }
.closely-nav-item:hover .nav-icon { opacity: 1; }
.closely-nav-item.active { background: rgba(59,130,246,.12); color: var(--app-accent); border: 1px solid rgba(59,130,246,.2); }
.closely-nav-item.active .nav-icon { opacity: 1; }
/* Sub-items */
.closely-nav-sub { padding-left: 12px; overflow: hidden; }
.closely-nav-sub .closely-nav-item { font-size: 12px; padding: 6px 10px; }
.closely-nav-item.has-sub .sub-arrow { margin-left: auto; font-size: 10px; transition: transform .2s; }
.closely-nav-item.has-sub.expanded .sub-arrow { transform: rotate(90deg); }

/* Sidebar bottom: integration badges */
.closely-sidebar-footer { padding: 12px; border-top: 1px solid var(--app-border); }
.closely-int-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .7rem; font-weight: 600; padding: 4px 9px;
  border-radius: 6px; margin: 2px;
}
.closely-int-badge.dotloop  { background: rgba(59,130,246,.12); color: #60a5fa; border: 1px solid rgba(59,130,246,.25); }
.closely-int-badge.skyslope { background: rgba(139,92,246,.12); color: #a78bfa; border: 1px solid rgba(139,92,246,.25); }

/* ── Main content area ───────────────────────────────────────────────────── */
.closely-main {
  flex: 1; overflow-y: auto; padding: 28px 32px;
  background: var(--app-bg);
}
.closely-page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px; flex-wrap: wrap; gap: 12px;
}
.closely-page-title { font-size: 1.4rem; font-weight: 700; color: var(--app-text); line-height: 1.2; }
.closely-page-sub { font-size: .85rem; color: var(--app-muted); margin-top: 3px; }

/* ── KPI stat cards ──────────────────────────────────────────────────────── */
.closely-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.closely-kpi {
  background: var(--app-surface); border: 1px solid var(--app-border);
  border-radius: var(--radius); padding: 20px; position: relative; overflow: hidden;
}
.closely-kpi::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--app-accent), var(--app-accent2)); }
.closely-kpi-icon { font-size: 1.4rem; margin-bottom: 8px; }
.closely-kpi-val { font-size: 1.8rem; font-weight: 800; color: var(--app-text); line-height: 1; }
.closely-kpi-label { font-size: .78rem; color: var(--app-muted); margin-top: 4px; }
.closely-kpi-delta { font-size: .75rem; margin-top: 6px; }
.closely-kpi-delta.up { color: var(--app-green); }
.closely-kpi-delta.down { color: var(--app-red); }
.closely-kpi.accent .closely-kpi-val { color: var(--app-accent); }
.closely-kpi.green  .closely-kpi-val { color: var(--app-green); }
.closely-kpi.amber  .closely-kpi-val { color: var(--app-amber); }
.closely-kpi.red    .closely-kpi-val { color: var(--app-red); }

/* ── Grid layouts ────────────────────────────────────────────────────────── */
.closely-grid-2  { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }
.closely-grid-3  { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; margin-bottom: 28px; }
.closely-grid-13 { display: grid; grid-template-columns: 1fr 3fr; gap: 20px; margin-bottom: 28px; }
.closely-grid-31 { display: grid; grid-template-columns: 3fr 1fr; gap: 20px; margin-bottom: 28px; }

/* ── Section cards ───────────────────────────────────────────────────────── */
.closely-section {
  background: var(--app-surface); border: 1px solid var(--app-border);
  border-radius: var(--radius); margin-bottom: 24px;
}
.closely-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--app-border);
}
.closely-section-title { font-size: .9rem; font-weight: 600; color: var(--app-text); }
.closely-section-action { font-size: .78rem; color: var(--app-accent); cursor: pointer; text-decoration: none; }
.closely-section-body { padding: 16px 20px; }

/* ── Data tables ─────────────────────────────────────────────────────────── */
.closely-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.closely-table th { text-align: left; font-size: .72rem; font-weight: 600; color: var(--app-muted); letter-spacing: .06em; text-transform: uppercase; padding: 8px 12px; border-bottom: 1px solid var(--app-border); }
.closely-table td { padding: 11px 12px; border-bottom: 1px solid rgba(30,41,59,.5); color: var(--app-text-dim); vertical-align: middle; }
.closely-table tr:last-child td { border-bottom: none; }
.closely-table tr:hover td { background: var(--app-surface2); color: var(--app-text); }
.closely-table a { color: var(--app-text); text-decoration: none; }
.closely-table a:hover { color: var(--app-accent); }

/* ── Pill / badge ────────────────────────────────────────────────────────── */
.closely-pill {
  display: inline-flex; align-items: center; padding: 3px 9px;
  border-radius: 20px; font-size: .7rem; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
}
.closely-pill-blue   { background: rgba(59,130,246,.12);  color: #60a5fa;  border: 1px solid rgba(59,130,246,.25); }
.closely-pill-green  { background: rgba(34,197,94,.12);   color: #4ade80;  border: 1px solid rgba(34,197,94,.25); }
.closely-pill-amber  { background: rgba(245,158,11,.12);  color: #fbbf24;  border: 1px solid rgba(245,158,11,.25); }
.closely-pill-red    { background: rgba(239,68,68,.12);   color: #f87171;  border: 1px solid rgba(239,68,68,.25); }
.closely-pill-purple { background: rgba(139,92,246,.12);  color: #a78bfa;  border: 1px solid rgba(139,92,246,.25); }
.closely-pill-gray   { background: rgba(100,116,139,.12); color: #94a3b8;  border: 1px solid rgba(100,116,139,.25); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.closely-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: .85rem;
  font-weight: 600; border: none; cursor: pointer; transition: all .15s; text-decoration: none;
}
.closely-btn-primary  { background: var(--app-accent); color: #fff; }
.closely-btn-primary:hover { background: #2563eb; }
.closely-btn-secondary { background: var(--app-surface2); color: var(--app-text); border: 1px solid var(--app-border2); }
.closely-btn-secondary:hover { background: var(--app-card); }
.closely-btn-ghost { background: transparent; color: var(--app-text-dim); border: 1px solid var(--app-border); }
.closely-btn-ghost:hover { color: var(--app-text); border-color: var(--app-border2); }
.closely-btn-danger { background: rgba(239,68,68,.12); color: #f87171; border: 1px solid rgba(239,68,68,.2); }
.closely-btn-danger:hover { background: rgba(239,68,68,.2); }
.closely-btn-sm { padding: 6px 12px; font-size: .78rem; }
.closely-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.closely-form-group { margin-bottom: 18px; }
.closely-label { display: block; font-size: .8rem; font-weight: 500; color: var(--app-text-dim); margin-bottom: 6px; }
.closely-input, .closely-select, .closely-textarea {
  width: 100%; padding: 10px 13px; border-radius: 8px; font-size: .9rem;
  background: var(--app-bg2); border: 1px solid var(--app-border2); color: var(--app-text);
  outline: none; transition: border .15s; font-family: inherit;
}
.closely-input:focus, .closely-select:focus, .closely-textarea:focus {
  border-color: var(--app-accent); box-shadow: 0 0 0 3px var(--app-glow);
}
.closely-input::placeholder { color: var(--app-muted); }
.closely-select { cursor: pointer; }
.closely-textarea { min-height: 100px; resize: vertical; }
.closely-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.closely-form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.closely-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--app-border); margin-bottom: 24px; overflow-x: auto; }
.closely-tab-btn {
  padding: 10px 18px; background: none; border: none; border-bottom: 2px solid transparent;
  font-size: .85rem; font-weight: 500; color: var(--app-text-dim);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.closely-tab-btn:hover { color: var(--app-text); }
.closely-tab-btn.active { color: var(--app-accent); border-bottom-color: var(--app-accent); }
.closely-tab-pane { display: none; }
.closely-tab-pane.active { display: block; }

/* ── Transaction hero ────────────────────────────────────────────────────── */
.closely-txn-hero {
  background: var(--app-surface); border: 1px solid var(--app-border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 24px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.closely-txn-meta-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.closely-back { font-size: .8rem; color: var(--app-muted); text-decoration: none; display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.closely-back:hover { color: var(--app-text); }
.closely-h1 { font-size: 1.4rem; font-weight: 700; color: var(--app-text); }
.closely-h2 { font-size: 1.1rem; font-weight: 600; color: var(--app-text); margin-bottom: 14px; }
.closely-h3 { font-size: .95rem; font-weight: 600; color: var(--app-text); margin-bottom: 10px; }

/* ── Stage progress strip ────────────────────────────────────────────────── */
.closely-stage-strip {
  display: flex; gap: 0; overflow-x: auto; margin-bottom: 24px;
  background: var(--app-surface); border: 1px solid var(--app-border);
  border-radius: var(--radius); padding: 0;
}
.closely-stage-step {
  flex: 1; min-width: 80px; padding: 12px 8px; text-align: center;
  border-right: 1px solid var(--app-border); position: relative;
}
.closely-stage-step:last-child { border-right: none; }
.closely-stage-step-num { font-size: .7rem; color: var(--app-muted); margin-bottom: 3px; }
.closely-stage-step-label { font-size: .72rem; color: var(--app-muted); font-weight: 500; }
.closely-stage-step.done { background: rgba(34,197,94,.05); }
.closely-stage-step.done .closely-stage-step-label { color: var(--app-green); }
.closely-stage-step.current { background: rgba(59,130,246,.08); border-bottom: 2px solid var(--app-accent); }
.closely-stage-step.current .closely-stage-step-label { color: var(--app-accent); font-weight: 600; }

/* ── Task list ───────────────────────────────────────────────────────────── */
.closely-task-stage-group { margin-bottom: 20px; }
.closely-task-stage-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.closely-task-stage-num { width: 22px; height: 22px; border-radius: 50%; background: var(--app-surface2); font-size: .72rem; font-weight: 700; display: flex; align-items: center; justify-content: center; color: var(--app-text-dim); }
.closely-task-stage-name { font-size: .82rem; font-weight: 600; color: var(--app-text-dim); }
.closely-task-stage-group.closely-stage-future .closely-task-stage-name { color: var(--app-muted); }
.closely-task-stage-group.closely-stage-future { opacity: .45; }
.closely-tasks { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.closely-task-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--app-bg2);
  border: 1px solid var(--app-border); border-radius: 8px; transition: all .15s;
}
.closely-task-item:hover { border-color: var(--app-border2); }
.closely-task-done { opacity: .55; }
.closely-task-done .closely-task-label { text-decoration: line-through; }
.closely-task-cb { width: 16px; height: 16px; cursor: pointer; accent-color: var(--app-accent); flex-shrink: 0; }
.closely-task-label { font-size: .85rem; color: var(--app-text-dim); }

/* ── Alert / notification rows ───────────────────────────────────────────── */
.closely-alert-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-radius: 8px; margin-bottom: 8px; border: 1px solid;
}
.closely-alert-row.red    { background: rgba(239,68,68,.06);  border-color: rgba(239,68,68,.2); }
.closely-alert-row.amber  { background: rgba(245,158,11,.06); border-color: rgba(245,158,11,.2); }
.closely-alert-row.blue   { background: rgba(59,130,246,.06); border-color: rgba(59,130,246,.2); }
.closely-alert-row.green  { background: rgba(34,197,94,.06);  border-color: rgba(34,197,94,.2); }
.closely-alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.closely-alert-title { font-size: .85rem; font-weight: 600; color: var(--app-text); }
.closely-alert-sub { font-size: .78rem; color: var(--app-muted); margin-top: 2px; }
.closely-alert-success { background: rgba(34,197,94,.08); color: #4ade80; border: 1px solid rgba(34,197,94,.2); border-radius: 8px; padding: 10px 14px; font-size: .85rem; margin-top: 8px; }
.closely-alert-error { background: rgba(239,68,68,.08); color: #f87171; border: 1px solid rgba(239,68,68,.2); border-radius: 8px; padding: 10px 14px; font-size: .85rem; margin-top: 8px; }

/* ── Activity log ────────────────────────────────────────────────────────── */
.closely-activity-list { display: flex; flex-direction: column; gap: 0; }
.closely-activity-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(30,41,59,.5); }
.closely-activity-item:last-child { border-bottom: none; }
.closely-activity-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--app-surface2); display: flex; align-items: center; justify-content: center; font-size: .85rem; flex-shrink: 0; }
.closely-activity-text { font-size: .83rem; color: var(--app-text-dim); line-height: 1.4; }
.closely-activity-time { font-size: .72rem; color: var(--app-muted); margin-top: 2px; }

/* ── Financial section ───────────────────────────────────────────────────── */
.closely-financial-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(30,41,59,.4); font-size: .88rem; }
.closely-financial-row:last-child { border-bottom: none; }
.closely-financial-label { color: var(--app-text-dim); }
.closely-financial-val { font-weight: 500; color: var(--app-text); }
.closely-financial-total { background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.2); border-radius: 8px; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.closely-financial-total-label { font-weight: 600; color: var(--app-text); }
.closely-financial-total-val { font-size: 1.2rem; font-weight: 800; color: var(--app-accent); }

/* ── Pipeline card ───────────────────────────────────────────────────────── */
.closely-pipeline-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; margin-bottom: 24px; }
.closely-pipeline-card {
  background: var(--app-surface); border: 1px solid var(--app-border);
  border-radius: var(--radius); padding: 18px; transition: all .2s;
}
.closely-pipeline-card:hover { border-color: var(--app-border2); box-shadow: var(--shadow); }
.closely-pipeline-card-address { font-size: .9rem; font-weight: 600; color: var(--app-text); margin-bottom: 6px; }
.closely-pipeline-card-price { font-size: .82rem; color: var(--app-muted); margin-bottom: 12px; }
.closely-pipeline-progress { height: 4px; background: var(--app-border); border-radius: 2px; margin: 10px 0; overflow: hidden; }
.closely-pipeline-progress-fill { height: 100%; background: linear-gradient(90deg, var(--app-accent), var(--app-accent2)); border-radius: 2px; }
.closely-pipeline-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* ── Party cards ─────────────────────────────────────────────────────────── */
.closely-parties-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 12px; }
.closely-party-card { background: var(--app-bg2); border: 1px solid var(--app-border); border-radius: 8px; padding: 14px; display: flex; align-items: center; gap: 12px; }
.closely-party-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--app-accent), var(--app-accent2)); display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.closely-party-name { font-size: .85rem; font-weight: 500; color: var(--app-text); }
.closely-party-role { font-size: .72rem; color: var(--app-muted); margin-top: 2px; }

/* ── Offer cards ─────────────────────────────────────────────────────────── */
.closely-offer-card { background: var(--app-bg2); border: 1px solid var(--app-border); border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.closely-offer-price { font-size: 1.2rem; font-weight: 700; color: var(--app-text); }
.closely-offer-meta { display: flex; gap: 16px; margin: 8px 0; font-size: .82rem; color: var(--app-muted); flex-wrap: wrap; }
.closely-offer-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ── Integration status ──────────────────────────────────────────────────── */
.closely-int-card { background: var(--app-bg2); border: 1px solid var(--app-border); border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.closely-int-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.closely-int-name { font-size: .9rem; font-weight: 600; color: var(--app-text); }
.closely-int-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--app-green); }
.closely-int-status-dot.red { background: var(--app-red); }
.closely-int-meta { font-size: .78rem; color: var(--app-muted); margin-top: 4px; }

/* ── Deadline tracker ────────────────────────────────────────────────────── */
.closely-deadline-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(30,41,59,.4); font-size: .85rem; }
.closely-deadline-row:last-child { border-bottom: none; }
.closely-deadline-date { min-width: 80px; font-weight: 600; color: var(--app-text); }
.closely-deadline-label { flex: 1; color: var(--app-text-dim); }
.closely-deadline-days { font-size: .78rem; font-weight: 600; padding: 3px 8px; border-radius: 6px; }
.closely-deadline-days.overdue { background: rgba(239,68,68,.12); color: #f87171; }
.closely-deadline-days.urgent  { background: rgba(245,158,11,.12); color: #fbbf24; }
.closely-deadline-days.ok      { background: rgba(34,197,94,.12);  color: #4ade80; }

/* ── New-transaction wizard ──────────────────────────────────────────────── */
.closely-wizard { max-width: 840px; margin: 0 auto; }
.closely-wizard-steps { display: flex; margin-bottom: 36px; gap: 0; }
.closely-wizard-step { flex: 1; display: flex; align-items: center; gap: 0; }
.closely-wizard-step-inner { display: flex; flex-direction: column; align-items: center; position: relative; flex: 1; }
.closely-wizard-step-dot { width: 32px; height: 32px; border-radius: 50%; background: var(--app-surface2); border: 2px solid var(--app-border2); display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; color: var(--app-muted); z-index: 1; transition: all .3s; }
.closely-wizard-step.done .closely-wizard-step-dot { background: var(--app-green); border-color: var(--app-green); color: #fff; }
.closely-wizard-step.current .closely-wizard-step-dot { background: var(--app-accent); border-color: var(--app-accent); color: #fff; box-shadow: 0 0 12px var(--app-glow); }
.closely-wizard-step-label { font-size: .72rem; color: var(--app-muted); margin-top: 6px; text-align: center; }
.closely-wizard-step.current .closely-wizard-step-label { color: var(--app-accent); }
.closely-wizard-step-line { flex: 1; height: 2px; background: var(--app-border2); margin: 0 0 0 0; transform: translateY(-10px); }
.closely-wizard-step.done ~ .closely-wizard-step .closely-wizard-step-line { background: var(--app-green); }
.closely-wizard-body { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--radius); padding: 32px; }
.closely-wizard-footer { display: flex; justify-content: space-between; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--app-border); }
.closely-wizard-pane { display: none; }
.closely-wizard-pane.active { display: block; }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.closely-link { color: var(--app-accent); text-decoration: none; font-size: .85rem; }
.closely-link:hover { text-decoration: underline; }
.closely-muted { color: var(--app-muted); font-size: .85rem; }
.closely-divider { height: 1px; background: var(--app-border); margin: 20px 0; }
.closely-search-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.closely-search-bar .closely-input { max-width: 320px; padding: 8px 12px; }
.closely-empty { text-align: center; padding: 60px 20px; color: var(--app-muted); }
.closely-empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .5; }
.closely-empty-title { font-size: .95rem; font-weight: 500; color: var(--app-text-dim); }
.closely-spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--app-border2); border-top-color: var(--app-accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.closely-ai-summary-text { font-style: italic; color: var(--app-text-dim); font-size: .88rem; line-height: 1.6; }
.closely-sig-reminder { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 8px; background: rgba(245,158,11,.07); border: 1px solid rgba(245,158,11,.2); margin-bottom: 8px; gap: 10px; }
.closely-sig-overdue { background: rgba(239,68,68,.07); border-color: rgba(239,68,68,.2); }
.closely-sig-label { font-size: .85rem; color: var(--app-text-dim); flex: 1; }
.closely-sig-status { font-size: .72rem; font-weight: 600; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) { .closely-kpis { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 860px)  { .closely-sidebar { display: none; } .closely-main { padding: 20px; } }
@media (max-width: 640px)  { .closely-kpis { grid-template-columns: 1fr 1fr; } .closely-grid-2, .closely-grid-3, .closely-grid-31, .closely-grid-13 { grid-template-columns: 1fr; } }

/* ── Dashboard & hub additions ──────────────────────────────────────────────── */

/* KPI warn state */
.closely-kpi-card.closely-kpi-warn { border-color: rgba(239,68,68,.4); background: linear-gradient(135deg,rgba(239,68,68,.07),var(--app-card)); }
.closely-kpi-card.closely-kpi-warn .closely-kpi-value { color: #ef4444; }

/* Card header link */
.closely-card-link { font-size: .78rem; color: var(--app-accent); text-decoration: none; }
.closely-card-link:hover { text-decoration: underline; }

/* Tab bar */
.closely-tab-bar { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--app-border); padding-bottom: 0; }
.closely-tab-btn {
  padding: 8px 14px; font-size: .82rem; font-weight: 500; color: var(--app-muted);
  border-radius: 6px 6px 0 0; background: transparent; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; text-decoration: none; transition: color .15s, border-color .15s;
  display: inline-flex; align-items: center; gap: 6px;
  transform: translateY(1px);
}
.closely-tab-btn:hover { color: var(--app-text); }
.closely-tab-btn.active { color: var(--app-accent); border-bottom-color: var(--app-accent); }

/* Badge counts in tabs */
.closely-badge-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; border-radius: 9px; font-size: .68rem; font-weight: 700; padding: 0 4px; }
.closely-badge-count.red { background: rgba(239,68,68,.2); color: #ef4444; }
.closely-badge-count.amber { background: rgba(245,158,11,.2); color: #f59e0b; }

/* Deadline rows */
.closely-deadline-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--app-border);
  transition: background .1s;
}
.closely-deadline-row:last-child { border-bottom: none; }
.closely-deadline-row:hover { background: var(--app-surface); }
.closely-deadline-row.warn  { background: rgba(245,158,11,.04); }
.closely-deadline-row.urgent{ background: rgba(239,68,68,.06); }

/* Alert row variants */
.closely-alert-green {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: 8px;
  background: rgba(34,197,94,.07); border: 1px solid rgba(34,197,94,.25); color: #86efac;
}

/* Empty state subtitle */
.closely-empty-sub { font-size: .82rem; color: var(--app-muted); margin-top: 6px; }

/* Activity log */
.closely-activity-log { display: flex; flex-direction: column; }
.closely-activity-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 16px;
  border-bottom: 1px solid var(--app-border);
}
.closely-activity-item:last-child { border-bottom: none; }
.closely-activity-icon { font-size: 1rem; flex-shrink: 0; width: 24px; text-align: center; margin-top: 1px; }

/* Task items */
.closely-task-list { display: flex; flex-direction: column; }
.closely-task-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--app-border);
  transition: background .1s;
}
.closely-task-item:last-child { border-bottom: none; }
.closely-task-item:hover { background: var(--app-surface); }
.closely-task-item.done { opacity: .55; }
.closely-task-check {
  width: 18px; height: 18px; border-radius: 4px; border: 2px solid var(--app-border2);
  flex-shrink: 0; margin-top: 1px; display: flex; align-items: center; justify-content: center;
  font-size: .7rem; color: #fff; transition: .15s;
}
.closely-task-check.checked { background: var(--app-green); border-color: var(--app-green); }
.closely-task-label { font-size: .85rem; font-weight: 500; color: var(--app-text); line-height: 1.3; }
.closely-task-meta { font-size: .73rem; color: var(--app-muted); margin-top: 2px; }

/* Form field groups */
.closely-field-group { display: flex; flex-direction: column; gap: 4px; }
.closely-label { font-size: .78rem; font-weight: 600; color: var(--app-text-dim); letter-spacing: .02em; }

/* Integration status badges */
.closely-int-badge { font-size: .7rem; font-weight: 600; padding: 3px 8px; border-radius: 4px; }
.closely-int-badge.dotloop  { background: rgba(99,102,241,.2); color: #a5b4fc; }
.closely-int-badge.skyslope { background: rgba(34,197,94,.15); color: #86efac; }


/* ── Aliases for new template class names ────────────────────────────────────── */

/* .closely-kpi-grid → same as .closely-kpis but flexible column count */
.closely-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

/* .closely-kpi-card → matches .closely-kpi */
.closely-kpi-card {
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: var(--radius);
  padding: 18px 16px;
  position: relative;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.closely-kpi-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--app-accent), var(--app-accent2));
}
.closely-kpi-card:hover { border-color: var(--app-border2); box-shadow: var(--shadow); }
.closely-kpi-card .closely-kpi-icon { font-size: 1.3rem; margin-bottom: 6px; }
.closely-kpi-card .closely-kpi-value {
  font-size: 1.65rem; font-weight: 800; color: var(--app-text); line-height: 1.1;
}
.closely-kpi-card .closely-kpi-label {
  font-size: .73rem; color: var(--app-muted); margin-top: 4px;
}

/* Standalone alert modifier classes (supplement the existing .closely-alert-row.red etc.) */
.closely-alert-red {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: 8px;
  background: rgba(239,68,68,.06); border: 1px solid rgba(239,68,68,.2); color: #fca5a5;
}
.closely-alert-amber {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: 8px;
  background: rgba(245,158,11,.06); border: 1px solid rgba(245,158,11,.2); color: #fcd34d;
}


/* ── CRM / Pipeline board ────────────────────────────────────────────────── */
.closely-kanban-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.closely-kanban-col   { width: 220px; flex-shrink: 0; }
.closely-kanban-hdr   { padding: 10px 12px; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 8px 8px 0 0; margin-bottom: 8px; }
.closely-kanban-card  {
  background: var(--app-card); border: 1px solid var(--app-border); border-radius: 8px;
  padding: 12px; margin-bottom: 8px; text-decoration: none; display: block;
  transition: border-color .15s, box-shadow .15s; cursor: pointer;
}
.closely-kanban-card:hover { box-shadow: var(--shadow); }

/* ── Property data panel ─────────────────────────────────────────────────── */
.closely-prop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 12px; }
.closely-prop-fact { background: var(--app-bg); border: 1px solid var(--app-border); border-radius: 8px; padding: 10px 12px; }
.closely-prop-fact-label { font-size: .7rem; color: var(--app-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.closely-prop-fact-value { font-size: .92rem; font-weight: 700; color: var(--app-text); margin-top: 3px; }
.closely-streetview { width: 100%; border-radius: 10px; aspect-ratio: 16/6; object-fit: cover; border: 1px solid var(--app-border); }

/* ── ALTA / settlement ───────────────────────────────────────────────────── */
.closely-alta-section { margin-bottom: 20px; }
.closely-alta-row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid rgba(30,41,59,.5); font-size: .83rem; }
.closely-alta-total { display: flex; justify-content: space-between; font-weight: 700; font-size: .9rem; border-top: 2px solid var(--app-border); padding: 8px 0; margin-top: 4px; }
.closely-ctc-box { background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.3); border-radius: 10px; padding: 20px; text-align: center; }
.closely-ctc-amount { font-size: 2rem; font-weight: 900; color: #60a5fa; }
.closely-proceeds-box { background: rgba(34,197,94,.07); border: 1px solid rgba(34,197,94,.25); border-radius: 10px; padding: 20px; text-align: center; }
.closely-proceeds-amount { font-size: 2rem; font-weight: 900; color: #4ade80; }

/* ── Address auto-fill loading indicator ────────────────────────────────── */
.closely-addr-loading { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--app-muted); }
.closely-addr-chip { display: inline-flex; align-items: center; gap: 4px; background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.2); border-radius: 6px; padding: 3px 8px; font-size: .72rem; color: var(--app-accent); }


/* ── Address autocomplete dropdown ──────────────────────────────────────────── */
#epzh-addr-suggestions div.ac-active {
  background: var(--app-surface2) !important;
  color: var(--app-accent) !important;
}
#epzh-addr-suggestions::-webkit-scrollbar { width: 5px; }
#epzh-addr-suggestions::-webkit-scrollbar-thumb { background: var(--app-border2); border-radius: 3px; }

/* ── All-50-states select: full width ───────────────────────────────────────── */
select#epzh-field-state option { font-size: .85rem; }

/* ── Document upload panel ───────────────────────────────────────────────── */
#epzh-dropzone {
  border: 2px dashed var(--app-border2);
  border-radius: 10px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
#epzh-dropzone:hover,
#epzh-dropzone.drag-over {
  border-color: var(--app-accent);
  background: rgba(59,130,246,.05);
}
#epzh-dropzone.drag-over { border-style: solid; }

#epzh-staged-files .closely-input { width: 100%; }

/* Upload progress row */
.epzh-upload-file-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; background: var(--app-surface); border-radius: 6px; margin-bottom: 6px;
}
.epzh-progress-bar-wrap {
  flex: 1; height: 6px; background: var(--app-border); border-radius: 3px; overflow: hidden;
}
.epzh-progress-bar {
  height: 100%; background: var(--app-accent); border-radius: 3px;
  transition: width .3s;
}
