/* ============================================================
   Electric Load Control — Consolidated Cooperative
   Mobile-first; rescales to a two-column layout on wide screens.
   ============================================================ */

:root {
  --navy:        #16305a;
  --navy-dark:   #0f2444;
  /* Consolidated Cooperative brand palette (Brand Identity Standards) */
  --brand:       #ff6900;   /* Energy Orange (core)        */
  --brand-light: #f8a31c;   /* Gradient Orange (light end) */
  --shadow-gray: #51534a;   /* Shadow Gray (grounded ink)  */
  --teal:        #1abdc1;   /* Connect Teal (accent)       */
  --teal-bg:     #e7f7f7;
  --ink:         #1f2733;
  --muted:       #6b7683;
  --line:        #e6e9ef;
  --bg:          #f4f6f9;
  --card:        #ffffff;

  --inprogress:  #e8503a;   /* red   */
  --inprogress-bg:#fdece9;
  --warning:     #f0a020;   /* orange*/
  --warning-bg:  #fef4e2;
  --warning-yellow: #cf9200; /* legible golden-yellow for the Warning title on the light card */
  --normal:      #7cbf5a;   /* green */
  --info:        #ff6900;   /* interactive accent = Energy Orange */
  --info-bg:     #fff1e6;   /* soft orange tint (hover states)    */

  --radius:      14px;
  --radius-sm:   10px;
  --shadow:      0 1px 3px rgba(20,40,80,.08), 0 1px 2px rgba(20,40,80,.06);
  --tabbar-h:    62px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- App shell: fixed-height column with brandbar / scroll content / tabbar ---- */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;             /* phone-width column, centered on desktop */
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 40px rgba(20,40,80,.06);
  position: relative;
}

/* ===================== BRAND BAR ===================== */
.brandbar {
  flex: 0 0 auto;
  background: #fff;                    /* white, matching the logo's background */
  /* 3px brand gradient-orange accent along the bottom */
  border-style: solid; border-width: 0 0 3px;
  border-image: linear-gradient(105deg, var(--brand-light), var(--brand)) 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(env(safe-area-inset-top), 10px) 14px 10px;
}
.brandbar__logo {
  display: inline-flex; align-items: center;
  text-decoration: none; cursor: pointer;
}
.brandbar__logo-img { display: block; height: 30px; width: auto; }
.brandbar__version { align-self: center; font-size: 9.5px; color: #dde0e4; letter-spacing: .3px; white-space: nowrap; }

/* ===================== CONTENT (scroll region) ===================== */
.content {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px);
  /* Column so the active tab can stretch to fill the viewport height. */
  display: flex;
  flex-direction: column;
}
.tabview { padding: 16px 16px 8px; }
/* The visible tab fills any leftover vertical space (never shrinks below content). */
.tabview:not([hidden]) { flex: 1 0 auto; }
/* Map tab is itself a column so the map can absorb the slack below the cards. */
#tab-map:not([hidden]) { display: flex; flex-direction: column; }

