/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       font-size: 14px; background: #0f1117; color: #e2e8f0; }
a { color: inherit; text-decoration: none; }

/* ── Login page ─────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center;
              min-height: 100vh; background: #0f1117; }
.login-box { background: #1a1f2e; border: 1px solid #2d3748; border-radius: 12px;
             padding: 40px 36px; width: 340px; text-align: center; }
.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-box h2 { font-size: 22px; font-weight: 600; margin-bottom: 24px; color: #f7c948; }
.login-box input[type=password] { width: 100%; padding: 10px 14px; border-radius: 8px;
  border: 1px solid #3d4a5c; background: #0f1117; color: #e2e8f0;
  font-size: 15px; margin-bottom: 14px; outline: none; }
.login-box input[type=password]:focus { border-color: #f7c948; }

/* ── App layout ─────────────────────────────────────────────────── */
.app-body { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 260px; min-width: 200px; background: #141822; border-right: 1px solid #2d3748;
           display: flex; flex-direction: column; overflow: hidden; }
.sidebar-header { display: flex; align-items: center; gap: 8px; padding: 12px 14px;
                  border-bottom: 1px solid #2d3748; }
.brand { font-size: 15px; font-weight: 700; color: #f7c948; flex: 1; }
.btn-new { background: #f7c948; color: #0f1117; padding: 5px 10px; border-radius: 6px;
           font-size: 12px; font-weight: 700; }
.btn-new:hover { background: #e5b800; }
.logout-link { color: #94a3b8; font-size: 16px; padding: 4px; }
.search-bar { padding: 10px 12px; border-bottom: 1px solid #2d3748; }
.search-bar input { width: 100%; padding: 7px 10px; border-radius: 6px;
                    border: 1px solid #3d4a5c; background: #0f1117; color: #e2e8f0;
                    font-size: 13px; outline: none; }
#prop-list { flex: 1; overflow-y: auto; min-height: 0; }

/* ── Prop list items ─────────────────────────────────────────────── */
.prop-item { display: flex; flex-direction: row; align-items: baseline; justify-content: space-between; gap: 0.4rem;
             padding: 6px 12px; cursor: pointer; border-bottom: 1px solid #1a2030; transition: background 0.1s; }
.prop-item:hover { background: #1e2433; }
.prop-item.selected { background: #1e3a5f; border-left: 3px solid #f7c948; }
.prop-status { font-size: 13px; }
.prop-name { font-size: 12px; font-weight: 500; color: #c8d8f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.prop-meta { font-size: 12px; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop-date { font-size: 11px; color: #4a5568; flex-shrink: 0; }
.empty-list { padding: 20px 14px; color: #4a5568; font-size: 13px; }

/* ── Main pane ───────────────────────────────────────────────────── */
.main-pane { flex: 1; overflow-y: auto; background: #12161f; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center;
               height: 100%; gap: 16px; color: #4a5568; }
.empty-icon { font-size: 48px; }
.empty-state p { font-size: 15px; }

/* ── Form wrapper ────────────────────────────────────────────────── */
.form-wrapper { padding: 20px 28px; max-width: 900px; }

/* ── Flash ───────────────────────────────────────────────────────── */
.flash { background: #1a3a1a; border: 1px solid #2d6a2d; color: #86efac;
         padding: 14px 18px; border-radius: 8px; margin-bottom: 16px; font-size: 14px;
         font-weight: 500; border-left: 4px solid #4ade80; }
.flash-err { background: #2d1515 !important; border-color: #7f2020 !important; color: #f87171 !important; border-left-color: #ef4444 !important; }
.flash a { color: #86efac; text-decoration: underline; }
.err { color: #f87171; background: #2d1515; border: 1px solid #7f2020;
       padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.flash-ok { color: #86efac; }
.flash-err { color: #f87171; }

/* ── Action bar ──────────────────────────────────────────────────── */
.form-action-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 18px;
                   padding-bottom: 14px; border-bottom: 1px solid #2d3748; }
.btn-back { color: #94a3b8; font-size: 13px; padding: 4px 8px; border-radius: 5px;
            border: 1px solid #3d4a5c; background: #1a1f2e; white-space: nowrap; }
.btn-back:hover { color: #e2e8f0; background: #2d3748; }
.form-title { font-size: 18px; font-weight: 700; flex: 1; color: #f7c948; }
.form-actions-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge-locked { font-size: 12px; color: #94a3b8; }
.badge-signed { font-size: 12px; color: #86efac; }

/* ── View stats ──────────────────────────────────────────────────── */
.view-stats { background: #1a2a3a; border: 1px solid #2d4a6a; border-radius: 8px;
              padding: 10px 14px; margin-bottom: 16px; font-size: 13px; color: #93c5fd;
              display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn-primary { background: #f7c948; color: #0f1117; border: none; border-radius: 7px;
               padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer; }
.btn-primary:hover { background: #e5b800; }
.btn-secondary { background: #2d3748; color: #e2e8f0; border: none; border-radius: 7px;
                 padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-secondary:hover { background: #374151; }
.btn-sm { background: #1e2433; color: #94a3b8; border: 1px solid #3d4a5c;
          border-radius: 6px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.btn-sm:hover { background: #2d3748; color: #e2e8f0; }
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-xs { padding: 3px 7px; font-size: 11px; }
.btn-warn { border-color: #b45309; color: #fbbf24; }
.btn-warn:hover { background: #2a1f0a; }
.btn-danger { border-color: #7f2020; color: #f87171; }
.btn-danger:hover { background: #2d1515; }

/* ── Form sections ───────────────────────────────────────────────── */
.form-section { background: #1a1f2e; border: 1px solid #2d3748; border-radius: 10px;
                padding: 18px 20px; margin-bottom: 16px; }
.form-section-minor { margin-bottom: 12px; }
.section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.form-section h3 { font-size: 15px; font-weight: 700; color: #f7c948; margin-bottom: 14px; }
.section-header h3 { margin-bottom: 0; }
.toggle-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #94a3b8; cursor: pointer; }

/* ── Form grid ───────────────────────────────────────────────────── */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 0.4px; }
.field input, .field select, .field textarea {
  padding: 7px 10px; border-radius: 6px; border: 1px solid #3d4a5c;
  background: #0f1117; color: #e2e8f0; font-size: 13px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #f7c948; }
.field input[readonly] { opacity: 0.6; cursor: not-allowed; }
.field-inline { display: flex; align-items: center; gap: 8px; }
.field-inline label { font-size: 12px; color: #64748b; white-space: nowrap; }
.field-inline input, .field-inline select { flex: 1; min-width: 0; }
.hint { font-size: 12px; color: #64748b; margin-bottom: 12px; }

/* ── Cash/lease slots ────────────────────────────────────────────── */
.cash-slot { border: 1px solid #2d3748; border-radius: 8px; padding: 14px; margin-top: 12px; }
.slot-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.slot-header h4 { font-size: 13px; font-weight: 700; color: #e2e8f0; flex: 1; }
.escalator-row { display: flex; align-items: center; gap: 14px; padding: 10px 12px;
                 border: 1px solid #2d3748; border-radius: 7px; margin-top: 8px; }
.escalator-row.dim { opacity: 0.5; }
.lease-escalators { margin-top: 14px; }
.label-inline { border: 1px solid #3d4a5c; background: #0f1117; color: #e2e8f0;
                border-radius: 5px; padding: 4px 8px; font-size: 13px; width: 120px; }

/* ── Home photo ──────────────────────────────────────────────────── */
.home-photo-preview { width: 180px; height: 120px; object-fit: cover; border-radius: 8px;
                       border: 1px solid #3d4a5c; margin-bottom: 10px; display: block; }

/* ── CRM link ────────────────────────────────────────────────────── */
.crm-link-row { margin-top: 14px; position: relative; }
.crm-link-row label { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 0.4px; display: block; margin-bottom: 4px; }
.crm-link-row input[type=text] { width: 100%; padding: 7px 10px; border-radius: 6px;
  border: 1px solid #3d4a5c; background: #0f1117; color: #e2e8f0; font-size: 13px; outline: none; }
.crm-dropdown { position: absolute; z-index: 50; width: 100%; background: #1a1f2e;
                border: 1px solid #3d4a5c; border-radius: 7px; max-height: 200px; overflow-y: auto; }
.crm-result-list { }
.crm-result-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #2d3748; }
.crm-result-item:hover { background: #2d3748; }
.crm-result-item strong { display: block; font-size: 13px; }
.crm-meta { font-size: 11px; color: #64748b; }
.crm-result-item.dim { color: #4a5568; cursor: default; }

/* ── Collapsible panels ──────────────────────────────────────────── */
.collapsible { background: #1a1f2e; border: 1px solid #2d3748; border-radius: 10px;
               padding: 18px 20px; margin-bottom: 16px; }
.collapsible h4 { font-size: 14px; font-weight: 700; color: #f7c948; margin-bottom: 14px; }

/* ── Email panel ─────────────────────────────────────────────────── */
.email-panel .field { margin-bottom: 12px; }
.email-panel textarea { width: 100%; border-radius: 6px; border: 1px solid #3d4a5c;
  background: #0f1117; color: #e2e8f0; padding: 8px 10px; resize: vertical; outline: none; }
.email-panel textarea:focus { border-color: #f7c948; }
.email-panel input { width: 100%; padding: 7px 10px; border-radius: 6px;
  border: 1px solid #3d4a5c; background: #0f1117; color: #e2e8f0; font-size: 13px; outline: none; }

/* ── Version rows ────────────────────────────────────────────────── */
.version-row { display: flex; align-items: center; gap: 10px; padding: 7px 0;
               border-bottom: 1px solid #2d3748; font-size: 13px; }
.version-row span { flex: 1; color: #94a3b8; }
.version-row a { color: #60a5fa; }

/* ── Sold badge ──────────────────────────────────────────────────── */
.sold-badge { background: #1a3a1a; border: 1px solid #2d6a2d; color: #86efac;
              padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 700;
              display: inline-block; margin-bottom: 14px; }

/* ── Form footer ─────────────────────────────────────────────────── */
.form-footer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
               margin-top: 20px; padding-top: 16px; border-top: 1px solid #2d3748; }
.loading { color: #4a5568; font-size: 13px; padding: 8px 0; }
.dim { opacity: 0.5; }

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0f1117; }
::-webkit-scrollbar-thumb { background: #3d4a5c; border-radius: 3px; }

/* ── Sidebar collapse toggle ─────────────────────────────────────── */
.sidebar-toggle { background: none; border: none; color: #64748b; font-size: 16px;
  cursor: pointer; padding: 2px 4px; line-height: 1; flex-shrink: 0; }
.sidebar-toggle:hover { color: #94a3b8; }
.sidebar-collapsed { width: 0 !important; min-width: 0 !important; overflow: hidden !important;
  border-right: none !important; }
.sidebar-open-btn { display: none; position: fixed; top: 10px; left: 10px; z-index: 200;
  background: #1e2d42; border: 1px solid #2d3d55; color: #94a3b8; font-size: 18px;
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
  align-items: center; justify-content: center; }
.sidebar-open-btn:hover { background: #263a55; color: #e2e8f0; }

/* ── Sidebar footer (show archived toggle) ───────────────────────── */
.sidebar-footer { padding: 10px 14px; border-top: 1px solid #2d3748; flex-shrink: 0; }
.toggle-archived-label { display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: #64748b; cursor: pointer; user-select: none; }
.toggle-archived-label:hover { color: #94a3b8; }

/* ── Prop list item wrapper (for ↻ button) ───────────────────────── */
.prop-item-wrap { display: flex; align-items: stretch; position: relative; }
.prop-item-wrap .prop-item { flex: 1; }
.btn-refresh-row { display: none; background: none; border: none; color: #4a5568;
  font-size: 14px; cursor: pointer; padding: 0 8px; align-items: center;
  border-left: 1px solid #1e2535; }
.prop-item-wrap:hover .btn-refresh-row { display: flex; }
.btn-refresh-row:hover { color: #94a3b8; background: #1e2535; }

/* ── Archived proposal dimming ───────────────────────────────────── */
.prop-item.archived { opacity: 0.45; }
.prop-item.archived:hover { opacity: 0.7; }

/* ── View history table ──────────────────────────────────────────── */
.history-table { width: 100%; border-collapse: collapse; font-size: 12px;
                 margin: 8px 0 4px; color: #94a3b8; }
.history-table th { text-align: left; padding: 4px 8px; color: #64748b;
                    border-bottom: 1px solid #2d3748; font-weight: 600; }
.history-table td { padding: 4px 8px; border-bottom: 1px solid #1e2535; }

/* ── Signed PDF download link ────────────────────────────────────── */
.signed-dl-link { color: #86efac; font-size: 11px; margin-left: 8px;
  text-decoration: none; border: 1px solid #2d6a2d; border-radius: 4px;
  padding: 1px 5px; }
.signed-dl-link:hover { background: #1a3a1a; }

/* ── Published URL block ─────────────────────────────────────────── */
.url-block { background: #0d1117; border: 1px solid #2d3748; border-radius: 8px;
             padding: 8px 12px; margin-bottom: 10px; }
.url-row { display: flex; align-items: center; gap: 8px; padding: 4px 0;
           border-bottom: 1px solid #1a2235; font-size: 12px; }
.url-row:last-child { border-bottom: none; }
.url-label { color: #64748b; min-width: 80px; flex-shrink: 0; font-size: 11px; }
.url-link { color: #60a5fa; flex: 1; overflow: hidden; text-overflow: ellipsis;
            white-space: nowrap; text-decoration: none; }
.url-link:hover { text-decoration: underline; }
.url-admin-link { color: #4a5568; font-size: 11px; text-decoration: none; flex-shrink: 0; }
.url-admin-link:hover { color: #94a3b8; }
.btn-copy { background: none; border: 1px solid #2d3748; color: #4a5568;
            padding: 1px 6px; border-radius: 4px; font-size: 12px; cursor: pointer;
            flex-shrink: 0; line-height: 1.6; }
.btn-copy:hover { color: #e2e8f0; border-color: #4a5568; }

/* ── Price per watt display ──────────────────────────────────────── */
.ppw-display { color: #64748b; font-size: 11px; font-weight: normal; margin-left: 4px; }

/* ── Field hint (inline label annotation) ────────────────────────── */
.field-hint { color: #4a5568; font-size: 10px; font-weight: normal; margin-left: 4px; }

/* ── Dashboard home ─────────────────────────────────────────────── */
.p-dashboard { padding: 1.25rem; }

/* Metrics row */
.p-metrics { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.p-metric { background: #131d30; border: 1px solid #1e2d4a; border-radius: 8px; padding: 0.75rem 1.1rem; text-align: center; min-width: 80px; }
.p-mval { display: block; font-size: 1.7rem; font-weight: 700; color: #4da6ff; line-height: 1; }
.p-mlbl { display: block; font-size: 0.72rem; color: #6b7fa0; margin-top: 3px; }

/* Section header */
.p-section-hdr { font-size: 0.82rem; font-weight: 600; color: #a0b4cc; margin-bottom: 0.75rem; }

/* Proposal cards grid */
.p-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.6rem; align-items: start; }
.p-card {
  display: block; text-decoration: none; color: inherit;
  background: #0e1a2a; border: 1px solid #1e2d4a; border-radius: 8px;
  padding: 0.85rem 1rem; cursor: pointer; transition: border-color 0.15s;
}
.p-card:hover { border-color: #2563eb; }
.p-card-archived { opacity: 0.4; }
.p-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.4rem; }
.p-card-name { font-size: 0.95rem; font-weight: 600; color: #c8d8f0; line-height: 1.3; }
.p-lock { font-size: 0.7rem; opacity: 0.5; }
.p-card-sys { font-size: 0.77rem; color: #6b7fa0; margin-bottom: 0.5rem; }
.p-card-meta { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.p-card-meta span { font-size: 0.72rem; color: #4a6070; }
.p-crm-link { display: inline-block; margin-top: 7px; font-size: 0.7rem; font-weight: 600;
              color: #4da6ff; background: rgba(77,166,255,0.1); border: 1px solid rgba(77,166,255,0.25);
              border-radius: 4px; padding: 2px 8px; cursor: pointer; }
.p-crm-link:hover { background: rgba(77,166,255,0.2); }
.p-empty { grid-column: 1/-1; text-align: center; padding: 3rem; color: #4a6280; font-size: 0.9rem; }

/* Status badges */
.pbadge { display: inline-block; font-size: 0.65rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.pbadge-won    { background: #2a2000; color: #f7c948; border: 1px solid #4a3800; }
.pbadge-signed { background: #0a2e18; color: #4caf74; border: 1px solid #1a5c30; }
.pbadge-viewed { background: #0a1e38; color: #4da6ff; border: 1px solid #1a3060; }
.pbadge-sent   { background: #2a1800; color: #f59e0b; border: 1px solid #4a3000; }
.pbadge-pub    { background: #0e1a28; color: #5a7a99; border: 1px solid #1e2d42; }
.pbadge-draft  { background: #161820; color: #4a5870; border: 1px solid #242838; }
