/* =========================================================
   SolarDesk theme: white + dark purple
   ========================================================= */
:root {
  --sd-purple-950: #1e0a3c;
  --sd-purple-900: #2e1065;
  --sd-purple-800: #4c1d95;
  --sd-purple-700: #5b21b6;
  --sd-purple-600: #6d28d9;
  --sd-purple-500: #7c3aed;
  --sd-purple-200: #ddd6fe;
  --sd-purple-100: #ede9fe;
  --sd-purple-50:  #f5f3ff;
  --sd-bg: #f8f7fc;
  --sd-surface: #ffffff;
  --sd-border: #ebe8f3;
  --sd-text: #1f1830;
  --sd-muted: #6b6480;
  --sd-radius: 14px;
  --sd-shadow: 0 1px 2px rgba(46, 16, 101, .04), 0 4px 16px rgba(46, 16, 101, .06);
  --sd-shadow-lg: 0 10px 40px rgba(46, 16, 101, .16);

  --bs-primary: var(--sd-purple-800);
  --bs-primary-rgb: 76, 29, 149;
  --bs-link-color: var(--sd-purple-700);
  --bs-link-color-rgb: 91, 33, 182;
  --bs-link-hover-color: var(--sd-purple-900);
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--sd-text);
  --bs-border-color: var(--sd-border);
  --bs-border-radius: 10px;
  --bs-focus-ring-color: rgba(124, 58, 237, .25);
}

html { font-size: 15px; }
body { background: var(--sd-bg); color: var(--sd-text); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
.text-muted { color: var(--sd-muted) !important; }
.text-purple { color: var(--sd-purple-800) !important; }
.bg-purple { background: var(--sd-purple-800) !important; color: #fff; }
.bg-purple-soft { background: var(--sd-purple-50) !important; }
.fw-semibold { font-weight: 600 !important; }
.small-caps { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; color: var(--sd-muted); }

/* ---------- Buttons & forms ---------- */
.btn { font-weight: 500; border-radius: 10px; padding: .5rem 1rem; transition: all .15s ease; }
.btn-sm { padding: .3rem .7rem; border-radius: 8px; }
.btn-primary {
  --bs-btn-bg: var(--sd-purple-800); --bs-btn-border-color: var(--sd-purple-800);
  --bs-btn-hover-bg: var(--sd-purple-900); --bs-btn-hover-border-color: var(--sd-purple-900);
  --bs-btn-active-bg: var(--sd-purple-950); --bs-btn-active-border-color: var(--sd-purple-950);
  --bs-btn-disabled-bg: var(--sd-purple-600); --bs-btn-disabled-border-color: var(--sd-purple-600);
  box-shadow: 0 2px 8px rgba(76, 29, 149, .25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(76, 29, 149, .35); }
.btn-outline-primary {
  --bs-btn-color: var(--sd-purple-800); --bs-btn-border-color: var(--sd-purple-200);
  --bs-btn-hover-bg: var(--sd-purple-800); --bs-btn-hover-border-color: var(--sd-purple-800);
  --bs-btn-active-bg: var(--sd-purple-900);
}
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--sd-border); --bs-btn-hover-bg: var(--sd-purple-50); --bs-btn-hover-border-color: var(--sd-purple-200); }
.btn-soft { background: var(--sd-purple-50); color: var(--sd-purple-800); border: 1px solid transparent; }
.btn-soft:hover { background: var(--sd-purple-100); color: var(--sd-purple-900); }
.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

.form-control, .form-select { border-radius: 10px; border-color: var(--sd-border); padding: .55rem .8rem; }
/* Keep room for the dropdown arrow (the padding above would otherwise let text run under it). */
.form-select { padding-right: 2.4rem; background-position: right .8rem center; }
.form-select-sm { padding-right: 2.1rem; background-position: right .6rem center; }
.form-select.w-auto { min-width: 10.5rem; }
.form-control:focus, .form-select:focus { border-color: var(--sd-purple-500); box-shadow: 0 0 0 .2rem rgba(124, 58, 237, .15); }
.form-label { font-weight: 500; font-size: .87rem; margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--sd-purple-800); border-color: var(--sd-purple-800); }
.form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(124, 58, 237, .2); border-color: var(--sd-purple-500); }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--sd-muted); }
.input-icon > .form-control { padding-left: 2.3rem; }

