:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e4e7eb;
  --text: #1a1d21;
  --text-dim: #6b7280;
  --green: #12b76a;
  --red: #e5484d;
  --gray: #9aa1ab;
  --hover: rgba(0, 0, 0, 0.05);
  --tooltip: #1a1d21;
  --tooltip-text: #ffffff;
}

html[data-theme="dark"] {
  --bg: #0d1017;
  --surface: #151922;
  --border: #242936;
  --text: #e7eaf2;
  --text-dim: #9aa3b2;
  --green: #2ec27e;
  --red: #f2556a;
  --gray: #6b7280;
  --hover: rgba(255, 255, 255, 0.08);
  --tooltip: #e7eaf2;
  --tooltip-text: #0d1017;
}

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

.hidden {
  display: none !important;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
}

.brand-dim {
  color: var(--text-dim);
  font-weight: 500;
}

.nav {
  display: flex;
  gap: 18px;
}

.nav a {
  font-size: 14px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 2px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav a:hover {
  color: var(--text);
}

.nav .nav-active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  padding: 7px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--hover);
}

.theme-toggle .theme-icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-toggle .theme-icon-sun {
  display: block;
}

html[data-theme="dark"] .theme-toggle .theme-icon-moon {
  display: none;
}

/* Stats toggle icon */
html[data-stats="0"] .stats-icon-on {
  display: none;
}

html[data-stats="1"] .stats-icon-off {
  display: none;
}

/* Main */
main.container {
  flex: 1;
  padding: 48px 24px 56px;
}

/* Hero */
.hero {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 40px;
}

.hero-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  background: var(--gray);
}

.hero-dot.online {
  background: var(--green);
}

.hero-dot.active {
  background: #f0a500;
}

.hero-dot.offline {
  background: var(--red);
}

.hero-text h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow-wrap: break-word;
}

/* Maintenance banner */
.maintenance-banner {
  background: #fff8e6;
  border: 1px solid #f0c674;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 24px;
}

.maintenance-banner.hidden {
  display: none;
}

.maintenance-banner-link {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  color: inherit;
  text-decoration: none;
  width: 100%;
}

.maintenance-banner-link:hover .maintenance-more {
  color: #7c4a03;
  text-decoration: underline;
}

.maintenance-icon {
  color: #b45309;
  font-size: 20px;
  margin-top: 2px;
  flex-shrink: 0;
}

.maintenance-body {
  min-width: 0;
  flex: 1;
}

.maintenance-title {
  font-size: 15px;
  font-weight: 700;
  color: #7c4a03;
  overflow-wrap: break-word;
}

.maintenance-desc {
  font-size: 13px;
  color: #7c4a03;
  margin-top: 4px;
  overflow-wrap: break-word;
}

.maintenance-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 8px;
  font-size: 12.5px;
  color: #92600a;
}

.maintenance-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.maintenance-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: #b45309;
}

html[data-theme="dark"] .maintenance-banner {
  background: #3a2f14;
  border-color: #6b531c;
}

html[data-theme="dark"] .maintenance-title,
html[data-theme="dark"] .maintenance-desc {
  color: #f0d9a0;
}

html[data-theme="dark"] .maintenance-icon {
  color: #f0c674;
}

html[data-theme="dark"] .maintenance-meta {
  color: #d9bc7a;
}

html[data-theme="dark"] .maintenance-more {
  color: #f0c674;
}

html[data-theme="dark"] .maintenance-banner-link:hover .maintenance-more {
  color: #f0d9a0;
}

/* Wartung detail page */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 16px;
}

.back-link:hover {
  color: var(--text);
}

.wartung-hero {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

.wartung-hero .hero-dot.online {
  background: #f0a500;
}

.wartung-hero .hero-dot.offline {
  background: var(--green);
}

.status-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.status-pill.active {
  background: rgba(240, 165, 0, 0.15);
  color: #b45309;
}

.status-pill.ended {
  background: rgba(18, 183, 106, 0.15);
  color: var(--green);
}

html[data-theme="dark"] .status-pill.active {
  color: #f0c674;
}

.wartung-hero h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow-wrap: break-word;
}

.wartung-desc {
  font-size: 15px;
  color: var(--text-dim);
  margin-top: 8px;
  overflow-wrap: break-word;
}

