:root {
  --bg: var(--tg-theme-bg-color, #14162a);
  --card: var(--tg-theme-secondary-bg-color, #1e2036);
  --text: var(--tg-theme-text-color, #e9e8f3);
  --hint: var(--tg-theme-hint-color, #9a99ab);
  --accent: var(--tg-theme-button-color, #4f7cff);
  --off: #ff6b57;
  --on: #3fbf7f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

#app { max-width: 640px; margin: 0 auto; padding: 16px 14px 40px; }

.head h1 { margin: 0; font-size: 1.6rem; letter-spacing: .02em; }
.head .sub { margin: 2px 0 14px; color: var(--hint); font-size: .92rem; }

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}

.banner {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: .95rem;
  background: rgba(255, 107, 87, .14);
  border: 1px solid rgba(255, 107, 87, .5);
}
.banner.info { background: rgba(79, 124, 255, .12); border-color: rgba(79, 124, 255, .45); }

.field { display: block; margin-bottom: 8px; }
.field > span { display: block; font-size: .8rem; color: var(--hint); margin-bottom: 4px; }

input[type="search"] {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  font-size: 1rem;
}
input[type="search"]:disabled { opacity: .55; }

.options { list-style: none; margin: 0 0 10px; padding: 0; max-height: 260px; overflow-y: auto; }
.options li {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.options li:active, .options li.active { background: rgba(79, 124, 255, .18); }

.picked { margin: 4px 0 0; font-weight: 600; }

.status-line { display: flex; align-items: center; gap: 10px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--hint); flex: 0 0 auto; }
.dot.on { background: var(--on); box-shadow: 0 0 12px rgba(63, 191, 127, .7); }
.dot.off { background: var(--off); box-shadow: 0 0 12px rgba(255, 107, 87, .7); }
.light-text { font-size: 1.2rem; font-weight: 600; }
.until { margin: 8px 0 0; font-size: 1.05rem; }
.queue { margin: 6px 0 0; color: var(--hint); font-size: .9rem; }
.note { margin: 6px 0 0; color: var(--hint); font-size: .9rem; }
.updated { margin: 10px 0 0; color: var(--hint); font-size: .8rem; }

h2 { font-size: 1rem; margin: 20px 0 8px; color: var(--hint); font-weight: 600; }

.day {
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.day-head { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 8px; }
.day-head .meta { color: var(--hint); }
.hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 1px; }
.hour { height: 22px; border-radius: 3px; background: rgba(63, 191, 127, .28); position: relative; }
.hour b { position: absolute; left: 0; bottom: 0; width: 100%; height: 100%; border-radius: 3px;
          background: var(--off); display: block; }
.hour.now::after {
  content: ""; position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--accent);
  left: 50%; transform: translateX(-50%);
}
.times { display: flex; justify-content: space-between; color: var(--hint); font-size: .72rem; margin-top: 4px; }

.legend { color: var(--hint); font-size: .82rem; display: flex; align-items: center; gap: 8px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw-off { background: var(--off); }
.sw-on { background: rgba(63, 191, 127, .28); }

.error { background: rgba(255, 107, 87, .14); border: 1px solid rgba(255, 107, 87, .5); }
.foot { color: var(--hint); font-size: .75rem; text-align: center; margin-top: 20px; }

/* Вкладки источников: показываем, когда графики ЯСНО и ДТЕК расходятся
   или один из сервисов недоступен */
.tabs-reason {
  color: var(--hint);
  font-size: .88rem;
  margin: 0 0 10px;
}

.tabbar {
  display: flex;
  gap: 6px;
  background: var(--card);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 12px;
}
.tab {
  flex: 1;
  border: 0;
  border-radius: 9px;
  padding: 10px 8px;
  font: inherit;
  font-weight: 600;
  color: var(--hint);
  background: transparent;
  cursor: pointer;
}
.tab.active {
  background: var(--accent);
  color: #fff;
}
.panel[hidden] { display: none; }
.panel {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
}
.panel .status-line { margin-bottom: 4px; }
.panel .day { background: rgba(255, 255, 255, .04); }
