/* ═══════════════════════════════════════════════════════════════
   OKCurbs HOA Campaign Tracker — Styles
   Light theme (intentional — dense data reads better on white)
═══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:    #2d8cf0;
  --accent2:   #1a6fc4;
  --green:     #22a85a;
  --red:       #d93a3a;
  --gold:      #e8a020;
  --bg:        #f7f8fa;
  --bg2:       #eef0f4;
  --bg3:       #fff;
  --text1:     #1a1a2e;
  --text2:     #6b7385;
  --border:    rgba(0,0,0,.1);
  --radius:    12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text1);
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────── */
.crm-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.crm-header-left  { display: flex; align-items: center; gap: 10px; }
.crm-logo         { height: 32px; }
.crm-header-title { font-size: 15px; font-weight: 600; }
.crm-header-sub   { font-size: 12px; color: var(--text2); }
.crm-back-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 5px 10px;
  border: 1px solid #c5d8fc;
  border-radius: var(--radius-sm);
  background: #e8f0fe;
  white-space: nowrap;
  transition: background .15s;
}
.crm-back-btn:hover { background: #d4e6fd; }

/* ── Nav tabs ────────────────────────────────────────────────── */
.nav-tabs { display: flex; gap: 4px; }
.nav-tab {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  cursor: pointer;
  color: var(--text2);
  background: none;
  transition: all .15s;
  font-family: inherit;
}
.nav-tab:hover  { background: var(--bg2); color: var(--text1); }
.nav-tab.active { background: #e8f0fe; color: var(--accent); border-color: #c5d8fc; }

.crm-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.notif-btn {
  position: relative;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text2); font-size: 16px;
}
.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  display: none;
}

/* ── Layout ──────────────────────────────────────────────────── */
.main { display: flex; min-height: calc(100vh - 65px); }
.left-panel  { flex: 1; padding: 20px 24px; min-width: 0; border-right: 1px solid var(--border); }
.right-panel { width: 275px; flex-shrink: 0; padding: 20px 18px; display: flex; flex-direction: column; gap: 22px; }