.wartung-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 36px;
}

.meta-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}

.meta-item i {
  color: var(--text-dim);
  font-size: 16px;
  margin-top: 3px;
}

.meta-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
}

.meta-value {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-top: 2px;
  overflow-wrap: break-word;
}

.wartung-section {
  margin-bottom: 36px;
}

.timeline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 18px;
}

.timeline-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-marker {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gray);
  margin-top: 5px;
  flex-shrink: 0;
}

.timeline-marker-start {
  background: var(--gray);
}

.timeline-marker-end {
  background: var(--green);
}

.timeline-body {
  min-width: 0;
}

.timeline-text {
  font-size: 14.5px;
  overflow-wrap: break-word;
}

.timeline-meta {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* Maintenance history */
.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease;
}

.history-row:last-child {
  border-bottom: none;
}

.history-row:hover {
  background: var(--hover);
}

.history-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.history-dot {
  margin-top: 5px;
  background: var(--green);
}

.history-title {
  font-size: 14.5px;
  font-weight: 600;
  overflow-wrap: break-word;
}

.history-sub {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 2px;
  overflow-wrap: break-word;
}

.history-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.history-meta .status-pill {
  margin-bottom: 0;
}

.history-date {
  font-size: 12px;
  color: var(--text-dim);
}

.history-dot-active {
  margin-top: 5px;
  background: #f0a500;
}

.history-empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 18px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

.section-link {
  margin-left: auto;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
}

.section-link:hover {
  color: var(--text);
  text-decoration: underline;
}

/* Sections */
section {
  margin-bottom: 36px;
}

h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

h2 i {
  color: var(--text-dim);
  font-size: 13px;
}

/* Component rows */
.rows {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

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

.row-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.row-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  background: var(--gray);
}

.row.online .row-dot {
  background: var(--green);
}

.row.offline .row-dot {
  background: var(--red);
}

.row-body {
  min-width: 0;
}

.row-name {
  font-size: 15px;
  font-weight: 600;
}

.row-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
  word-break: break-word;
}

.row-error {
  font-size: 13px;
  color: var(--red);
  margin-top: 2px;
  word-break: break-all;
}

.row-meta {
  text-align: right;
  flex-shrink: 0;
}

.row-status {
  font-size: 13px;
  font-weight: 600;
}

.row-status.online {
  color: var(--green);
}

.row-status.offline {
  color: var(--red);
}

.row-status.unknown {
  color: var(--text-dim);
}

.row-stats {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* Uptime bar */
.uptime-bar {
  display: flex;
  gap: 1px;
  margin-top: 10px;
  width: 100%;
}

.upseg {
  flex: 1;
  height: 14px;
  min-width: 2px;
  border-radius: 1px;
  background: var(--border);
}

.upseg.up {
  background: var(--green);
}

.upseg.down {
  background: var(--red);
}

.upseg.nodata {
  background: var(--border);
}

/* Custom tooltip */
[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--tooltip);
  color: var(--tooltip-text);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  padding: 5px 9px;
  border-radius: 5px;
  white-space: nowrap;
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

[data-tooltip]:hover::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--tooltip);
  z-index: 20;
  pointer-events: none;
}

.uptime-bar .upseg:nth-child(-n+8)::after {
  left: 0;
  transform: translateX(0);
}

.uptime-bar .upseg:nth-child(-n+8)::before {
  left: 0;
  transform: translateX(-50%);
}

.uptime-bar .upseg:nth-last-child(-n+8)::after {
  left: 100%;
  transform: translateX(-100%);
}

.uptime-bar .upseg:nth-last-child(-n+8)::before {
  left: calc(100% - 5px);
  transform: translateX(0);
}

/* Footer */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 18px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-dim);
}

.footer-nav {
  display: flex;
  gap: 16px;
}

.footer-nav a,
.cookie-settings {
  color: var(--text-dim);
  text-decoration: none;
}

.footer-nav a:hover,
.cookie-settings:hover {
  color: var(--text);
  text-decoration: underline;
}

.cookie-settings {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
}

.footer-socials {
  display: flex;
  align-items: center;
  gap: 8px;
}

