:root {
  color-scheme: light;
  --navy: #032d5f;
  --navy-dark: #001f45;
  --blue: #0b63d8;
  --blue-soft: #e8f3ff;
  --ink: #061b3a;
  --muted: #52627a;
  --line: #d8e0ea;
  --field: #f9fbfe;
  --green: #14883a;
  --green-soft: #edf9f1;
  --orange: #f28b00;
  --danger: #d72f37;
  --shadow: 0 18px 42px rgba(3, 45, 95, 0.13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(232, 243, 255, 0.86), rgba(255, 255, 255, 0.96) 17rem),
    radial-gradient(circle at 18% 0, rgba(11, 99, 216, 0.18), transparent 23rem),
    #fff;
  font-size: 16px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  padding-bottom: 20px;
}

.hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  min-height: 104px;
  padding: 18px 22px;
  color: #fff;
  background:
    linear-gradient(135deg, var(--navy-dark), var(--navy)),
    radial-gradient(circle at 30% 5%, rgba(0, 159, 255, 0.4), transparent 16rem);
  box-shadow: 0 12px 28px rgba(0, 31, 69, 0.22);
}

.lang-pill {
  display: grid;
  grid-template-columns: repeat(2, 56px);
  gap: 4px;
  padding: 4px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  direction: ltr;
}

.lang-pill span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 14px;
  font-weight: 900;
}

.lang-pill span:first-child {
  background: var(--blue);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
}

.hero-title {
  text-align: center;
  line-height: 1.06;
}

.hero-title h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.9rem);
  letter-spacing: 0;
}

.hero-title strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(1.45rem, 5vw, 3rem);
}

.menu-button {
  display: grid;
  gap: 7px;
  width: 44px;
  padding: 0;
  border: 0;
  background: transparent;
}

.menu-button span {
  display: block;
  height: 4px;
  background: #fff;
  border-radius: 999px;
}

.calculator {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.panel,
.total-card,
.recommendation {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.bilingual-heading,
.bilingual-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.bilingual-heading {
  margin-bottom: 16px;
}

.bilingual-heading > div:first-child {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
}

.bilingual-heading h2,
.bilingual-row h2,
.compact-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1.05;
}

.bilingual-heading p,
.compact-heading p,
.recommend-head p {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
}

.rtl-title {
  text-align: right;
}

.section-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--blue);
  font-weight: 950;
  font-size: 1.4rem;
}

.add-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.7fr) minmax(130px, 0.45fr);
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  direction: ltr;
}

.add-bar label,
.settings-grid label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.35;
}

label b {
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-height: 50px;
  padding: 0 13px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  font-weight: 750;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--blue) 50%),
    linear-gradient(135deg, var(--blue) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% + 1px),
    calc(100% - 12px) calc(50% + 1px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(11, 99, 216, 0.12);
}

.custom-only {
  display: none !important;
}

.show-custom .custom-only {
  display: grid !important;
}

.show-custom {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.8fr) minmax(118px, 0.5fr) auto;
}

.outline-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 18px;
  color: var(--blue);
  background: #fff;
  border: 2px solid var(--blue);
  border-radius: 12px;
  font-weight: 900;
}

.outline-action b {
  color: var(--blue);
}

.plus {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: #fff;
  background: var(--blue);
  border-radius: 50%;
  font-size: 1.35rem;
  line-height: 1;
}

.table-head {
  display: grid;
  grid-template-columns: minmax(210px, 1.3fr) 170px 160px 118px 42px;
  gap: 10px;
  padding: 0 12px 10px;
  color: var(--ink);
  font-weight: 900;
  line-height: 1.55;
  direction: ltr;
}

.table-head b {
  font-weight: 750;
}

.appliance-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.appliance-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.3fr) 170px 160px 118px 42px;
  gap: 10px;
  align-items: center;
  padding: 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  direction: ltr;
}

.appliance-row:last-child {
  border-bottom: 0;
}

