:root {
  /* Palette taken from www.agemsolar.com (Odoo theme colours) */
  --brand: #1B7A3A;
  --brand-dark: #006241;
  --brand-soft: #e3ebe7;
  --accent: #7BC043;
  --bg: #F2F7EE;
  --surface: #ffffff;
  --text: #0E2F1B;
  --muted: #56685d;
  --line: #dde7e0;
  --danger: #c0392b;
  --panel: #1d3557;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 2px 8px rgba(16, 24, 20, .05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
a { color: var(--brand); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1, h2 { font-family: 'Inter Tight', Inter, system-ui, sans-serif; font-weight: 700; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--brand-dark); font-weight: 700; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 64px; background: var(--surface); border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.logo { height: 40px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: 'Inter Tight', Inter, sans-serif; font-size: 18px; color: var(--brand-dark); letter-spacing: .02em; }
.brand-text span { font-size: 12px; color: var(--muted); font-weight: 500; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  padding: 8px 14px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500;
}
.topbar nav a.active { background: var(--brand-soft); color: var(--brand-dark); }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page { padding: 24px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: #c4cec8; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check input { width: auto; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

/* ---------- projects list ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover { background: #fafcfb; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef1ef; color: var(--muted); }
.pill.lead { background: #eef3ff; color: #2f54b5; }
.pill.designed { background: #fff6e5; color: #9a6400; }
.pill.proposal { background: #f3ecff; color: #6b3fb8; }
.pill.won { background: var(--brand-soft); color: var(--brand-dark); }
.pill.lost { background: #fdecea; color: var(--danger); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* ---------- project workspace ---------- */
.workspace { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ws-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.tabs { display: flex; gap: 2px; background: #eef1ef; padding: 3px; border-radius: 9px; }
.tabs a { padding: 6px 14px; border-radius: 7px; text-decoration: none; color: var(--muted); font-weight: 500; }
.tabs a.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.ws-body { flex: 1; min-height: 0; display: flex; }

.design { display: grid; grid-template-columns: 1fr 360px; flex: 1; min-height: 0; }
#map { height: 100%; min-height: 400px; background: #222; }
.map-wrap { position: relative; min-height: 0; }
.crosshair {
  position: absolute; z-index: 450; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; pointer-events: none;
  background: linear-gradient(#fff, #fff) center/2px 100% no-repeat, linear-gradient(#fff, #fff) center/100% 2px no-repeat;
  filter: drop-shadow(0 0 2px rgba(0,0,0,.8));
}
.map-hint {
  position: absolute; z-index: 500; left: 50%; top: 14px; transform: translateX(-50%);
  background: rgba(23, 33, 27, .9); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 13px;
  display: flex; gap: 10px; align-items: center;
}
.sidebar { background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 18px; }
.sidebar section { display: flex; flex-direction: column; gap: 10px; }
.search-results { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.search-results button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: #fff; padding: 8px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.search-results button:hover { background: var(--brand-soft); }
.roof { border: 1px solid var(--line); border-radius: 9px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.roof.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(123, 192, 67, .25); }
.roof-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.totals { background: var(--brand); color: #fff; border-radius: 10px; padding: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.totals b { display: block; font-size: 20px; }
.totals span { font-size: 11px; opacity: .85; }

.vertex-handle { width: 12px !important; height: 12px !important; margin: -6px 0 0 -6px !important; background: #fff; border: 2px solid var(--accent); border-radius: 50%; }

/* ---------- content tabs ---------- */
.content { flex: 1; overflow-y: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi span { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi b { display: block; font-size: 22px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.hl { background: var(--brand); border-color: var(--brand); color: #fff; }
.kpi.hl span { color: rgba(255, 255, 255, .8); }
.two-col { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); font-family: inherit; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 20, 14, .45); display: grid; place-items: center; z-index: 2000; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 520px; max-width: 100%; padding: 22px; display: flex; flex-direction: column; gap: 14px; max-height: 90vh; overflow-y: auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 3000; font-size: 13px; }

@media (max-width: 900px) {
  .design { grid-template-columns: 1fr; grid-template-rows: 55vh auto; overflow-y: auto; }
  .sidebar { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .two-col { grid-template-columns: 1fr; }
  .page { padding: 16px; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}

/* ---------- login & team ---------- */
.topbar nav { align-items: center; }
.user-chip { font-size: 12px; color: var(--muted); padding: 0 6px 0 12px; border-left: 1px solid var(--line); margin-left: 6px; }
.login-wrap { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.login-box { width: 420px; max-width: 100%; text-align: center; }
.login-box .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); }
#gbtn { display: flex; justify-content: center; min-height: 44px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 56px; padding: 8px 12px; flex-wrap: wrap; gap: 6px; }
  .topbar nav { flex-wrap: wrap; }
  .topbar nav a { padding: 6px 10px; }
  .user-chip { display: none; }
  .brand-text span { display: none; }
  .logo { height: 32px; }
}