/* ---- Title block ---- */
.titleblock__row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.titleblock__title { margin: 2px 0 0; font-size: 26px; font-weight: 800; letter-spacing: -.3px; }
.titleblock__subtitle { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.updated {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px;
  color: var(--muted); font-size: 12px; white-space: nowrap; padding-top: 6px;
}

/* ---- Search ---- */
.search {
  position: relative;
  margin-top: 10px; display: flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0 6px 0 10px; box-shadow: var(--shadow);
}
.search__suggestions {
  position: absolute; top: calc(100% + 5px); left: 0; right: 0; z-index: 30;
  margin: 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(20,40,80,.16);
  max-height: 264px; overflow-y: auto;
}
.search__suggestion {
  padding: 9px 10px; font-size: 13.5px; line-height: 1.3; color: var(--ink);
  border-radius: 8px; cursor: pointer;
}
.search__suggestion:hover, .search__suggestion.is-active { background: var(--info-bg); }
.search__icon { color: var(--muted); display: grid; place-items: center; }
.search__input {
  flex: 1 1 auto; border: 0; outline: none; background: none;
  padding: 6px 4px; font-size: 14px; color: var(--ink);
}
.search__input::placeholder { color: #9aa4b0; }
.search__clear {
  flex: 0 0 auto; border: 0; background: none; color: var(--muted);
  cursor: pointer; padding: 5px; border-radius: 8px; display: grid; place-items: center;
}
.search__clear:hover { background: #eef1f5; color: var(--ink); }
.search__locate {
  flex: 0 0 auto; border: 0; background: none; color: var(--info);
  cursor: pointer; padding: 5px; border-radius: 8px; display: grid; place-items: center;
}
.search__locate:hover { background: var(--info-bg); }
.search__examples { margin: 6px 2px 0; color: var(--muted); font-size: 11px; }
.search__status { margin: 6px 2px 0; font-size: 12.5px; }
.search__status:empty { display: none; margin: 0; } /* reserve no space when idle */
.search__status.is-error { color: var(--inprogress); }
.search__status.is-ok    { color: var(--info); }

/* ---- Service territory heading ---- */
.territory { margin-top: 18px; display: flex; align-items: flex-start; gap: 8px; }
.territory__pin { color: var(--info); margin-top: 1px; }
.territory__title { margin: 0; font-size: 16px; font-weight: 700; }
.territory__hint { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* ===================== MAP ===================== */
.mapwrap {
  position: relative; margin-top: 12px;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--line);
  background: #dfe6ea;
  flex: 1 1 auto;                  /* grow to fill leftover height */
  min-height: 300px;              /* but never collapse on short screens */
}
#viewDiv { position: absolute; inset: 0; }

/* Esri default widgets nudged to match mockup placement */
.mapwrap .esri-ui-top-right { top: 10px; right: 10px; }
.mapwrap .esri-ui-corner .esri-component { box-shadow: var(--shadow); }
/* Home + zoom sit in a horizontal row at the lower-left */
.mapwrap .esri-ui-bottom-left { flex-flow: row nowrap; align-items: flex-end; gap: 8px; }

.mapbtn {
  position: absolute; z-index: 5; border: 0; cursor: pointer;
  background: #fff; color: var(--shadow-gray); box-shadow: var(--shadow);
  border-radius: 16px; font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px;
}
.mapbtn svg { width: 12px; height: 12px; }
.mapbtn:hover { background: #f2f5fa; }
.mapbtn--mylocation { top: 10px; left: 10px; }

.maplegend {
  position: absolute; z-index: 5; right: 10px; bottom: 10px;
  background: rgba(255,255,255,.95); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 6px 8px; font-size: 10.5px; color: var(--ink);
}
.maplegend__row { display: flex; align-items: center; gap: 6px; line-height: 1.6; }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; }
.swatch--inprogress { background: var(--inprogress); }
.swatch--warning    { background: var(--warning); }
.swatch--normal     { background: var(--normal); }

/* ===================== STATUS CARDS ===================== */
.card {
  width: 100%; text-align: left; cursor: default;
  margin-top: 9px; display: flex; align-items: center; gap: 9px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 11px;
  font: inherit; color: inherit;
}
button.card { cursor: pointer; }
button.card:hover { background: #fbfcfe; }
.card__icon { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.card__icon svg { width: 14px; height: 14px; }
.card__body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 1px; }
.card__title { font-weight: 700; font-size: 12.5px; }
.card__text { color: var(--muted); font-size: 11px; line-height: 1.3; }
.card__text--strong { color: var(--ink); font-weight: 600; font-size: 11.5px; }
.card__chev { flex: 0 0 auto; color: #b6bfca; font-size: 18px; line-height: 1; }

.card--inprogress { background: var(--inprogress-bg); }
.card--inprogress .card__icon { background: var(--inprogress); }
.card--inprogress .card__title { color: var(--inprogress); }   /* title red; description stays muted */
.card--warning    { background: var(--warning-bg); }
.card--warning .card__icon { background: var(--warning); }
.card--warning .card__title { color: var(--warning-yellow); }  /* title yellow; description stays muted */
.card--info       { background: #eef6df; }               /* light Grass Green tint */
.card--info .card__icon { background: #86c232; }         /* Grass Green (brand accent) */

/* ===================== SIMPLE (placeholder) TABS ===================== */
.tabview--simple { min-height: 60vh; }
.simplehead h1 { margin: 4px 0 2px; font-size: 24px; font-weight: 800; }
.simplehead p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.placeholder__item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.placeholder__item h3 { margin: 0 0 4px; font-size: 15px; }
.placeholder__item p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.4; }
.placeholder__note {
  text-align: center; color: #9aa4b0; font-size: 12px; font-style: italic; margin-top: 8px;
}

/* Usage Tips — green savings scale (darker = saves more) */
.tips { display: flex; flex-direction: column; gap: 12px; }
.tip {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
}
.tip__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tip h3 { margin: 0 0 4px; font-size: 15px; }
.tip p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.4; }
/* Savings level shown as 1-3 custom leaf icons instead of dollar signs. */
.tip__save { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 2px; }
.tip__save .leaf { width: 18px; height: 18px; color: #5aa632; }
.tip--high { border-left-color: #2e7d32; }
.tip--med  { border-left-color: #66bb6a; }
.tip--low  { border-left-color: #b7dcb3; }

/* ===================== BOTTOM TAB BAR ===================== */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
  display: flex; align-items: stretch;
}
.tabbar__btn {
  flex: 1 1 0; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 600; padding: 6px 2px;
}
.tabbar__btn svg { opacity: .85; }
.tabbar__btn.is-active { color: var(--info); }
.tabbar__btn.is-active svg { opacity: 1; }

/* ===================== UPDATES TAB ===================== */
.statrow { display: flex; gap: 12px; margin-bottom: 14px; }
.stat {
  flex: 1 1 0; background: var(--card); border: 1px solid var(--line);
  border-left-width: 4px; border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.stat__num { font-size: 30px; font-weight: 800; line-height: 1.05; color: var(--ink); }
.stat__label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat--inprogress { border-left-color: var(--inprogress); }
.stat--inprogress .stat__num { color: var(--inprogress); }
.stat--warning { border-left-color: var(--warning); }
.stat--warning .stat__num { color: var(--warning-yellow); }

.updcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.updcard + .updcard { margin-top: 14px; }
.updcard__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.updcard__title { margin: 0; font-size: 14px; font-weight: 700; }
.updfoot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.updfoot .updnote { margin: 0; }
.updlegend { font-size: 9.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.updlegend__dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.updlegend__dot--ip { background: var(--inprogress); }
.updlegend__dot--wn { background: var(--warning); margin-left: 8px; }
.updlegend__dot--nm { background: var(--normal); margin-left: 8px; }
.updchart svg { display: block; width: 100%; height: auto; }
.updchart-bar--ip { fill: var(--inprogress); }
.updchart-bar--wn { fill: var(--warning); }
.updchart-axis { fill: var(--muted); font-size: 9px; font-family: inherit; }
.updchart-grid { stroke: var(--line); stroke-width: 1; }
.updnote { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }
.updnote:empty { display: none; }

.zonelist { list-style: none; margin: 0; padding: 0; }
.zonelist li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.zonelist li:last-child { border-bottom: 0; }
.zone__swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.zone__name { font-weight: 700; }
.zone__meta { margin-left: auto; color: var(--muted); font-size: 11.5px; text-align: right; white-space: nowrap; }
.zonelist__empty { color: var(--muted); font-size: 12.5px; }

/* ===================== HEAT-MAP MODAL ===================== */
.hm-modal { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.hm-modal__backdrop { position: absolute; inset: 0; background: rgba(15, 25, 45, .45); }
.hm-modal__panel {
  position: relative; z-index: 1; background: #fff; border-radius: 14px;
  box-shadow: 0 20px 60px rgba(10, 20, 40, .35);
  width: 100%; max-width: 760px; max-height: 90%; display: flex; flex-direction: column; overflow: hidden;
}
.hm-modal__head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.hm-modal__title { margin: 0; font-size: 16px; font-weight: 800; }
.hm-modal__close { border: 0; background: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 6px; border-radius: 8px; }
.hm-modal__close:hover { background: #eef1f5; color: var(--ink); }

.hm-modal__seg { display: flex; gap: 6px; padding: 12px 16px 0; }
.hm-modal__seg button {
  flex: 1; padding: 8px 6px; font: inherit; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 9px; cursor: pointer;
}
.hm-modal__seg button.is-active { color: #fff; border-color: transparent; }
.hm-modal__seg button[data-mode="InProgress"].is-active { background: var(--inprogress); }
.hm-modal__seg button[data-mode="Warn"].is-active { background: var(--warning); }
.hm-modal__seg button[data-mode="Both"].is-active { background: #e07b1a; }

.hm-modal__body { padding: 14px 16px 16px; overflow: auto; }
.hm-note { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.hm-note:empty { display: none; }
.hm-scroll { overflow-x: auto; padding-bottom: 4px; }
.hm-scroll svg { display: block; }
.hm-cell { stroke: rgba(27, 31, 36, .06); stroke-width: 1; }
.hm-month, .hm-wd { fill: var(--muted); font-size: 9px; font-family: inherit; }
.hm-year { fill: var(--ink); font-size: 9px; font-weight: 700; font-family: inherit; }

.hm-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 11.5px; color: var(--muted); gap: 10px; flex-wrap: wrap; }
.hm-legend { display: inline-flex; align-items: center; gap: 5px; }
.hm-legend__cells { display: inline-flex; gap: 3px; }
.hm-legend__cells i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }

/* ===================== DESKTOP / LARGE SCREENS ===================== */
/* The map node (#mapWrap) is relocated into #rightPane by app.js at >=900px
   and moved back into the Map tab below that width. CSS here styles both states. */
.rightpane { display: none; }

@media (min-width: 900px) {
  #app {
    max-width: 1180px;
    height: 100dvh;
    display: grid;
    grid-template-columns: 400px 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "brand   brand"
      "content right"
      "tabbar  right";
    box-shadow: none;
  }
  .brandbar   { grid-area: brand; padding: 14px 28px; }
  .brandbar__name { font-size: 17px; }

  /* Left column scrolls; holds all tab text/cards */
  .content {
    grid-area: content;
    border-right: 1px solid var(--line);
    background: var(--bg);
    padding-bottom: 24px;
  }
  .tabview { padding: 22px 24px; }
  .titleblock__title { font-size: 30px; }

  /* Right pane holds the full-height map */
  .rightpane { grid-area: right; display: block; position: relative; }
  #rightPane .mapwrap {
    position: absolute; inset: 0;
    aspect-ratio: auto;
    height: 100%; width: 100%;
    margin: 0; border: 0; border-radius: 0;
  }

  /* Tab bar becomes a normal row at the bottom of the left column */
  .tabbar {
    grid-area: tabbar;
    position: static;
    height: auto;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .content { padding-bottom: 24px; }   /* no floating tabbar to clear */

  /* Non-map tabs read comfortably */
  .tabview--simple { max-width: 760px; }
}

/* Extra-wide: keep the reading column comfortable */
@media (min-width: 1400px) {
  #app { max-width: 1400px; grid-template-columns: 440px 1fr; }
}
