:root {
  --tg-bg-color: #ffffff;
  --tg-text-color: #000000;
  --tg-hint-color: #999999;
  --tg-link-color: #2481cc;
  --tg-button-color: #2481cc;
  --tg-button-text-color: #ffffff;
  --tg-secondary-bg-color: #f0f0f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--tg-bg-color);
  color: var(--tg-text-color);
}

#app-root {
  min-height: 100vh;
  padding: calc(16px + var(--tg-safe-area-top, 56px)) 16px
    calc(164px + var(--tg-safe-area-bottom, 0px));
}

#clock-widget {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--tg-safe-area-top, 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--tg-bg-color);
  color: var(--tg-hint-color);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  z-index: 20;
  pointer-events: none;
}

#clock-time {
  font-weight: 600;
  color: var(--tg-text-color);
}

.full-page-message {
  margin-top: 40vh;
  text-align: center;
  color: var(--tg-hint-color);
  font-size: 15px;
}

.retry-button {
  display: block;
  margin: 16px auto 0;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background: var(--tg-button-color);
  color: var(--tg-button-text-color);
  font-size: 15px;
  cursor: pointer;
}

#toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(150px + var(--tg-safe-area-bottom, 0px));
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--tg-secondary-bg-color);
  color: var(--tg-text-color);
  text-align: center;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

#toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  cursor: pointer;
}

.group-section {
  margin-bottom: 24px;
}

.group-section summary {
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--tg-text-color);
  margin: 0 0 10px 0;
  padding: 0 0 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  list-style: none;
}

.group-section summary::-webkit-details-marker {
  display: none;
}

.section-chevron {
  width: 8px;
  height: 8px;
  margin-right: 10px;
  border-right: 2px solid var(--tg-text-color);
  border-bottom: 2px solid var(--tg-text-color);
  transform: rotate(-45deg);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.group-section[open] .section-chevron {
  transform: rotate(45deg);
}

.group-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--tg-secondary-bg-color);
  border-radius: 10px;
  overflow: hidden;
}

.group-row {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.group-list li:last-child .group-row {
  border-bottom: none;
}

.group-row summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}

.group-row summary::-webkit-details-marker {
  display: none;
}

.group-row-flat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}

.group-chevron {
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-right: 2px solid var(--tg-hint-color);
  border-bottom: 2px solid var(--tg-hint-color);
  transform: rotate(-45deg);
  transition: transform 0.2s;
}

.group-row[open] .group-chevron {
  transform: rotate(45deg);
}

.group-name {
  flex: 1;
  font-size: 15px;
}

.channel-list {
  list-style: none;
  margin: 0;
  padding: 4px 16px 12px 32px;
}

.channel-list li {
  font-size: 13px;
  color: var(--tg-hint-color);
  padding: 4px 0;
}

.channel-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.channel-name-link {
  color: var(--tg-link-color);
  cursor: pointer;
}

.channel-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--tg-hint-color);
  border-radius: 26px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 2px;
  bottom: 2px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--tg-button-color);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.hidden {
  display: none !important;
}

#bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--tg-bg-color);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-bottom: var(--tg-safe-area-bottom, 0px);
}

#tab-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

#tab-bar .tab {
  padding: 12px 0;
  border: none;
  background: none;
  font-size: 15px;
  font-family: inherit;
  color: var(--tg-hint-color);
  cursor: pointer;
}

#tab-bar .tab.active {
  color: var(--tg-button-color);
  font-weight: 600;
}

.status-card {
  border-radius: 12px;
  padding: 24px 16px;
  margin-bottom: 16px;
  text-align: center;
  color: #ffffff;
}

.status-card.alert {
  background: #d32f2f;
}

.status-card.calm {
  background: #2e7d32;
}

.status-card.inactive {
  background: #e0e0e0;
  min-height: 20px;
}

.status-title {
  font-size: 20px;
  font-weight: 700;
}

.status-duration {
  margin-top: 8px;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

.location-card {
  background: var(--tg-secondary-bg-color);
  border-radius: 12px;
  padding: 16px;
}

.location-primary {
  font-size: 16px;
  font-weight: 600;
}

.location-secondary {
  margin-top: 4px;
  font-size: 14px;
  color: var(--tg-hint-color);
}

.dashboard-prompt,
.view-loading,
.settings-empty {
  margin-top: 30vh;
  text-align: center;
  color: var(--tg-hint-color);
  font-size: 15px;
}

.settings-empty {
  margin-top: 8px;
  text-align: left;
}

.section-label {
  margin: 0 0 8px 4px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--tg-hint-color);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--tg-secondary-bg-color);
  border-radius: 10px;
  margin-bottom: 24px;
}

.settings-row .setting-name {
  flex: 1;
  font-size: 15px;
  padding-right: 12px;
}

.info-text-static {
  padding: 12px 16px;
  background: var(--tg-secondary-bg-color);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--tg-text-color);
  white-space: pre-line;
}

.home-screen-button {
  width: 100%;
  margin: 16px 0 0;
}

.oblast-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}

.oblast-tile {
  padding: 14px 8px;
  border-radius: 10px;
  background: var(--tg-secondary-bg-color);
  color: var(--tg-text-color);
  font-size: 13px;
  text-align: center;
}