/* ── Section label ───────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 10px;
}

/* ── Metrics ─────────────────────────────────────────────────── */
.metrics-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-bottom: 20px; }
.metric-card  { background: var(--bg2); border-radius: var(--radius-sm); padding: 12px 14px; }
.metric-label { font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.metric-val   { font-size: 22px; font-weight: 600; color: var(--text1); line-height: 1; }
.metric-sub   { font-size: 11px; color: var(--text2); margin-top: 3px; }
.metric-bar   { height: 3px; background: rgba(0,0,0,.08); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.metric-bar-fill { height: 100%; border-radius: 2px; transition: width .4s ease; }

/* ── HOA list ────────────────────────────────────────────────── */
.hoa-list    { display: flex; flex-direction: column; gap: 8px; }
.empty-state { text-align: center; padding: 52px 20px; color: var(--text2); }
.empty-state svg { display: block; margin: 0 auto 12px; opacity: .35; }
.empty-state p   { font-size: 14px; }

.hoa-card  { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.hoa-card:hover   { border-color: #b0c4f8; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.hoa-card.expanded { border-color: var(--accent); }
.hoa-row   { display: flex; align-items: center; gap: 12px; padding: 13px 16px; }

.status-light { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-light.good  { background: var(--green); box-shadow: 0 0 0 3px rgba(34,168,90,.15); }
.status-light.issue { background: var(--red);   box-shadow: 0 0 0 3px rgba(217,58,58,.15); }

.hoa-name  { font-size: 14px; font-weight: 600; color: var(--text1); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hoa-type  { font-size: 11px; color: var(--text2); }

.score-badge { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 20px; flex-shrink: 0; }
.grade-A { background: #dcfce7; color: #166534; }
.grade-B { background: #dbeafe; color: #1e40af; }
.grade-C { background: #fef9c3; color: #854d0e; }
.grade-D { background: #fee2e2; color: #991b1b; }

.stage-pill { font-size: 11px; padding: 3px 9px; border-radius: 20px; border: 1px solid var(--border); color: var(--text2); flex-shrink: 0; }
.chevron    { font-size: 13px; color: var(--text2); transition: transform .2s; display: inline-block; }
.hoa-card.expanded .chevron { transform: rotate(180deg); }

.hoa-detail { border-top: 1px solid var(--border); padding: 16px; display: none; background: var(--bg); }
.hoa-card.expanded .hoa-detail { display: block; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.detail-item label { font-size: 11px; color: var(--text2); display: block; margin-bottom: 2px; }
.detail-item span  { font-size: 13px; color: var(--text1); font-weight: 500; }

.notes-box  { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; max-height: 200px; overflow-y: auto; }
.note-item  { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.note-item:last-child { margin: 0; padding: 0; border: none; }
.note-meta  { font-size: 11px; color: var(--text2); margin-bottom: 3px; }
.note-text  { font-size: 13px; color: var(--text1); line-height: 1.55; }
.note-empty { font-size: 13px; color: var(--text2); font-style: italic; }

.add-note-row          { display: flex; gap: 8px; margin-bottom: 12px; }
.add-note-row textarea { flex: 1; font-size: 13px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff; color: var(--text1); font-family: inherit; resize: none; height: 60px; }
.action-btns           { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  font-size: 12px; padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff; cursor: pointer; color: var(--text1);
  display: inline-flex; align-items: center; gap: 5px;
  transition: all .15s; font-family: inherit;
}
.btn:hover         { border-color: var(--accent); color: var(--accent); }
.btn-primary       { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn-danger        { border-color: #fca5a5; color: var(--red); }
.btn-danger:hover  { background: #fee2e2; }
.btn-sm            { font-size: 11px; padding: 5px 10px; }

/* ── View sections ───────────────────────────────────────────── */
.view-section        { display: none; }
.view-section.active { display: block; }

/* ── Right sidebar ───────────────────────────────────────────── */
.event-card  { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.event-dot   { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.event-title { font-size: 13px; color: var(--text1); font-weight: 500; line-height: 1.3; }
.event-meta  { font-size: 11px; color: var(--text2); margin-top: 2px; }
.work-item      { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff; font-size: 12px; margin-bottom: 6px; }
.work-item-name { flex: 1; color: var(--text1); font-size: 12px; }

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay       { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; align-items: flex-start; justify-content: center; padding-top: 60px; }
.modal-overlay.open  { display: flex; }
.modal               { background: #fff; border-radius: var(--radius); border: 1px solid var(--border); width: 540px; max-height: 85vh; overflow-y: auto; box-shadow: 0 16px 48px rgba(0,0,0,.15); }
.modal-header        { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-title         { font-size: 15px; font-weight: 600; }
.modal-close         { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text2); line-height: 1; }
.modal-body          { padding: 20px; }
.form-row            { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.form-full           { grid-column: 1 / -1; }
.form-group          { display: flex; flex-direction: column; gap: 5px; }
.form-group label    { font-size: 12px; color: var(--text2); font-weight: 500; }
.form-group input,
.form-group select,
.form-group textarea { font-size: 13px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff; color: var(--text1); font-family: inherit; transition: border-color .15s; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 80px; }
.modal-footer        { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── Email templates ─────────────────────────────────────────── */
.template-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tmpl-tab      { padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 12px; cursor: pointer; background: none; color: var(--text2); font-family: inherit; }
.tmpl-tab.active { background: #e8f0fe; color: var(--accent); border-color: #c5d8fc; }
.email-preview   { background: var(--bg); border-radius: var(--radius-sm); padding: 16px; font-size: 13px; line-height: 1.7; color: var(--text1); white-space: pre-line; }
.email-field     { margin-bottom: 10px; }
.email-field label { font-size: 11px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.email-field p   { font-size: 13px; color: var(--text1); margin-top: 2px; }

/* ── Goals ───────────────────────────────────────────────────── */
.goals-grid       { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.goal-input-card  { background: var(--bg2); border-radius: var(--radius-sm); padding: 12px 14px; }
.goal-input-card label { font-size: 12px; color: var(--text2); display: block; margin-bottom: 4px; }
.goal-input-card input { font-size: 20px; font-weight: 600; border: none; background: none; color: var(--text1); width: 100%; font-family: inherit; }
.goal-input-card input:focus { outline: none; }
.goal-row       { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.goal-name      { font-size: 12px; color: var(--text1); width: 140px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-bar-wrap  { flex: 1; height: 6px; background: rgba(0,0,0,.08); border-radius: 3px; overflow: hidden; }
.goal-bar-fill  { height: 100%; border-radius: 3px; transition: width .4s; }
.goal-pct       { font-size: 11px; color: var(--text2); width: 36px; text-align: right; }

/* ── Notifications panel ─────────────────────────────────────── */
.notif-panel      { display: none; position: fixed; top: 65px; right: 16px; width: 290px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 100; }
.notif-panel.open { display: block; }
.notif-header     { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.notif-item       { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.notif-item:last-child  { border-bottom: none; }
.notif-item-title { font-size: 13px; font-weight: 500; }
.notif-item-sub   { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text1); color: #fff; font-size: 13px; padding: 10px 18px; border-radius: var(--radius-sm); z-index: 999; opacity: 0; transform: translateY(8px); transition: all .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }

/* ── Misc ────────────────────────────────────────────────────── */
.loading    { text-align: center; padding: 40px; color: var(--text2); font-size: 14px; }
.search-row { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; }
.search-row input  { flex: 1; font-size: 13px; }
.search-row select { font-size: 13px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: repeat(2,1fr); }
  .right-panel  { display: none; }
  .nav-tabs     { display: none; }
  .crm-back-btn { display: none; } /* already obvious on mobile */
}
