/* =========================================================================
   POWERMIETER — Design System Tokens
   Premium energy / property-tech onboarding. Navy + Cyan. Light & Dark.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700;800&family=Schibsted+Grotesk:wght@500;600;700;800&family=Geist+Mono:wght@400;500&display=swap');

:root {
  /* Brand fonts (overridable via Tweaks) */
  --font-sans: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --font-display: 'Schibsted Grotesk', var(--font-sans);
  --font-mono: 'Geist Mono', ui-monospace, monospace;

  /* Accent scale — cyan = energy / progress / savings */
  --accent-50:  #ECFEFF;
  --accent-100: #CFFAFE;
  --accent-200: #A5EEFB;
  --accent-300: #67E0F2;
  --accent-400: #22D3EE;
  --accent-500: #0FB8D6;
  --accent-600: #0E97B4;
  --accent-700: #0F7689;

  /* Positive / savings — calm emerald */
  --positive-50:  #ECFDF5;
  --positive-100: #D1FAE9;
  --positive-400: #34D39A;
  --positive-500: #14B981;
  --positive-600: #0E9C6C;

  /* Warning / info */
  --warn-50:  #FFF8EB;
  --warn-200: #FCE3AE;
  --warn-500: #E6A23C;
  --warn-700: #9A6516;

  /* Navy / charcoal core */
  --navy-900: #0A1220;
  --navy-800: #0F1A2E;
  --navy-700: #16243C;
  --navy-600: #1E3149;

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  --shadow-color: 218 35% 18%;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* ---------------- LIGHT THEME (default) ---------------- */
[data-theme='light'], :root {
  --bg: #EBEFF4;
  --bg-grad-a: #EEF2F7;
  --bg-grad-b: #E4E9F0;
  --surface: #FFFFFF;
  --surface-2: #F5F8FB;
  --surface-3: #EDF2F7;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F1A2E;
  --text-2: #4A5A70;
  --text-3: #8493A8;
  --text-on-navy: #EAF1F8;

  --accent: var(--accent-600);
  --accent-ink: #FFFFFF;
  --accent-tint: var(--accent-50);
  --accent-tint-border: var(--accent-200);
  --accent-line: var(--accent-400);

  --positive: var(--positive-600);
  --positive-tint: var(--positive-50);

  --btn-primary-bg: var(--navy-800);
  --btn-primary-bg-hover: #1B2C45;
  --btn-primary-ink: #FFFFFF;

  --ring: var(--accent-400);

  --shadow-sm: 0 1px 2px hsl(var(--shadow-color) / .06), 0 1px 3px hsl(var(--shadow-color) / .05);
  --shadow-md: 0 6px 16px -6px hsl(var(--shadow-color) / .12), 0 2px 6px -2px hsl(var(--shadow-color) / .08);
  --shadow-lg: 0 24px 48px -16px hsl(var(--shadow-color) / .22), 0 8px 20px -8px hsl(var(--shadow-color) / .12);
  --shadow-pop: 0 18px 40px -12px hsl(var(--shadow-color) / .28);
}

/* ---------------- DARK THEME ---------------- */
[data-theme='dark'] {
  --bg: #070D17;
  --bg-grad-a: #0A1322;
  --bg-grad-b: #060B14;
  --surface: #0F1A2C;
  --surface-2: #13213A;
  --surface-3: #1A2B46;
  --border: #21354F;
  --border-strong: #2E456180;
  --text: #EAF1F8;
  --text-2: #A6B8D0;
  --text-3: #6B819E;
  --text-on-navy: #EAF1F8;

  --accent: var(--accent-400);
  --accent-ink: #042027;
  --accent-tint: #0C2A36;
  --accent-tint-border: #155A6B;
  --accent-line: var(--accent-400);

  --positive: var(--positive-400);
  --positive-tint: #0C2A24;

  --btn-primary-bg: var(--accent-400);
  --btn-primary-bg-hover: var(--accent-300);
  --btn-primary-ink: #04222A;

  --ring: var(--accent-400);

  --shadow-sm: 0 1px 2px #00000040;
  --shadow-md: 0 8px 22px -8px #00000066, 0 2px 6px -2px #00000055;
  --shadow-lg: 0 28px 56px -18px #000000aa, 0 10px 24px -10px #00000077;
  --shadow-pop: 0 22px 48px -14px #000000bb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* App canvas */
.pm-canvas {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% -10%, color-mix(in oklab, var(--accent) 8%, transparent), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-a), var(--bg-grad-b));
  transition: background .4s var(--ease);
}

::selection { background: color-mix(in oklab, var(--accent) 30%, transparent); }

/* Typography helpers */
.display { font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; line-height: 1.04; }
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); font-family: var(--font-sans);
}
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

/* ---------------- Buttons ---------------- */
.btn {
  --pad-y: 13px; --pad-x: 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--font-sans); font-weight: 600; font-size: 15px; line-height: 1;
  padding: var(--pad-y) var(--pad-x);
  border-radius: var(--radius-pill);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: transform .15s var(--ease), background .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
  user-select: none;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn svg { width: 18px; height: 18px; }

.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-ink); box-shadow: var(--shadow-md); }
.btn-primary:hover { background: var(--btn-primary-bg-hover); box-shadow: var(--shadow-lg); }

.btn-accent { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px -8px color-mix(in oklab, var(--accent) 60%, transparent); }
.btn-accent:hover { filter: brightness(1.05); }

.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text-3); }

.btn-quiet { background: transparent; color: var(--text-2); padding-left: 12px; padding-right: 12px; }
.btn-quiet:hover { color: var(--text); background: var(--surface-2); }