.oblast-tile.active {
  background: #d32f2f;
  color: #ffffff;
  font-weight: 600;
}

.detailed-map-button {
  width: 100%;
  margin-bottom: 24px;
}

.ukraine-map-container {
  margin-bottom: 24px;
}

.ukraine-map-container svg {
  width: 100%;
  height: auto;
  display: block;
}

.oblast-shape {
  fill: var(--tg-secondary-bg-color);
  stroke: var(--tg-bg-color);
  stroke-width: 1.5;
  transition: fill 0.2s;
}

.oblast-shape.active {
  fill: #d32f2f;
}

.oblast-point {
  stroke-width: 1;
}

.user-pin-ring {
  fill: #ffffff;
  stroke: #111827;
  stroke-width: 1.5;
}

.user-pin-dot {
  fill: #111827;
  stroke: none;
}

.stats-filter-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.stats-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--tg-secondary-bg-color);
  color: var(--tg-text-color);
  font-size: 14px;
  box-sizing: border-box;
}

.stats-preset-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.stats-preset {
  padding: 8px 14px;
  border: none;
  border-radius: 20px;
  background: var(--tg-secondary-bg-color);
  color: var(--tg-text-color);
  font-size: 13px;
  cursor: pointer;
}

.stats-preset.active {
  background: var(--tg-button-color);
  color: var(--tg-button-text-color);
  font-weight: 600;
}

.stats-custom-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.stats-custom-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stats-custom-field-label {
  font-size: 12px;
  color: var(--tg-hint-color);
}

.stats-custom-row input[type="date"] {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: var(--tg-secondary-bg-color);
  color: var(--tg-text-color);
  font-size: 14px;
}

.stats-updated-at {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--tg-hint-color);
  text-align: right;
}

.stats-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-tile {
  background: var(--tg-secondary-bg-color);
  border-radius: 10px;
  padding: 12px;
}

.stat-tile-label {
  font-size: 12px;
  color: var(--tg-hint-color);
}

.stat-tile-value {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 700;
}

.stat-tile-badge {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #d32f2f;
}

.stats-chart-wrap {
  position: relative;
}

.stats-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 156px;
  /* top padding must clear the count label's "top: -16px" offset above a
     full-height bar - overflow-x: auto forces overflow-y to auto too, so
     anything above the content box (rather than just in the padding) gets
     clipped instead of spilling out. Bottom padding keeps the scrollbar
     clear of the date labels instead of overlapping them. */
  padding: 20px 4px 16px;
  background: var(--tg-secondary-bg-color);
  border-radius: 10px;
  overflow-x: auto;
}

.stats-chart-sentinel {
  flex: 0 0 1px;
  width: 1px;
  align-self: stretch;
}

.stats-chart-spacer {
  flex: 1 1 0;
  min-width: 0;
}

.stats-chart-fade {
  position: absolute;
  top: 0;
  bottom: 16px;
  width: 28px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  border-radius: 10px;
}

.stats-chart-fade.visible {
  opacity: 1;
}

.stats-chart-fade-left {
  left: 0;
  background: linear-gradient(to right, var(--tg-secondary-bg-color), transparent);
}

.stats-chart-fade-right {
  right: 0;
  background: linear-gradient(to left, var(--tg-secondary-bg-color), transparent);
}

.stats-chart-arrow {
  position: absolute;
  top: 0;
  bottom: 16px;
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.stats-chart-arrow.visible {
  opacity: 1;
  pointer-events: auto;
}

.stats-chart-arrow-left {
  left: 0;
}

.stats-chart-arrow-right {
  right: 0;
}

.stats-chart-arrow-glyph {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--tg-bg-color);
  color: var(--tg-text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.stats-chart-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: 0 1 60px;
  min-width: 36px;
  height: 100%;
}

.stats-chart-bar {
  width: 100%;
  min-height: 2px;
  background: #d32f2f;
  border-radius: 4px 4px 0 0;
  position: relative;
  display: flex;
  justify-content: center;
}

.stats-chart-bar-count {
  position: absolute;
  top: -16px;
  font-size: 11px;
  color: var(--tg-hint-color);
}

.stats-chart-bar-label {
  margin-top: 4px;
  font-size: 10px;
  color: var(--tg-hint-color);
  white-space: nowrap;
}

.stats-chart-bar-wrap-clickable {
  cursor: pointer;
}

.stats-timeline {
  margin-top: 12px;
  background: var(--tg-secondary-bg-color);
  border-radius: 10px;
  padding: 12px;
}

.stats-timeline-header {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-text-color);
}

.stats-timeline-strip {
  position: relative;
  height: 48px;
  background: var(--tg-bg-color);
  border-radius: 6px;
  overflow: hidden;
}

.stats-timeline-segment {
  position: absolute;
  top: 0;
  bottom: 0;
  background: #d32f2f;
  min-width: 2px;
}

.stats-timeline-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: var(--tg-hint-color);
}

.stats-timeline-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 13px;
  color: var(--tg-text-color);
}

.stats-timeline-list li {
  padding: 4px 0;
  border-top: 1px solid var(--tg-bg-color);
}

.stats-timeline-list li:first-child {
  border-top: none;
}
