/* قابس - Apple Home look. Loaded after app.css: system font, iOS colours, grouped sheets,
   Home-style tiles (dim when off, solid white when on). Same tokens, so every view follows. */
:root {
  --paper: #f2f2f7;            /* systemGroupedBackground */
  --card: #ffffff;
  --sunk: rgba(118, 118, 128, .12);
  --ink: #000000;
  --ink-2: rgba(60, 60, 67, .72);
  --ink-3: rgba(60, 60, 67, .5);
  --line: rgba(60, 60, 67, .16);
  --live: #ff9500;              /* systemOrange - the Home tint */
  --live-soft: rgba(255, 149, 0, .16);
  --on: #34c759;                /* systemGreen */
  --on-soft: rgba(52, 199, 89, .16);
  --warn: #ff3b30;
  --warn-soft: rgba(255, 59, 48, .14);
  --tile-off: rgba(214, 214, 222, .5);
  --tile-on: #ffffff;
  --wall: radial-gradient(120% 60% at 85% -10%, #ffd8a8 0%, transparent 60%),
          radial-gradient(90% 50% at 0% 10%, #cfe3ff 0%, transparent 55%), #f2f2f7;
  --radius-l: 20px;
  --radius-m: 14px;
  --radius-s: 10px;
  --shadow: none;
  --tabs-h: 56px;
  --ease: cubic-bezier(.32, .72, 0, 1);    /* iOS spring-ish */
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #000000;
    --card: #1c1c1e;
    --sunk: rgba(118, 118, 128, .24);
    --ink: #ffffff;
    --ink-2: rgba(235, 235, 245, .7);
    --ink-3: rgba(235, 235, 245, .45);
    --line: rgba(84, 84, 88, .6);
    --live: #ff9f0a;
    --live-soft: rgba(255, 159, 10, .2);
    --on: #30d158;
    --on-soft: rgba(48, 209, 88, .2);
    --warn: #ff453a;
    --warn-soft: rgba(255, 69, 58, .2);
    --tile-off: rgba(28, 28, 30, .88);
    --tile-on: #f5f5f7;
    --wall: radial-gradient(120% 60% at 85% -10%, #3a2410 0%, transparent 60%),
            radial-gradient(90% 50% at 0% 10%, #0f2340 0%, transparent 55%), #000;
  }
}

body {
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Arabic", "Segoe UI", Roboto, "Noto Sans Arabic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--wall) fixed;
  letter-spacing: -.01em;
}
html { background: var(--paper); }

/* large title, like every iOS app */
.top { padding: 12px 16px 2px; }
.top h1 { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.icon-btn { background: var(--sunk); width: 36px; height: 36px; color: var(--live); }
.icon-btn svg { width: 20px; height: 20px; }

.section-title { margin: 22px 4px 10px; }
.section-title h2 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }

/* capsules */
.chip { border: 0; background: var(--tile-off); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); font-size: 15px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chip.add { border: 0; color: var(--live); }
.pill { border: 0; background: var(--sunk); color: var(--live); font-weight: 600; font-size: 15px; padding: 6px 14px; }
.chips button { border: 0; background: var(--sunk); font-size: 15px; padding: 8px 14px; }
.chips button[aria-pressed="true"] { background: var(--live); color: #fff; }

/* Home tiles: icon in a circle, name, status - dim when off, solid when on */
.tiles, .outlets { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tile, .outlet {
  border: 0; background: var(--tile-off); -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6);
  border-radius: var(--radius-l); min-height: 112px; padding: 12px 14px 12px; gap: 2px;
}
.tile.on, .outlet.on { background: var(--tile-on); color: #000; }
.tile .ico, .outlet .ico {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 22px;
  background: var(--sunk);
}
.tile.on .ico, .outlet.on .ico { background: var(--live-soft); }
.tile .name, .outlet .name { font-size: 15px; font-weight: 600; margin-top: 8px; line-height: 1.2; }
.tile .sub, .outlet .sub, .tile .dev { font-size: 13px; color: var(--ink-2); }
.tile.on .sub, .outlet.on .sub, .tile.on .dev { color: rgba(60, 60, 67, .72); }
.tile .w-now, .outlet .w-now { color: var(--live); }
.tile .badge .switch { display: none; }                 /* Home shows state as text, not a switch */
.tile.sensor { background: var(--tile-off); }
.tile.sensor .val { font-size: 26px; }
.more { color: var(--ink-3); }
.tile.on .more, .outlet.on .more { color: rgba(60, 60, 67, .5); }
.tile.on[data-glow] .ico { background: color-mix(in srgb, var(--glow) 35%, transparent); }

/* the strip meter card follows the grouped-card look */
.meter { border-radius: var(--radius-l); background: var(--card); }
.reading { background: var(--sunk); border-radius: 12px; }
.money div { border: 0; background: var(--sunk); }

/* iOS switch */
.switch { width: 51px; height: 31px; background: rgba(120, 120, 128, .32); }
.switch::after { width: 27px; height: 27px; top: 2px; inset-inline-start: 2px; box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16); }
.on .switch::after, .switch.on::after { transform: translateX(-20px); }

/* inset grouped lists */
.list { border-radius: 12px; }
.row { border-bottom: 0; box-shadow: inset 0 -.5px 0 var(--line); }
.row:last-child { box-shadow: none; }

/* buttons */
.primary { background: var(--live); color: #fff; border-radius: 14px; font-size: 17px; padding: 15px 18px; }
.ghost { border: 0; background: var(--sunk); color: var(--live); border-radius: 14px; font-weight: 600; font-size: 17px; }
.ghost.danger, .danger { color: var(--warn); }

/* segmented control */
.seg { background: var(--sunk); border-radius: 9px; padding: 2px; }
.seg button { border-radius: 7px; font-size: 13px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--card); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); }
.chart { border-radius: var(--radius-l); }

/* tab bar */
.tabs { background: color-mix(in srgb, var(--card) 78%, transparent); -webkit-backdrop-filter: blur(30px) saturate(1.8); backdrop-filter: blur(30px) saturate(1.8);
  border-top: .5px solid var(--line); }
.tabs button { font-size: 10px; font-weight: 500; gap: 2px; }
.tabs svg { width: 24px; height: 24px; }
.tabs button.active, .tabs button.active svg { color: var(--live); font-weight: 600; }

/* sheets: grabber, grouped background, fields as white rows */
.sheet { background: var(--paper); border-radius: 14px 14px 0 0; }
.sheet::backdrop { background: rgba(0, 0, 0, .4); }
.grab { background: rgba(127, 127, 127, .4); width: 36px; }
.sheet h3 { font-size: 20px; font-weight: 700; text-align: center; }
.sheet h4 { margin: 8px 4px 0; font-size: 13px; font-weight: 400; color: var(--ink-3); text-transform: uppercase; }
.field > span { font-size: 13px; color: var(--ink-3); padding-inline-start: 4px; }
.field input, .field select { background: var(--card); border: 0; border-radius: 12px; padding: 13px 14px; font-size: 17px; }
.field input:focus, .field select:focus { box-shadow: 0 0 0 2px var(--live); }
.toggle-row { background: var(--card); border-radius: 12px; padding: 12px 14px; }
.icons button { border: 0; background: var(--card); border-radius: 12px; }
.icons button[aria-pressed="true"] { background: var(--live-soft); box-shadow: inset 0 0 0 2px var(--live); }
.sheet .readings.in-sheet .reading { background: var(--card); }
.sheet .row { background: var(--card); }
.sheet .row:first-of-type { border-radius: 12px 12px 0 0; }

.empty { border: 0; background: var(--tile-off); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); border-radius: var(--radius-l); }
.toast { background: color-mix(in srgb, var(--ink) 88%, transparent); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: 14px; }
:focus-visible { outline-color: var(--live); }
.login h2 { font-size: 34px; font-weight: 700; }

body.kiosk .tile { min-height: 140px; }
body.kiosk .tile .ico { width: 52px; height: 52px; font-size: 28px; }

/* settings: inset grouped list, coloured icon squares, chevrons - like iOS Settings */
.group { display: flex; flex-direction: column; gap: 6px; }
.group-title { font-size: 13px; color: var(--ink-3); padding-inline-start: 16px; }
.group-foot { font-size: 13px; color: var(--ink-3); padding: 0 16px; margin: 0; }
.group-box { background: var(--card); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.group-box.form { padding: 0 14px; }
.nav-row {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; cursor: pointer;
  padding: 10px 14px; min-height: 48px; font: inherit; color: inherit; text-align: start; position: relative;
}
.nav-row + .nav-row::before { content: ""; position: absolute; top: 0; inset-inline-start: 56px; inset-inline-end: 0; border-top: .5px solid var(--line); }
.nav-row:active { background: var(--sunk); }
.nav-row.static { cursor: default; }
.nav-row.static:active { background: transparent; }
.nav-row.danger { justify-content: center; color: var(--warn); }
.nav-row.danger .nav-ico, .nav-row.danger .nav-detail { display: none; }
.nav-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 16px; flex: none; }
.tint-orange { background: #ff9500; } .tint-green { background: #34c759; } .tint-yellow { background: #ffcc00; }
.tint-blue { background: #007aff; } .tint-gray { background: #8e8e93; } .tint-purple { background: #af52de; } .tint-red { background: #ff3b30; }
.nav-label { flex: 1; font-size: 17px; }
.nav-detail { color: var(--ink-3); font-size: 15px; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--ink-3); font-size: 22px; line-height: 1; opacity: .6; }
.profile {
  display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: var(--card); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; font: inherit; color: inherit; text-align: start;
}
.profile > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.profile b { font-size: 19px; }
.profile small { color: var(--ink-3); font-size: 14px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, #a1a1aa, #6e6e76); flex: none; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; min-height: 48px; position: relative; }
.field.inline + .field.inline::before { content: ""; position: absolute; top: 0; inset-inline: 0; border-top: .5px solid var(--line); }
.field.inline > span { flex: 1; font-size: 17px; color: var(--ink); padding: 0; }
.field.inline input, .field.inline select { width: auto; max-width: 52%; text-align: end; background: transparent; padding: 10px 0; color: var(--ink-2); }
.field.inline input:focus, .field.inline select:focus { box-shadow: none; color: var(--ink); }
.field.inline em { font-style: normal; color: var(--ink-3); font-size: 15px; }
.group-box.form .toggle-row { background: transparent; padding: 10px 0; border-radius: 0; }
.sheet-nav { display: flex; margin-bottom: -6px; }
.back { border: 0; background: transparent; color: var(--live); font: inherit; font-size: 17px; cursor: pointer; padding: 4px 0; }
.nav-row.danger .nav-label { text-align: center; }
.sheet h3:focus, .sheet h3:focus-visible { outline: none; }

/* every checkbox is an iOS switch */
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; width: 51px; height: 31px; border-radius: 999px; margin: 0; flex: none;
  background: rgba(120, 120, 128, .32); position: relative; cursor: pointer; transition: background-color .2s var(--ease);
}
input[type="checkbox"]::before {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16); transition: transform .25s var(--ease);
}
input[type="checkbox"]:checked { background: var(--on); }
input[type="checkbox"]:checked::before { transform: translateX(-20px); }
input[type="checkbox"]:disabled { opacity: .5; }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; }

