:root {
  --bg: #0b0f1a;
  --bg2: #111827;
  --bg3: #1a2235;
  --border: rgba(255, 255, 255, 0.07);
  --border2: rgba(255, 255, 255, 0.12);
  --text: #e8eaf0;
  --muted: #7a8299;
  --accent: #f0a500;
  --accent2: #3b82f6;
  --green: #22c55e;
  --yellow: #fbbf24;
  --red: #ef4444;
  --mono: "Space Mono", monospace;
  --sans: "Outfit", sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(59, 130, 246, 0.07) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "header header"
    "weather duty"
    "footer footer";
  gap: 16px;
  padding: 20px;
}

#header {
  grid-area: header;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
}

#header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent2), transparent);
}

#clock {
  font-family: var(--mono);
  font-size: clamp(3rem, 6vw, 5.5rem);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  line-height: 1;
  transition: opacity 0.08s;
}

#clock .colon {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

#date-block {
  text-align: center;
  min-width: 0;
}

#date-day {
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

#date-full {
  font-size: clamp(0.9rem, 1.5vw, 1.15rem);
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#location-block {
  text-align: right;
  min-width: 0;
  max-width: min(100%, 26rem);
}

#location-name {
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

#location-coords {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

#location-status {
  margin-top: 8px;
  font-size: 0.76rem;
  line-height: 1.45;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  overflow-wrap: anywhere;
}

#location-status.ok {
  color: var(--green);
}

#location-status.warn {
  color: var(--yellow);
}

#location-status.error {
  color: var(--red);
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.card-title {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 6px var(--accent2);
  flex-shrink: 0;
}

.card-title .dot.green {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

#weather {
  grid-area: weather;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#temp-display {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}

#temp-value {
  font-family: var(--mono);
  font-size: clamp(4rem, 9vw, 7.5rem);
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

#temp-unit {
  font-family: var(--mono);
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  color: var(--muted);
  margin-top: 8px;
}

#weather-icon {
  font-size: clamp(3rem, 6vw, 5rem);
  margin-left: auto;
  filter: drop-shadow(0 0 12px rgba(240, 165, 0, 0.3));
}

#weather-desc {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 500;
  color: var(--text);
  margin-bottom: 20px;
}

.weather-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: auto;
}

.stat-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
}

.stat-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--mono);
  font-size: clamp(1rem, 2vw, 1.4rem);
  font-weight: 700;
  color: var(--text);
}

#duty {
  grid-area: duty;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.duty-status-strip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
}

.duty-status-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.duty-status-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 110px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border2);
  background: rgba(255, 255, 255, 0.04);
}

#duty-status-text {
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.duty-status-note {
  max-width: 210px;
  text-align: right;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.tone-good {
  border-color: rgba(34, 197, 94, 0.18);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.08), rgba(34, 197, 94, 0.03));
}

.tone-warn {
  border-color: rgba(251, 191, 36, 0.2);
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.08), rgba(251, 191, 36, 0.03));
}

.tone-error {
  border-color: rgba(239, 68, 68, 0.2);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.08), rgba(239, 68, 68, 0.03));
}

.tone-neutral {
  border-color: var(--border);
}

.duty-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.duty-tab {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  letter-spacing: 0.04em;
}

.duty-tab.active {
  background: var(--bg3);
  border-color: var(--accent2);
  color: var(--text);
}

.duty-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.duty-list::-webkit-scrollbar {
  width: 4px;
}

.duty-list::-webkit-scrollbar-track {
  background: transparent;
}

.duty-list::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 4px;
}

.duty-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color 0.2s;
  animation: slideIn 0.3s ease both;
}

.duty-item:hover {
  border-color: var(--border2);
}

.duty-item.degraded {
  border-color: rgba(251, 191, 36, 0.22);
}

.duty-item.fallback {
  border-color: rgba(239, 68, 68, 0.16);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.duty-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.duty-info {
  flex: 1;
  min-width: 0;
}

.duty-meta {
  width: 190px;
  min-width: 190px;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.duty-name {
  font-size: clamp(0.9rem, 1.6vw, 1.05rem);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

.duty-address {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

.duty-phone {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent2);
  font-weight: 700;
}

.duty-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.duty-hours {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 4px;
  text-align: right;
  font-family: var(--mono);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.duty-hours-line {
  display: block;
  white-space: nowrap;
}

.duty-entry-status {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
}

.duty-entry-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.duty-entry-status.good {
  color: var(--green);
}

.duty-entry-status.warn {
  color: var(--yellow);
}

.duty-entry-status.error {
  color: var(--red);
}

.card-message {
  border: 1px dashed var(--border2);
  border-radius: 10px;
  padding: 18px 16px;
  text-align: center;
  font-size: 0.86rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.card-message.error {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.05);
}

.loading-row {
  height: 86px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    var(--bg3);
  background-size: 220px 100%, auto;
  animation: shimmer 1.5s linear infinite;
}

@keyframes shimmer {
  from { background-position: -220px 0, 0 0; }
  to { background-position: calc(100% + 220px) 0, 0 0; }
}

.badge-24h {
  background: rgba(34, 197, 94, 0.12);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.badge-duty {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent2);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-hosp {
  background: rgba(240, 165, 0, 0.12);
  color: var(--accent);
  border: 1px solid rgba(240, 165, 0, 0.25);
}

#footer {
  grid-area: footer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.footer-item {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 5px var(--green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

body.night {
  filter: brightness(0.35);
  transition: filter 1.5s ease;
}

body.day {
  filter: brightness(1);
  transition: filter 1.5s ease;
}

#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  transition: opacity 0.5s;
}

#loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loader-text {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 980px) {
  html,
  body {
    overflow: auto;
  }

  #app {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "weather"
      "duty"
      "footer";
    overflow-y: auto;
  }

  #header,
  #footer,
  .duty-status-strip,
  .duty-status-main,
  .duty-item {
    flex-direction: column;
  }

  #header,
  #footer {
    align-items: flex-start;
    gap: 14px;
  }

  #location-block,
  .duty-status-note {
    text-align: left;
  }

  .duty-meta {
    width: 100%;
    min-width: 0;
    margin-left: 0;
    align-items: flex-start;
    text-align: left;
  }

  .duty-hours {
    align-items: flex-start;
    text-align: left;
  }

  .weather-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