/* Segmented control */
.segmented { display: inline-flex; background: var(--sd-purple-50); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented input { display: none; }
.segmented label { padding: .4rem .9rem; border-radius: 8px; cursor: pointer; font-weight: 500; font-size: .87rem; color: var(--sd-muted); transition: all .15s; }
.segmented input:checked + label { background: #fff; color: var(--sd-purple-800); box-shadow: 0 1px 4px rgba(46, 16, 101, .12); }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--sd-border); border-radius: var(--sd-radius); box-shadow: var(--sd-shadow); background: var(--sd-surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--sd-border); padding: 1rem 1.25rem; font-weight: 600; }
.card-body { padding: 1.25rem; }
.card-hover { transition: transform .15s, box-shadow .15s; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--sd-shadow-lg); }

.kpi { position: relative; overflow: hidden; }
.kpi .kpi-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; background: var(--sd-purple-50); color: var(--sd-purple-800); }
.kpi .kpi-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.kpi.kpi-dark { background: var(--sd-purple-900); color: #fff; border: 0; }
.kpi.kpi-dark .text-muted { color: rgba(255, 255, 255, .7) !important; }
.kpi.kpi-dark .kpi-icon { background: rgba(255, 255, 255, .12); color: #fff; }

/* ---------- Badges / status ---------- */
.badge { font-weight: 600; padding: .38em .7em; border-radius: 999px; }
.status { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-New { background: #f1effa; color: #5b5675; }
.status-SiteSurvey { background: #ede9fe; color: #6d28d9; }
.status-QuotationSent { background: #e0e7ff; color: #4338ca; }
.status-Won { background: #dcfce7; color: #15803d; }
.status-Installation { background: #fef3c7; color: #b45309; }
.status-NetMetering { background: #e0f2fe; color: #0369a1; }
.status-Completed { background: #2e1065; color: #fff; }
.status-Lost { background: #fee2e2; color: #b91c1c; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; position: fixed; inset: 0 auto 0 0; z-index: 1040;
  background: var(--sd-purple-900);
  color: #fff; display: flex; flex-direction: column; transition: transform .25s ease;
}
.sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: 1.3rem 1.4rem; color: #fff; font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: #fff; color: var(--sd-purple-800); display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.sidebar .nav-section { padding: .4rem 1.4rem; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: rgba(255, 255, 255, .45); margin-top: .6rem; }
.sidebar .nav-link {
  display: flex; align-items: center; gap: .75rem; margin: 2px .8rem; padding: .62rem .8rem; border-radius: 10px;
  color: rgba(255, 255, 255, .75); font-weight: 500; transition: all .15s;
}
.sidebar .nav-link i { font-size: 1.1rem; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar .nav-link.active { background: #fff; color: var(--sd-purple-900); box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
.sidebar .user-card { margin: auto .8rem 1rem; padding: .8rem; border-radius: 12px; background: rgba(255, 255, 255, .07); display: flex; align-items: center; gap: .7rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; background: var(--sd-purple-100); color: var(--sd-purple-800); flex-shrink: 0; }
.sidebar .avatar { background: #fff; }

.main { flex: 1; margin-left: 248px; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1030; height: 64px; display: flex; align-items: center; gap: 1rem; padding: 0 1.75rem;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--sd-border);
}
.topbar .page-title { font-weight: 600; font-size: 1.05rem; margin: 0; }
.location-switch { min-width: 200px; }
.content { padding: 1.75rem; max-width: 1400px; width: 100%; }
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open + .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(30, 10, 60, .45); z-index: 1035; }
  .main { margin-left: 0; }
  .content { padding: 1.1rem; }
  .topbar { padding: 0 1rem; }
  .location-switch { min-width: 0; max-width: 170px; }
}

/* ---------- Tables ---------- */
.table { --bs-table-hover-bg: var(--sd-purple-50); margin: 0; }
.table > thead th { font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; color: var(--sd-muted); font-weight: 600; background: #fbfaff; border-bottom: 1px solid var(--sd-border); padding: .8rem 1rem; white-space: nowrap; }
.table > tbody td { padding: .85rem 1rem; border-color: var(--sd-border); vertical-align: middle; }
.table-clickable tbody tr { cursor: pointer; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--sd-purple-800); }
th.sortable .bi { opacity: .35; }
th.sorted .bi { opacity: 1; color: var(--sd-purple-800); }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { border: 1px solid var(--sd-border); background: #fff; border-radius: 999px; padding: .32rem .8rem; font-size: .83rem; font-weight: 500; color: var(--sd-muted); cursor: pointer; transition: all .15s; }
.chip:hover { border-color: var(--sd-purple-200); color: var(--sd-purple-800); }
.chip.active { background: var(--sd-purple-800); border-color: var(--sd-purple-800); color: #fff; }

/* ---------- Kanban board ---------- */
.board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; }
.board-col { flex: 0 0 270px; background: #f1eff8; border-radius: var(--sd-radius); padding: .75rem; display: flex; flex-direction: column; max-height: 72vh; }
.board-col-head { display: flex; justify-content: space-between; align-items: center; padding: .2rem .3rem .7rem; font-weight: 600; font-size: .9rem; }
.board-list { flex: 1; overflow-y: auto; min-height: 80px; border-radius: 10px; transition: background .15s; padding: 2px; }
.board-list.drag-over { background: var(--sd-purple-100); outline: 2px dashed var(--sd-purple-500); }
.board-card { background: #fff; border-radius: 10px; padding: .75rem; margin-bottom: .6rem; box-shadow: 0 1px 3px rgba(46, 16, 101, .08); cursor: grab; border: 1px solid transparent; transition: all .15s; }
.board-card:hover { border-color: var(--sd-purple-200); }
.board-card.dragging { opacity: .5; transform: rotate(2deg); }

/* ---------- Status stepper ---------- */
.stepper { display: flex; gap: .3rem; overflow-x: auto; padding: .25rem 0; }
.step { flex: 1; min-width: 96px; text-align: center; position: relative; padding: .55rem .4rem; border-radius: 10px; font-size: .8rem; font-weight: 600; color: var(--sd-muted); background: #f3f1f9; border: 1px solid transparent; transition: all .15s; }
.step.clickable { cursor: pointer; }
.step.clickable:hover { border-color: var(--sd-purple-200); color: var(--sd-purple-800); }
.step.done { background: var(--sd-purple-100); color: var(--sd-purple-800); }
.step.current { background: var(--sd-purple-800); color: #fff; box-shadow: 0 4px 12px rgba(76, 29, 149, .3); }
.step .bi { display: block; font-size: 1rem; margin-bottom: 2px; }

/* ---------- Quote builder ---------- */
.quote-result { background: var(--sd-purple-900); color: #fff; border-radius: var(--sd-radius); padding: 1.4rem; position: relative; transition: opacity .2s; }
.quote-result.loading { opacity: .65; }
.quote-result .big { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; }
.quote-result .line { display: flex; justify-content: space-between; padding: .35rem 0; border-bottom: 1px dashed rgba(255, 255, 255, .15); font-size: .9rem; }
.quote-result .muted { color: rgba(255, 255, 255, .65); }
.quote-result .pill { background: rgba(255, 255, 255, .1); border-radius: 10px; padding: .6rem .7rem; text-align: center; }
.quote-result .pill b { display: block; font-size: clamp(.82rem, 1.25vw, 1.05rem); white-space: nowrap; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--sd-muted); }
.empty-state .bi { font-size: 2.6rem; color: var(--sd-purple-200); display: block; margin-bottom: .6rem; }
.skeleton { background: linear-gradient(90deg, #f0eef6 25%, #e7e3f2 37%, #f0eef6 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; min-height: 14px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.fade-in { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.pipeline-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: #f1eff8; }
.pipeline-bar > div { transition: width .5s ease; }
.toast-container { z-index: 1090; }
.toast { border: 0; border-radius: 12px; box-shadow: var(--sd-shadow-lg); }
.modal-content { border: 0; border-radius: 18px; box-shadow: var(--sd-shadow-lg); }
.modal-header { border-bottom: 1px solid var(--sd-border); padding: 1.1rem 1.4rem; }
.modal-body { padding: 1.4rem; }
.modal-footer { border-top: 1px solid var(--sd-border); padding: .9rem 1.4rem; }
.pagination { --bs-pagination-active-bg: var(--sd-purple-800); --bs-pagination-active-border-color: var(--sd-purple-800); --bs-pagination-color: var(--sd-purple-800); --bs-pagination-border-radius: 8px; --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(124, 58, 237, .2); }
.perm-matrix td, .perm-matrix th { text-align: center; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: left; }

/* ---------- Public site ---------- */
.public-nav { background: rgba(255, 255, 255, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--sd-border); }
.public-nav .brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.2rem; color: var(--sd-purple-900); }
.public-nav .brand-mark { background: var(--sd-purple-800); color: #fff; }
.hero { background: var(--sd-purple-900); color: #fff; padding: 5.5rem 0 6rem; position: relative; overflow: hidden; }
.hero h1 { font-size: clamp(2.1rem, 4.5vw, 3.4rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.08; }
.hero .lead { color: rgba(255, 255, 255, .78); font-size: 1.15rem; }
.hero .eyebrow { display: inline-flex; gap: .4rem; align-items: center; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .15); padding: .35rem .85rem; border-radius: 999px; font-size: .85rem; }
.hero .btn-light { --bs-btn-color: var(--sd-purple-900); font-weight: 600; }
.hero .btn-outline-light { --bs-btn-hover-color: var(--sd-purple-900); }
.hero-mock { background: #fff; color: var(--sd-text); border-radius: 18px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); padding: 1.3rem; transform: rotate(-1.5deg); }
.feature-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--sd-purple-50); color: var(--sd-purple-800); display: flex; align-items: center; justify-content: center; font-size: 1.35rem; margin-bottom: 1rem; }
.section { padding: 5rem 0; }
.section-title { font-weight: 800; letter-spacing: -.02em; font-size: clamp(1.7rem, 3vw, 2.3rem); }
.demo-section { padding-bottom: 3rem; }
.demo-frame { max-width: 960px; border-radius: 18px; overflow: hidden; background: var(--sd-purple-900); box-shadow: 0 30px 70px rgba(46, 16, 101, .25); }
.demo-frame video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; }
.contact-card { color: inherit; text-decoration: none; }
.contact-card:hover { color: inherit; }
.contact-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.price-card.featured { background: var(--sd-purple-900); color: #fff; transform: scale(1.03); }
.price-card.featured .text-muted { color: rgba(255, 255, 255, .7) !important; }
.price-card .price { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; }
.cta-band { background: var(--sd-purple-900); color: #fff; border-radius: 24px; padding: 3rem; }
.public-footer { border-top: 1px solid var(--sd-border); padding: 2rem 0; color: var(--sd-muted); background: #fff; }

/* Auth split screen */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--sd-purple-900); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .brand { color: #fff; display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.25rem; }
.auth-side li { margin-bottom: .9rem; color: rgba(255, 255, 255, .85); }
.auth-side li .bi { color: #c4b5fd; margin-right: .5rem; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.auth-form .inner { width: 100%; max-width: 420px; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* ---------- Read-only mode (trial ended) ---------- */
.read-only [data-requires-write] { opacity: .5; pointer-events: none; }
.usage-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .75rem; border-radius: 999px; background: var(--sd-purple-50); color: var(--sd-purple-800); font-size: .8rem; font-weight: 600; }
.usage-pill.full { background: #fef3c7; color: #b45309; }

/* ---------- Activity timeline ---------- */
.timeline { position: relative; }
.timeline-item { display: flex; gap: .8rem; position: relative; padding-bottom: 1rem; }
.timeline-item:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: 0; width: 2px; background: var(--sd-border); }
.timeline-icon { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .9rem; background: var(--sd-purple-50); color: var(--sd-purple-800); }
.timeline-icon.system { background: #f3f1f9; color: var(--sd-muted); }
.followup-item { display: flex; gap: .7rem; align-items: flex-start; padding: .75rem 1.25rem; border-bottom: 1px solid var(--sd-border); }
.followup-item:last-child { border-bottom: 0; }
.followup-item.overdue .due { color: #b91c1c; font-weight: 600; }
.check-btn { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--sd-purple-200); background: #fff; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; color: transparent; transition: all .15s; padding: 0; }
.check-btn:hover { border-color: var(--sd-purple-800); color: var(--sd-purple-800); }
.check-btn.done { background: var(--sd-purple-800); border-color: var(--sd-purple-800); color: #fff; }

/* ---------- Charts (see wwwroot/js/charts.js) ---------- */
.chart { width: 100%; min-height: 260px; transition: opacity .2s; }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-tick { font-size: 11px; fill: #6b6480; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; gap: 1rem; }
.legend-key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; flex-shrink: 0; }
.chart-tooltip { position: fixed; z-index: 1100; display: none; pointer-events: none; background: #fff; color: var(--sd-text); border: 1px solid var(--sd-border); border-radius: 10px; box-shadow: var(--sd-shadow-lg); padding: .5rem .7rem; font-size: .8rem; min-width: 150px; }
.tabular { font-variant-numeric: tabular-nums; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 90px; align-items: center; gap: .75rem; padding: .3rem 0; }
.bar-label { font-size: .85rem; font-weight: 500; }
.bar-track { height: 18px; background: var(--sd-purple-50); border-radius: 0 4px 4px 0; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; transition: width .5s ease; }
.bar-value { font-size: .85rem; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 575.98px) { .bar-row { grid-template-columns: 90px 1fr 70px; } }