/* scenes & automations */
.scene-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.scene-strip::-webkit-scrollbar { display: none; }
.scene-chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer; font: inherit; font-size: 15px; font-weight: 600;
  padding: 10px 16px; border-radius: 14px; background: var(--tile-off); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); color: var(--ink);
}
.scene-chip:active { transform: scale(.96); background: var(--tile-on); color: #000; }
.scenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.scene-tile {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; min-height: 96px; cursor: pointer;
  border-radius: var(--radius-l); background: var(--tile-off); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
}
.scene-tile:active { transform: scale(.97); background: var(--tile-on); color: #000; }
.scene-tile .ico { font-size: 26px; }
.scene-tile .name { font-weight: 600; font-size: 15px; margin-top: 6px; }
.scene-tile .sub { font-size: 13px; color: var(--ink-3); }
.linkish { border: 0; background: transparent; font: inherit; color: inherit; text-align: start; cursor: pointer; padding: 0; }
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.template {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: start; border: 0; cursor: pointer; font: inherit; color: inherit;
  padding: 14px; border-radius: var(--radius-l); background: var(--card);
}
.template > span { font-size: 24px; }
.template b { font-size: 15px; }
.template small { color: var(--ink-3); font-size: 13px; line-height: 1.3; }
.template:active { transform: scale(.97); }
.act-row, .pick-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; position: relative; }
.act-row + .act-row::before, .pick-row + .pick-row::before { content: ""; position: absolute; top: 0; inset-inline: 12px; border-top: .5px solid var(--line); }
.act-row select, .act-row input { font: inherit; font-size: 15px; background: var(--sunk); border: 0; border-radius: 8px; padding: 8px; color: inherit; min-width: 0; flex: 1; }
.act-row em { font-style: normal; color: var(--ink-3); font-size: 14px; }
.act-row .del { flex: none; }
.acts:empty { display: none; }
.pick-row .seg button { padding: 6px 10px; }
.legacy { margin-top: 22px; }
.legacy summary { cursor: pointer; color: var(--live); font-weight: 600; padding: 8px 4px; }
.row.disabled .when { opacity: .6; }
.tile.on, .outlet.on { box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .18); }
.tile.on .ico, .outlet.on .ico { color: var(--live); }

