/* Energy Exchange Market app. Mobile first; works on iPhone (Safari) and Android (Chrome). */
:root {
  --blue: #2563EB; --blue-dark: #1D4ED8; --ink: #0F172A; --ink2: #334155; --muted: #64748B;
  --bg: #F5F8FF; --card: #fff; --line: #D9E2F2; --green: #047857; --red: #B91C1C;
  --bar-h: 64px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--blue-dark); }
h1, h2 { font-family: 'Syne', 'Inter', sans-serif; margin: 0; line-height: 1.15; }
h1 { font-size: 1.6rem; margin-bottom: .4rem; }
.sub { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
.lede { color: var(--ink2); margin: 0 0 1rem; }
.muted { color: var(--muted); font-size: .92rem; }
.fine { color: var(--muted); font-size: .8rem; line-height: 1.45; margin: .75rem 0 0; }

.app-header {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-family: 'Syne', 'Inter', sans-serif; font-weight: 800; font-size: 1rem; line-height: 1.05; }
.brand-name em { font-style: normal; color: var(--blue); }
.call-pill {
  background: var(--blue); color: #fff; text-decoration: none; font-weight: 700; font-size: .95rem;
  padding: 10px 18px; border-radius: 999px; min-height: 44px; display: inline-flex; align-items: center;
}

.app-main { max-width: 640px; margin: 0 auto; padding: 18px 16px 8px; }
.screen[hidden] { display: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 0 0 12px; }
.card p { margin: .4rem 0 .9rem; color: var(--ink2); }
.card-link { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink); }
.card-link strong { font-size: 1.02rem; }
.tag { align-self: flex-start; background: #E0EAFF; color: var(--blue-dark); font-size: .72rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.tool-list { list-style: none; padding: 0; margin: 0; }
.success { border-color: #A7F3D0; background: #ECFDF5; }
.success strong { color: var(--green); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 20px;
  border-radius: 12px; border: 2px solid transparent; font: 700 1rem 'Inter', system-ui, sans-serif; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:active { background: var(--blue-dark); }
.btn-ghost { background: #fff; color: var(--blue-dark); border-color: var(--blue); margin-top: 8px; }
.btn-full { width: 100%; }
.btn-sm { min-height: 44px; padding: 8px 16px; }
.btn[disabled] { opacity: .6; }

.seg { display: flex; gap: 6px; background: #E6ECF8; padding: 4px; border-radius: 14px; margin-bottom: 14px; }
.seg-btn { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; font: 600 .9rem 'Inter', system-ui, sans-serif; color: var(--ink2); cursor: pointer; }
.seg-btn.is-on { background: #fff; color: var(--blue-dark); box-shadow: 0 1px 3px rgba(15, 23, 42, .15); }

.field-label { display: block; font-weight: 600; font-size: .92rem; margin: 12px 0 4px; }
.field-label:first-child { margin-top: 0; }
.req { color: var(--red); font-weight: 600; font-size: .75rem; }
.opt { color: var(--muted); font-weight: 500; font-size: .75rem; }
/* 16px minimum stops iOS Safari from zooming into fields */
.field {
  width: 100%; min-height: 48px; padding: 10px 12px; font: 400 16px 'Inter', system-ui, sans-serif; color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: 12px; appearance: none; -webkit-appearance: none;
}
select.field { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%2364748B' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
textarea.field { resize: vertical; }
.field:focus-visible, .btn:focus-visible, a:focus-visible, .seg-btn:focus-visible { outline: 3px solid #93C5FD; outline-offset: 2px; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form .btn { margin-top: 16px; }
.form-msg { color: var(--red); font-weight: 600; font-size: .9rem; }

.consent { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 16px 0 0; }
.consent legend { font-weight: 700; font-size: .85rem; padding: 0 6px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .78rem; color: var(--ink2); margin: 8px 0; }
.check input { flex: none; width: 24px; height: 24px; margin-top: 2px; accent-color: var(--blue); }

.rate-list { display: grid; gap: 12px; margin-top: 14px; }
.rate { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.rate h3 { margin: 0; font-size: 1.05rem; }
.rate .grid { color: var(--muted); font-size: .8rem; }
.rate .price { font: 800 2rem 'Syne', 'Inter', sans-serif; color: var(--blue-dark); margin: 6px 0 0; line-height: 1; }
.rate .price small { font: 600 .9rem 'Inter', sans-serif; color: var(--ink2); }
.rate .label { color: var(--ink2); font-size: .9rem; margin: 4px 0; }
.rate .next { color: var(--muted); font-size: .85rem; }
.rate .acts { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; font-weight: 600; font-size: .92rem; }
.empty { color: var(--muted); padding: 12px 0; }

.install-card { display: flex; align-items: center; gap: 10px; margin: 12px 16px 0; padding: 12px 14px; background: #E0EAFF; border: 1px solid #BFD1FF; border-radius: 14px; max-width: 608px; }
@media (min-width: 640px) { .install-card { margin-left: auto; margin-right: auto; } }
.install-card[hidden] { display: none; }
.install-text { flex: 1; display: flex; flex-direction: column; font-size: .9rem; line-height: 1.35; }
.install-text strong { font-size: .95rem; }
.install-close { flex: none; width: 44px; height: 44px; border: 0; background: transparent; font-size: 1.6rem; color: var(--ink2); cursor: pointer; }

.app-foot { color: var(--muted); font-size: .8rem; text-align: center; padding: 22px 0 10px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; min-height: var(--bar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: .68rem; font-weight: 600;
}
.tabbar svg { width: 24px; height: 24px; fill: currentColor; }
.tabbar a[aria-current="page"] { color: var(--blue-dark); }
.tabbar a[data-call] { color: var(--green); }

@media (min-width: 700px) {
  .tabbar { max-width: 640px; left: 50%; right: auto; width: 100%; transform: translateX(-50%); border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 16px 16px 0 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

[hidden] { display: none !important; }

/* Ask: AI assistant */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.notice { background: #FFF7E0; border: 1px solid #F4D77A; border-radius: 12px; padding: 10px 12px; font-size: .85rem; color: #5B4300; margin: 0 0 14px; }
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .98rem; line-height: 1.45; }
.msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.typing { color: var(--muted); font-style: italic; }
.msg.err { background: #FEF2F2; border-color: #FECACA; color: #7F1D1D; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { min-height: 44px; padding: 8px 14px; border: 1px solid var(--blue); background: #fff; color: var(--blue-dark); border-radius: 999px; font: 600 .88rem 'Inter', system-ui, sans-serif; cursor: pointer; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-form .field { flex: 1; resize: none; min-height: 48px; max-height: 120px; }
.chat-form .btn { flex: none; margin: 0; }
.chat-handoff { display: flex; gap: 8px; margin-top: 12px; }
.chat-handoff .btn { flex: 1; margin: 0; min-height: 44px; font-size: .92rem; }

/* Desktop only: a QR code to open the app on a phone (hidden on touch devices and once installed) */
.desk-qr { display: none; }
@media (min-width: 700px) and (hover: hover) and (pointer: fine) {
  .desk-qr { display: flex; align-items: center; gap: 16px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin: 0 0 16px; }
  .desk-qr img { flex: none; width: 104px; height: 104px; }
  .desk-qr strong { display: block; font-size: 1.02rem; }
  .desk-qr span { color: var(--ink2); font-size: .9rem; }
}
@media (display-mode: standalone) { .desk-qr { display: none !important; } }
