:root {
  color-scheme: dark;
  --bg: #0c1118;
  --bg-2: #111822;
  --surface: #141b24;
  --surface-2: #18222f;
  --border: #2a3544;
  --text: #e7eef8;
  --muted: #93a7be;
  --success: #20c997;
  --danger: #dc3545;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
}

body.bg-app {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(32, 201, 151, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(13, 110, 253, 0.08), transparent 26%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.bg-app-2,
.card,
.list-group-item,
.alert,
.service-mini,
.service-collapse,
.badge,
.btn,
input,
select,
textarea,
.history-row {
  border-radius: 0 !important;
}

a {
  color: inherit;
}

.text-secondary,
.text-secondary-emphasis,
small {
  color: var(--muted) !important;
}

.card,
.list-group-item,
.alert,
.service-mini,
.service-collapse {
  background-color: var(--surface);
  border-color: var(--border) !important;
}

.btn {
  box-shadow: none !important;
}

.btn-link {
  text-decoration: none;
}

.btn-link:hover {
  text-decoration: none;
}

.service-list {
  background: transparent;
}

.service-row + .service-row {
  margin-top: 0;
}

.service-row {
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.service-row.dragging {
  opacity: 0.55;
  transform: scale(0.995);
}

.service-row.drag-over {
  border-color: rgba(32, 201, 151, 0.7) !important;
  background-color: rgba(32, 201, 151, 0.08);
}

.service-toggle {
  text-align: left;
  border: 0;
  background: transparent;
}

.service-toggle:focus,
.service-toggle:active {
  box-shadow: none !important;
}

.drag-handle {
  flex: 0 0 auto;
  width: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  line-height: 1;
  cursor: grab;
  user-select: none;
  border-color: var(--border);
  background: var(--surface-2);
}

.drag-handle:active {
  cursor: grabbing;
}

.service-icon-wrap {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
}

.service-icon {
  display: block;
  width: 100%;
  height: 100%;
}

.service-subtitle {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.service-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.service-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
}

.status-vignette {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1px solid transparent;
}

.status-ok {
  background: var(--success);
  border-color: rgba(255, 255, 255, 0.08);
}

.status-down,
.status-unknown,
.status-warning {
  background: var(--danger);
  border-color: rgba(255, 255, 255, 0.08);
}

.status-pill {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.5rem;
}

.service-collapse {
  background: var(--bg-2);
}

.service-mini {
  border: 1px solid var(--border);
  padding: 0.9rem 1rem;
  display: grid;
  gap: 0.25rem;
  height: 100%;
}

.service-mini span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.service-mini strong {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.chart-card {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.chart-title {
  margin: 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-subtitle {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.chart-footer {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-background {
  fill: var(--surface-2);
}

.chart-grid-line {
  stroke: rgba(147, 167, 190, 0.18);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart-axis {
  stroke: rgba(231, 238, 248, 0.3);
  stroke-width: 1.25;
  shape-rendering: crispEdges;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.chart-axis-label-left {
  text-anchor: end;
}

.chart-axis-label-center {
  text-anchor: middle;
}

.chart-value {
  fill: var(--text);
  font-size: 11px;
  text-anchor: middle;
}

.chart-bar {
  rx: 0;
  ry: 0;
}

.chart-bar-high {
  fill: url(#uptimeFill);
}

.chart-bar-mid {
  fill: #7dcf88;
}

.chart-bar-low {
  fill: #20c997;
}

.chart-bar-missing {
  fill: rgba(147, 167, 190, 0.22);
  stroke: rgba(147, 167, 190, 0.25);
  stroke-dasharray: 4 3;
}

.chart-line {
  fill: none;
  stroke: #0d6efd;
  stroke-width: 3;
  stroke-linejoin: miter;
  stroke-linecap: square;
}

.chart-point {
  fill: #dbeafe;
  stroke: #0d6efd;
  stroke-width: 2;
}

.chart-empty {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  color: var(--muted);
  background: var(--surface-2);
  text-align: center;
  padding: 1rem;
}

.history {
  display: grid;
  gap: 0.5rem;
}

.history-row {
  display: grid;
  grid-template-columns: 88px 90px 190px 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.history-row strong {
  font-weight: 700;
}

.status-ok .history-row,
.history-row.status-ok {
  border-color: rgba(32, 201, 151, 0.35);
}

.status-down .history-row,
.history-row.status-down,
.status-warning .history-row,
.history-row.status-warning,
.status-unknown .history-row,
.history-row.status-unknown {
  border-color: rgba(220, 53, 69, 0.35);
}

.form {
  max-width: 840px;
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.4rem;
}

input,
select,
textarea {
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}

input:focus,
select:focus,
textarea:focus {
  box-shadow: 0 0 0 0.2rem rgba(32, 201, 151, 0.15) !important;
  border-color: rgba(32, 201, 151, 0.5) !important;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox input {
  width: auto;
}

.empty {
  text-align: center;
}

@media (max-width: 768px) {
  .history-row {
    grid-template-columns: 1fr;
  }

  .service-toggle .d-flex {
    flex-direction: column;
    align-items: stretch !important;
  }

  .service-toggle .text-end {
    text-align: left !important;
  }
}