/* devices + Alexa */
.dev-ico { background: var(--live-soft); }
.dev-ico.off { background: var(--sunk); filter: grayscale(1); }
.nav-label small { display: block; color: var(--ink-3); font-size: 13px; }
.page-nav { margin: 0 0 6px; }
.pair-card { background: #fff; color: #000; border-radius: 16px; padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr { width: 200px; height: 200px; fill: #000; }
.qr .qr-bg { fill: #fff; }
.pair-code { font-size: 24px; font-weight: 700; letter-spacing: .08em; }
.pair-card .hint { color: #6c6c70; }
.steps { padding: 6px 14px; }
.steps p { margin: 8px 0; font-size: 15px; }
.hint.pad { padding: 12px 14px; }

/* ---- header actions, status row, rooms (Apple Home layout) ---- */
.top { display: flex; align-items: center; justify-content: space-between; }
.top-actions { display: flex; gap: 8px; }
.icon-btn { width: 44px; height: 44px; }
.icon-btn[hidden] { display: none; }
.status-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 2px 4px 14px; color: var(--ink-2); font-size: 15px; }
.status-row .stat b { color: var(--ink); font-weight: 600; }
.status-row .stat.warn b { color: var(--danger, #ff3b30); }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.section-title h2 small { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-top: 2px; }
p.room-meta { display: block; margin: -6px 4px 10px; font-size: 15px; color: var(--ink-2); }
.room.loose .section-title { margin-bottom: 12px; }
.nav-label small { display: block; font-size: 13px; color: var(--ink-2); margin-top: 1px; }
#sheet-body { position: relative; }
.sheet-close { position: absolute; top: 12px; inset-inline-end: 12px; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); z-index: 1; }
.sheet-close svg { width: 30px; height: 30px; padding: 7px; border-radius: 50%; background: var(--sunk); fill: currentColor; }
.sheet-close:active svg { opacity: .6; }

/* ---- iPad / Android tablet: use the width, like Home on iPad ---- */
@media (min-width: 760px) {
  body { max-width: 1080px; }
  .tabs { max-width: none; padding-inline: max(16px, calc((100vw - 760px) / 2)); }
  .tiles, .outlets { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
  .top h1 { font-size: 40px; }
  .group, .meter { max-width: 760px; margin-inline: auto; }
}

/* ---- line icons (icons.js): sized by the surrounding font-size, coloured by text colour ---- */
svg.i { width: 1em; height: 1em; flex: none; vertical-align: -.15em; fill: none; }
.tile .ico, .outlet .ico { color: var(--ink-2); }
.tile .ico svg.i, .outlet .ico svg.i { width: 22px; height: 22px; }
.tile.on .ico, .outlet.on .ico { color: var(--live); }
.tile.on[data-glow] .ico { color: #000; }
body.kiosk .tile .ico svg.i { width: 28px; height: 28px; }
.nav-ico { color: #fff; font-size: 18px; }
.nav-ico svg.i { stroke-width: 2.1; }
.dev-ico { color: var(--live); }
.dev-ico.off { color: var(--ink-2); }
.ev-ico { color: var(--ink-2); font-size: 18px; }
.ev-ico.ok { color: #34c759; } .ev-ico.alert { color: #ff9500; }
.lock { display: inline-grid; place-items: center; font-size: 14px; color: var(--ink-2); }
.icons button { display: grid; place-items: center; color: var(--ink-2); font-size: 24px; min-height: 48px; }
.icons button[aria-pressed="true"] { color: var(--live); }
.chips button svg.i, .scene-chip svg.i, .section-title h2 svg.i, .pill svg.i { font-size: 1.05em; margin-inline-end: 4px; }
.section-title h2 svg.i { color: var(--ink-2); }
.scene-chip > span, .template > span, .act-row > span:first-child { display: inline-grid; place-items: center; color: var(--live); font-size: 20px; }
.row .del svg.i, .act-row .del svg.i { font-size: 18px; }
.guard-trip svg.i, .reading small svg.i { color: #34c759; }
.room-meta svg.i { color: var(--ink-2); }
.group-foot.warn { color: #ff3b30; }

/* Tiles: the icon circle switches, the rest of the card opens the device (no accidental "off") */
.tile, .outlet { cursor: default; }
.tile:active, .outlet:active { transform: none; }
.tile:has(> .tile-open:active), .outlet:has(> .tile-open:active) { transform: scale(.98); }
.tile-open { position: absolute; inset: 0; border: 0; padding: 0; background: transparent; border-radius: inherit; cursor: pointer; }
.tile-open:focus-visible, .power:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; }
.tile > :not(.tile-open):not(.badge), .outlet > :not(.tile-open):not(.badge) { position: relative; pointer-events: none; }
.tile > .badge, .outlet > .badge { pointer-events: none; }
.tile .ico.power, .outlet .ico.power {
  pointer-events: auto; z-index: 1; width: 44px; height: 44px; border: 0; padding: 0; cursor: pointer;
  box-shadow: inset 0 0 0 1.5px var(--line); transition: transform .15s var(--ease), background-color .2s var(--ease), color .2s var(--ease);
}
.tile .ico.power:active, .outlet .ico.power:active { transform: scale(.88); }
.tile.on .ico.power, .outlet.on .ico.power { background: var(--live); color: #fff; box-shadow: 0 4px 12px -4px var(--live); }
.tile.on[data-glow] .ico.power { background: var(--glow); color: #000; }

/* device sheet: header with a small switch at the edge (no wide on/off button to hit by accident) */
.dev-head { display: flex; align-items: center; gap: 12px; margin: 2px 0 12px; padding-inline-end: 48px; }
.dev-ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex: none;
  background: var(--sunk); color: var(--ink-2); transition: background-color .2s var(--ease), color .2s var(--ease); }
.dev-head.on .dev-ico { background: var(--live-soft); color: var(--live); }
.dev-ico svg.i { width: 24px; height: 24px; }
.dev-head h3 { margin: 0; font-size: 20px; line-height: 1.25; overflow-wrap: anywhere; }
.state-row { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 4px 6px 4px 14px; padding-inline: 14px 6px;
  margin-bottom: 14px; background: var(--card); border-radius: 12px; font-size: 15px; color: var(--ink-2); }
.state-row [data-status] { flex: 1; min-width: 0; }
.state-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.state-row.on { color: var(--ink); }
.state-row.on .dot { background: var(--live); box-shadow: 0 0 0 3px var(--live-soft); }
.power-switch { flex: none; display: grid; place-items: center; width: 56px; height: 44px; margin: 0; padding: 0;
  border: 0; background: transparent; cursor: pointer; border-radius: 12px; touch-action: manipulation; }
.power-switch .switch { width: 51px; height: 31px; }
.power-switch .switch::after { width: 27px; height: 27px; top: 2px; inset-inline-start: 2px; }
.power-switch .switch.on { background: var(--live); }
.power-switch .switch.on::after { transform: translateX(-20px); }
.power-switch[aria-busy="true"] { opacity: .5; cursor: progress; }
.power-switch:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; }
.lock-tag { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-2);
  background: var(--sunk); border-radius: 999px; padding: 5px 10px; }
.lock-tag svg.i { width: 14px; height: 14px; }
.sheet-tabs { margin-bottom: 14px; }
.sheet-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.sheet-tabs svg.i { width: 16px; height: 16px; }
[data-panel][hidden] { display: none; }
.kpis.mini { margin-bottom: 12px; }
.kpis.mini .kpi { padding: 12px 14px; background: var(--sunk); }
.kpis.mini .k-val { font-size: 24px; }
.k-val.skel { color: var(--ink-3); }
.trend-box .seg.wide { margin-bottom: 10px; }
.chart { position: relative; padding-top: 18px; }
.chart svg { width: 100%; height: 120px; display: block; }
.chart .area { fill: var(--live-soft); }
.chart .line { fill: none; stroke: var(--live); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.chart .c-plot { position: relative; }
.chart .c-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.chart-empty { padding: 34px 8px; text-align: center; color: var(--ink-3); font-size: 14px; }
.power-note { margin: 4px 0 8px; }
.seg.wide { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
.seg.wide button { padding: 9px 6px; font-size: 14px; min-height: 40px; }
.seg button:disabled { opacity: .45; cursor: not-allowed; }

/* toast with an action (تراجع) */
.toast.with-act { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toast-act { border: 0; background: transparent; color: var(--live); font-weight: 700; font-size: 16px; padding: 8px 4px; min-height: 44px; cursor: pointer; }

/* Energy: answers first (today, month + forecast, live draw), then who uses the most */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.kpi { background: var(--card); border-radius: var(--radius-l); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .k-label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.kpi .k-val { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi .k-val small { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-inline-start: 4px; }
.kpi .k-sub { font-size: 14px; color: var(--ink-2); min-height: 1em; }
.kpi.live { grid-column: 1 / -1; flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.kpi.live .k-val { color: var(--live); font-size: 24px; }
.kpis { grid-template-columns: 1fr 1fr; }
.delta { font-size: 12.5px; color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; line-height: 1.35; }
.delta svg.i { width: 14px; height: 14px; }
.delta.up { color: var(--warn); }
.delta.down { color: #248a3d; }
@media (prefers-color-scheme: dark) { .delta.down { color: #30d158; } }
.budget-box { padding: 14px 16px; }
.budget-box .b-row { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; }
.budget-box .b-row b.hot { color: var(--warn); }
.budget-box .track, .rank .track { display: block; height: 6px; background: var(--sunk); border-radius: 999px; overflow: hidden; margin: 8px 0 6px; }
.budget-box .fill, .rank .fill { display: block; height: 100%; width: 0; background: var(--live); border-radius: 999px; transition: width .5s var(--ease); }
.budget-box .fill.hot { background: var(--warn); }
.budget-box .group-foot { padding: 0; }
.rank { padding: 0; }
.rank-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: start;
  border: 0; background: transparent; padding: 12px 16px; cursor: pointer; color: inherit; font: inherit; min-height: 64px;
}
.rank-row + .rank-row { border-top: .5px solid var(--line); }
.rank-row:active { background: var(--sunk); }
.rank-row .r-main { display: flex; flex-direction: column; min-width: 0; }
.rank-row .r-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .r-name small { font-weight: 400; color: var(--ink-2); font-size: 13px; }
.rank-row .track { margin: 6px 0 4px; }
.rank-row .r-now { color: var(--ink-2); font-size: 12.5px; }
.rank-row .r-val { display: flex; flex-direction: column; align-items: flex-end; text-align: end; }
.rank-row .r-val b { font-size: 17px; }
.rank-row .r-val small { color: var(--ink-2); font-size: 12.5px; }
.trend-box { padding: 12px 16px 14px; }
.trend { width: 100%; height: 70px; display: block; }
.trend .area { fill: var(--live-soft); }
.trend .line { fill: none; stroke: var(--live); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.trend .tip { fill: var(--live); stroke: var(--card); stroke-width: 2; }
.trend-box .facts { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; color: var(--ink-2); margin-top: 8px; }
.trend-box .facts b { color: var(--ink); }

/* Accounts: people with an initial, a role line, and a separate danger zone */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(160deg, #a5a5ad, #7d7d85); color: #fff; font-weight: 600; font-size: 16px;
}
.nav-row.person .nav-label small { display: block; }
.you { display: inline-block; font-size: 11px; font-weight: 600; color: var(--live); background: var(--live-soft); border-radius: 999px; padding: 1px 8px; margin-inline-start: 6px; vertical-align: middle; }
.person-head { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 4px 0 14px; }
.person-head .avatar { width: 64px; height: 64px; font-size: 28px; }
.person-head h3 { margin: 0; }
.danger-zone { margin-top: 22px; padding-top: 14px; border-top: .5px solid var(--line); text-align: center; }
.danger-zone .ghost.danger { display: inline-flex; align-items: center; gap: 6px; justify-content: center; width: 100%; min-height: 48px; }
.danger-zone .ghost.danger svg.i { width: 18px; height: 18px; }
.danger-zone button:disabled { opacity: .45; cursor: not-allowed; }
.section-title.stack { flex-direction: column; align-items: stretch; gap: 10px; }
.rank-row .r-val b { white-space: nowrap; }
.rank-row .r-val b small { font-size: 12px; font-weight: 500; color: var(--ink-2); }

/* outlet settings: section heading (الحماية) */
.sheet h4.sheet-sec { display: flex; align-items: center; gap: 6px; margin: 22px 0 2px; padding-top: 16px; border-top: .5px solid var(--line);
  font-size: 15px; font-weight: 700; color: var(--ink); }
.sheet h4.sheet-sec svg { width: 18px; height: 18px; color: var(--on); }

/* outlet usage: scale column, grid, bars/lines, cursor, insight */
.chart .c-plot { display: flex; gap: 6px; align-items: stretch; }
.chart .c-y { display: flex; flex-direction: column-reverse; justify-content: space-between; margin-block: -7px;
  min-width: 26px; font-size: 11px; line-height: 14px; color: var(--ink-3); text-align: end; font-variant-numeric: tabular-nums; }
.chart .c-area { position: relative; flex: 1; min-width: 0; }
.chart svg { width: 100%; height: 120px; display: block; overflow: visible; touch-action: pan-y; cursor: crosshair; }
.chart svg.h80 { height: 80px; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.chart .grid.base { stroke-dasharray: none; }
.chart .c-axis { padding-inline-end: 32px; }   /* the axis row is ltr; the scale sits on the right */
.chart .line.part { stroke-dasharray: 4 4; opacity: .6; }
.chart .line.volt { stroke: var(--ink-2); stroke-width: 1.8; }
.chart .band { fill: var(--on-soft); }
.chart.volt { margin-top: 12px; }
.chart .c-dot { position: absolute; width: 10px; height: 10px; margin: -5px -5px 0 0; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 3px var(--card); pointer-events: none; }
.chart .c-dot[hidden], .chart .c-cursor[hidden] { display: none; }
.chart .c-cursor { position: absolute; top: -4px; bottom: 0; width: 0; border-inline-start: 1.5px solid var(--ink-2); pointer-events: none; }
.sheet .insight { margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius-m); background: var(--live-soft); font-size: 14px; color: var(--ink); line-height: 1.5; }
.kpi .k-sub .up { color: var(--warn); }
.kpi .k-sub .down { color: var(--on); }
.reading.warn b { color: var(--warn); }

/* outlet settings: iOS-style titled cards */
.o-settings { display: flex; flex-direction: column; gap: 22px; }
.o-sec { display: flex; flex-direction: column; gap: 6px; }
.o-sec[hidden] { display: none; }
.sheet h4.o-title { display: flex; align-items: center; gap: 6px; margin: 0; padding-inline-start: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.sheet h4.o-title svg { width: 16px; height: 16px; color: var(--live); }
.o-card { background: var(--card); border-radius: var(--radius-m); padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.o-card > * + * { border-top: .5px solid var(--line); padding-top: 12px; }
.o-card .field.inline { min-height: 40px; }
.o-card .field.inline + .field.inline::before { display: none; }
.o-card .toggle-row { background: transparent; padding: 4px 0; border-radius: 0; }
.o-card .hint { margin: 0; }
.o-card .ghost { align-self: flex-start; }
.o-icons summary { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; list-style: none; font-size: 17px; }
.o-icons summary::-webkit-details-marker { display: none; }
.o-icons summary > span:first-child { flex: 1; }
.o-icons .o-cur { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--live-soft); color: var(--live); font-size: 20px; }
.o-icons .o-chev { color: var(--ink-3); font-size: 15px; }
.o-icons[open] .o-chev { color: var(--live); }
.o-icons .icons { margin-top: 12px; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
.o-icons .icons button { background: var(--sunk); }
.link-row { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-top: 4px; padding: 10px 0 2px; border: 0; background: none;
  color: var(--live); font: inherit; font-size: 16px; cursor: pointer; text-align: start; }
.o-save { position: sticky; bottom: 0; padding: 10px 0 4px; background: linear-gradient(to top, var(--paper) 70%, transparent); }
/* cyclic on/off sub-form and a command waiting for an offline strip */
.o-sub { display: flex; flex-direction: column; gap: 12px; }
.o-sub[hidden], .o-sub [hidden] { display: none; }
.o-sub > * + *, .o-sub > div > * + * { border-top: .5px solid var(--line); padding-top: 12px; }
.o-sub > div { display: flex; flex-direction: column; gap: 12px; }
.pending-row { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink-2); font-size: 14px; }
.pending-row > span { flex: 1; }
.pending-row svg.i { color: var(--live); }
.pending-row .ghost { align-self: center; }
.timer-tag svg.i { margin-inline-end: 2px; }

/* outlet usage, Health/Stocks style: one segmented control, big total, paged bars */
.usage-box .hl { display: flex; align-items: baseline; gap: 10px; margin-top: 14px; min-height: 44px; }
.usage-box .hl-val { font-size: 34px; font-weight: 700; line-height: 1.1; letter-spacing: -.5px; }
.usage-box .hl-val small { font-size: 15px; font-weight: 500; color: var(--ink-3); margin-inline-start: 5px; }
.usage-box .hl-cost { font-size: 15px; color: var(--ink-3); }
.usage-box .hl-val.skel { color: var(--ink-3); }
.usage-box .chart-nav { display: flex; align-items: center; justify-content: flex-start; gap: 4px; margin: 2px 0 8px; min-height: 28px; font-size: 13px; color: var(--ink-3); }
.usage-box .chart-nav button { border: 0; background: transparent; color: var(--ink-3); font-size: 20px; line-height: 1; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; }
.usage-box .chart-nav button:hover:not(:disabled) { background: var(--sunk); color: var(--ink); }
.usage-box .chart-nav button:disabled { opacity: .3; cursor: default; }
.usage-box .chart-nav[hidden] { display: none; }
.usage-box .chart { padding-top: 4px; }
.usage-box .grid { stroke: var(--line); opacity: .6; }
.usage-box .c-y { font-size: 11px; color: var(--ink-3); }
.usage-box .seg.wide button { padding: 9px 2px; font-size: 13px; white-space: nowrap; }
.usage-box .insight { margin: 12px 0 0; }
.c-slide { animation: c-in 200ms var(--ease) both; }
.c-slide[data-from="older"] { --c-dx: -24px; }
.c-slide[data-from="newer"] { --c-dx: 24px; }
.c-slide[data-from="fade"] { --c-dx: 0px; }
@keyframes c-in { from { opacity: 0; transform: translateX(var(--c-dx, 0)); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .c-slide { animation: none; } }

/* Outlet sheet: collapsed "تفاصيل تقنية", Health "Show All Data" style */
.tech { margin-top: 4px; }
.tech > summary { display: flex; align-items: center; justify-content: space-between; list-style: none; cursor: pointer;
  padding: 10px 4px; font-size: 13px; color: var(--ink-3); }
.tech > summary::-webkit-details-marker { display: none; }
.tech-chev { font-size: 15px; transition: transform var(--t, .2s); }
.tech[open] > summary { color: var(--ink-2); }
.tech[open] .tech-chev { transform: rotate(-90deg); }
.tech-body { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; }
.tech-body h5 { margin: 10px 4px 4px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.tech-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px; background: var(--card); font-size: 14px; }
.tech-row:first-of-type { border-start-start-radius: 12px; border-start-end-radius: 12px; }
.tech-row > span { color: var(--ink-2); }
.tech-row b { font-weight: 500; text-align: end; }
.tech-empty { margin: 6px 4px; font-size: 13px; color: var(--ink-3); }
.tech-tbl { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.tech-tbl th { padding: 8px 10px; text-align: start; font-weight: 600; color: var(--ink-3); box-shadow: inset 0 -.5px 0 var(--line); }
.tech-tbl td { padding: 6px 10px; box-shadow: inset 0 -.5px 0 var(--line); }
.tech-pager { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; font-size: 12px; color: var(--ink-3); }
.tech-pager button { padding: 4px 14px; }
.tech-csv { display: block; text-align: center; margin-top: 6px; padding: 11px; text-decoration: none; border-radius: 12px; background: var(--card); color: var(--live); font-size: 15px; }