.btn-lg { --pad-y: 16px; --pad-x: 26px; font-size: 16px; }
.btn-sm { --pad-y: 9px; --pad-x: 14px; font-size: 13.5px; }
.btn-block { display: flex; width: 100%; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.card-flat { box-shadow: var(--shadow-sm); }
.card-pad { padding: 24px; }

/* Chips / pills */
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; line-height: 1;
  padding: 7px 12px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.chip-accent { background: var(--accent-tint); color: var(--accent); border-color: var(--accent-tint-border); }
.chip-positive { background: var(--positive-tint); color: var(--positive); border-color: color-mix(in oklab, var(--positive) 30%, transparent); }
.chip svg { width: 14px; height: 14px; }

/* Divider */
.hr { height: 1px; background: var(--border); border: 0; margin: 0; }

/* ---------------- Form fields ---------------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.field-req { color: var(--accent); font-weight: 700; }
.field-opt { font-size: 12px; font-weight: 500; color: var(--text-3); }
.field-hint { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.field-err { font-size: 12.5px; color: #E0556B; font-weight: 600; display: flex; align-items: center; gap: 5px; }

.input, .select, .textarea {
  width: 100%; font-family: var(--font-sans); font-size: 15px; color: var(--text);
  background: var(--surface-2); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--ring); background: var(--surface);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--ring) 18%, transparent);
}
.input-err, .input-err:hover { border-color: #E0556B; }
.input-err:focus { box-shadow: 0 0 0 4px #e0556b2e; border-color: #E0556B; }
.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.select { appearance: none; background-image: none; cursor: pointer; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 42px; }
.input-affix { position: absolute; right: 14px; color: var(--text-3); font-size: 13px; font-weight: 600; pointer-events: none; }
.select-wrap { position: relative; }
.select-wrap .select-caret { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }

/* Checkbox / radio */
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check-box {
  flex: none; width: 22px; height: 22px; border-radius: 7px; margin-top: 1px;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; transition: all .15s var(--ease);
}
.check-box svg { width: 14px; height: 14px; color: #fff; opacity: 0; transform: scale(.6); transition: all .15s var(--ease); }
.check[data-checked='true'] .check-box { background: var(--accent); border-color: var(--accent); }
.check[data-checked='true'] .check-box svg { opacity: 1; transform: scale(1); }
.check-text { font-size: 14px; line-height: 1.5; color: var(--text-2); }
.check-text strong { color: var(--text); font-weight: 600; }

/* Segmented control */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 4px; gap: 2px; }
.seg-btn {
  border: 0; background: transparent; color: var(--text-2); font-family: var(--font-sans);
  font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: var(--radius-pill);
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px; transition: all .18s var(--ease);
}
.seg-btn svg { width: 16px; height: 16px; }
.seg-btn[data-on='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Tooltip */
.tip { position: relative; display: inline-flex; }
.tip-trigger { cursor: help; color: var(--text-3); display: inline-flex; }
.tip-bubble {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 240px; background: var(--navy-800); color: #EAF1F8;
  font-size: 12.5px; line-height: 1.5; font-weight: 500; padding: 10px 12px; border-radius: 10px;
  box-shadow: var(--shadow-pop); z-index: 40; pointer-events: none;
  opacity: 0; transform: translateX(-50%) translateY(4px); transition: all .16s var(--ease);
}
[data-theme='dark'] .tip-bubble { background: #1E3149; border: 1px solid var(--border); }
.tip:hover .tip-bubble { opacity: 1; transform: translateX(-50%) translateY(0); }
.tip-bubble::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--navy-800); }
[data-theme='dark'] .tip-bubble::after { border-top-color: #1E3149; }

/* Info / alert banners */
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.5; }
.alert svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.alert-info { background: var(--accent-tint); border: 1px solid var(--accent-tint-border); color: var(--text-2); }
.alert-info svg { color: var(--accent); }
.alert-positive { background: var(--positive-tint); border: 1px solid color-mix(in oklab, var(--positive) 25%, transparent); color: var(--text-2); }
.alert-positive svg { color: var(--positive); }
.alert-warn { background: var(--warn-50); border: 1px solid var(--warn-200); color: var(--warn-700); }
.alert-warn svg { color: var(--warn-500); }
[data-theme='dark'] .alert-warn { background: #2A2113; border-color: #5A4520; color: #F3D9A6; }
.alert strong { color: var(--text); font-weight: 600; }
[data-theme='dark'] .alert-warn strong { color: #F8E9C9; }

/* Accordion */
.acc-item { border-bottom: 1px solid var(--border); }
.acc-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: none; border: 0; cursor: pointer; padding: 18px 2px; text-align: left;
  font-family: var(--font-sans); font-size: 15px; font-weight: 600; color: var(--text);
}
.acc-icon { flex: none; color: var(--text-3); transition: transform .25s var(--ease); }
.acc-head[data-open='true'] .acc-icon { transform: rotate(180deg); color: var(--accent); }
.acc-panel { overflow: hidden; transition: height .28s var(--ease); }
.acc-body { padding: 0 2px 18px; font-size: 14px; line-height: 1.6; color: var(--text-2); }

/* Scrollbar (mobile frame) */
.thin-scroll::-webkit-scrollbar { width: 7px; height: 7px; }
.thin-scroll::-webkit-scrollbar-thumb { background: color-mix(in oklab, var(--text-3) 45%, transparent); border-radius: 99px; }
.thin-scroll::-webkit-scrollbar-track { background: transparent; }

/* Fade / slide-in — note: no opacity:0 start, so DOM-clone screenshots stay visible */
@keyframes pm-rise { from { transform: translateY(10px); } to { transform: none; } }
.rise { animation: pm-rise .5s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