.social {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

a.social:hover {
  color: var(--text);
  background: var(--hover);
}

.social-inactive {
  opacity: 0.4;
  cursor: default;
}

@media (max-width: 640px) {
  main.container {
    padding: 32px 20px 40px;
  }

  .header-inner {
    gap: 10px;
  }

  header {
    padding: 10px 0;
  }

  .theme-toggle {
    order: 2;
    margin-left: auto;
    padding: 8px;
  }

  .nav {
    order: 3;
    width: 100%;
    justify-content: space-between;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 12px;
    margin-top: 4px;
    padding: 10px 0 2px;
    border-top: 1px solid var(--border);
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav a {
    font-size: 13px;
    padding: 4px 0;
  }

  .hero-text h1 {
    font-size: 22px;
  }

  .row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .row-meta {
    text-align: left;
  }

  .upseg {
    height: 16px;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-nav {
    flex-wrap: wrap;
    gap: 10px 16px;
  }

  .footer-socials {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }

  .cookie-banner {
    padding: 0;
  }

  .cookie-banner-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    max-width: 100%;
    padding: 16px 18px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
  }

  .cookie-actions {
    flex-direction: column;
    width: 100%;
  }

  .cookie-btn {
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 11px 18px;
  }

  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content {
    max-height: 90vh;
    border-radius: 18px 18px 0 0;
    padding: 24px 18px;
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 400px) {
  .container {
    padding: 0 16px;
  }

  .row {
    padding: 12px 14px;
  }

  .hero {
    margin-bottom: 28px;
  }

  .modal-content {
    padding: 22px 16px;
  }
}

@media (hover: none) {
  [data-tooltip]::after,
  [data-tooltip]::before {
    display: none;
  }
}

/* Cookie banner */
.cookie-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  padding: 16px 24px 22px;
  display: flex;
  justify-content: center;
  pointer-events: none;
  animation: cookieSlideUp 0.4s ease;
}

.cookie-banner-inner {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 780px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.18);
}

.cookie-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.cookie-text {
  flex: 1;
  min-width: 0;
}

.cookie-text strong {
  display: block;
  font-size: 14.5px;
  color: var(--text);
  margin-bottom: 2px;
}

.cookie-text p {
  font-size: 13px;
  color: var(--text-dim);
}

.cookie-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.cookie-btn {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cookie-btn-primary {
  background: var(--green);
  color: #ffffff;
  border: 1px solid var(--green);
}

.cookie-btn-primary:hover {
  filter: brightness(1.06);
}

.cookie-btn-ghost {
  color: var(--text-dim);
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
}

.cookie-btn-ghost:hover {
  background: var(--hover);
  color: var(--text);
}

/* Settings (modal) */
.settings-intro {
  font-size: 14px;
  color: var(--text-dim);
  max-width: 720px;
}

.settings-section {
  margin-top: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
}

.settings-section h2 {
  margin-bottom: 14px;
}

.cookie-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cookie-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.cookie-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.cookie-item-head strong {
  font-size: 14px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.cookie-item p {
  font-size: 13px;
  color: var(--text-dim);
}

.cookie-item code {
  font-size: 12px;
  background: var(--hover);
  padding: 1px 5px;
  border-radius: 4px;
}

.cookie-meta {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.8;
}

.cookie-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.cookie-tag-required {
  color: var(--text-dim);
  background: var(--hover);
  border: 1px solid var(--border);
}

.cookie-tag-optional {
  color: var(--green);
  background: color-mix(in srgb, var(--green) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 40%, transparent);
}

.stats-list {
  list-style: none;
  margin: 14px 0 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stats-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.stats-list li i {
  width: 18px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.stats-note {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 12px;
  max-width: 720px;
}

.settings-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Error page */
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.error-box {
  text-align: center;
  padding: 48px 0;
}

.error-code {
  font-size: 72px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
  opacity: 0.25;
}

.error-box h1 {
  font-size: 24px;
  margin: 10px 0 6px;
}

.error-box p {
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: 24px;
}

/* Cookie settings modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 640px;
  max-height: 86vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-content > h2 {
  font-size: 20px;
  margin-bottom: 6px;
}

.modal-content .settings-section {
  margin-top: 20px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.modal-close:hover {
  color: var(--text);
  background: var(--hover);
}

@keyframes cookieSlideUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