.device-cell {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.device-icon {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  color: #fff;
  background: linear-gradient(145deg, #0e6ee8, #0648b8);
  border-radius: 10px;
  box-shadow: inset 0 -7px 12px rgba(0, 0, 0, 0.18);
  font-size: 1.95rem;
  font-weight: 900;
}

.device-cell h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.25;
  direction: ltr;
}

.device-cell p {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
  direction: rtl;
}

.qty-control {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  overflow: hidden;
}

.qty-control button {
  height: 100%;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: 1.7rem;
  font-weight: 500;
}

.qty-control input {
  min-height: 54px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 1.25rem;
}

.power-cell input,
.power-cell select {
  min-height: 56px;
  text-align: center;
}

.power-cell small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.row-total {
  color: var(--ink);
  font-size: 1.35rem;
  text-align: center;
  direction: ltr;
  unicode-bidi: isolate;
}

.remove-row {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: #fff;
  font-size: 1.45rem;
  line-height: 1;
}

.total-card {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 18px;
  background: linear-gradient(135deg, #f6fbff, #e8f3ff);
  border-color: #b9dcff;
}

.total-icon {
  color: #1399e8;
  font-size: 3rem;
  font-weight: 900;
}

.total-card span,
.total-card b {
  display: block;
  font-size: 1.05rem;
}

.total-card strong {
  color: var(--ink);
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1;
  direction: ltr;
  unicode-bidi: isolate;
}

.total-card small {
  grid-column: 3;
  margin-top: -12px;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
  direction: ltr;
  unicode-bidi: isolate;
}

.outage-panel {
  background: linear-gradient(135deg, #ffffff, #f8fbff);
}

.duration-control {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 16px;
  align-items: center;
  margin-top: 12px;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--blue);
  border: 0;
  background: transparent;
}

.duration-value {
  display: grid;
  place-items: center;
  min-height: 86px;
  color: #fff;
  background: var(--navy);
  border-radius: 16px;
}

.duration-value strong {
  font-size: 2.3rem;
  line-height: 1;
}

.duration-value span {
  color: #dbeafe;
  font-weight: 850;
}

.helper {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.system-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
  direction: ltr;
}

.system-tabs button {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: center;
  min-height: 92px;
  padding: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
}

.system-tabs button.active {
  color: var(--orange);
  border: 2px solid var(--orange);
  background: #fffaf2;
}

.tab-icon {
  grid-row: 1 / span 2;
  color: var(--green);
  font-size: 2rem;
  font-weight: 900;
}

.tab-icon.sun {
  color: var(--orange);
}

.system-tabs strong,
.system-tabs b {
  display: block;
  line-height: 1.15;
}

.system-tabs strong {
  font-size: 1.07rem;
}

.system-tabs b {
  font-size: 0.95rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.recommendation {
  padding: 18px;
  background: linear-gradient(145deg, #f3fbf5, #ffffff 58%);
  border-color: #b9d9c3;
}

.recommend-head {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--green);
}

.recommend-head h2 {
  margin: 0;
  color: var(--green);
  font-size: 1.55rem;
}

.checkmark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  color: #fff;
  background: var(--green);
  border-radius: 50%;
  font-size: 2.1rem;
  font-weight: 950;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 16px 0 0;
  padding: 16px;
  background: #fff;
  border-radius: 18px 18px 0 0;
}

.metric {
  padding: 10px 14px;
  border-inline-end: 1px solid var(--line);
  text-align: center;
}

.metric:last-child {
  border-inline-end: 0;
}

.metric span,
.result-bottom span {
  display: block;
  color: var(--ink);
  font-weight: 900;
}

.metric b,
.result-bottom b {
  display: block;
  color: var(--muted);
  font-size: 0.95rem;
}

.metric strong,
.result-bottom strong {
  display: block;
  margin-top: 10px;
  color: var(--green);
  font-size: clamp(1.55rem, 5vw, 2.2rem);
  line-height: 1.05;
  direction: ltr;
  unicode-bidi: isolate;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.result-bottom {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  padding: 16px;
  background: #fff;
  border-top: 1px solid var(--line);
  border-radius: 0 0 18px 18px;
  text-align: center;
}

.result-bottom > div:first-child {
  border-inline-end: 1px solid var(--line);
}

.result-note {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.65;
  font-weight: 750;
}

.sticky-summary {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 16px;
  align-items: center;
  margin: 0 14px;
  padding: 16px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  border-radius: 14px;
  box-shadow: 0 -12px 28px rgba(0, 31, 69, 0.18);
  z-index: 6;
}

.sticky-summary span,
.sticky-summary b {
  display: block;
  color: #fff;
}

.sticky-summary strong {
  color: #fff;
  font-size: 1.35rem;
  direction: ltr;
  unicode-bidi: isolate;
}

@media (min-width: 840px) {
  .calculator {
    grid-template-columns: 1.2fr 0.8fr;
  }

  .appliances-panel,
  .total-card,
  .recommendation {
    grid-column: 1 / -1;
  }
}

@media (max-width: 740px) {
  .hero {
    grid-template-columns: 1fr auto;
    min-height: 92px;
    padding: 14px;
    overflow: hidden;
  }

  .lang-pill {
    grid-row: 2;
    grid-column: 1 / -1;
    justify-self: start;
    grid-template-columns: repeat(2, 48px);
  }

  .hero-title {
    text-align: right;
    min-width: 0;
  }

  .hero-title h1 {
    font-size: clamp(1.85rem, 8vw, 2.35rem);
    white-space: nowrap;
  }

  .hero-title strong {
    font-size: clamp(1.25rem, 6vw, 1.75rem);
    white-space: nowrap;
  }

  .menu-button {
    width: 38px;
  }

  .add-bar,
  .show-custom,
  .settings-grid,
  .duration-control {
    grid-template-columns: 1fr;
  }

  .table-head {
    display: none;
  }

  .appliance-list {
    border: 0;
    gap: 10px;
    overflow: visible;
  }

  .appliance-row {
    grid-template-columns: 1fr;
    border: 1px solid var(--line);
    border-radius: 16px;
  }

  .device-cell {
    grid-template-columns: 58px 1fr;
  }

  .device-icon {
    width: 58px;
    height: 58px;
    font-size: 1.6rem;
  }

  .remove-row {
    position: absolute;
    inset-inline-end: 12px;
    top: 12px;
  }

  .appliance-row {
    position: relative;
  }

  .row-total {
    text-align: start;
  }

  .system-tabs,
  .result-grid,
  .result-bottom,
  .sticky-summary {
    grid-template-columns: 1fr;
  }

  .result-bottom > div:first-child,
  .metric {
    border-inline-end: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .total-card {
    grid-template-columns: 52px 1fr;
  }

  .total-card strong,
  .total-card small {
    grid-column: 1 / -1;
    text-align: end;
  }

  .sticky-summary {
    position: static;
  }
}
