:root {
    --page-bg: #f1f8ff; /* Тот самый фирменный голубой с vdc.ru */
    --surface: #ffffff; /* Карточки оставляем белыми, чтобы они «сияли» на голубом */
    --border: #e1e9f1; /* Границы чуть голубоватыми, чтобы не грязнить фон */
    --border-subtle: #e5e7eb;
    --text: #0f172a;
    --muted: #475569;
    --muted2: #64748b;
    --ok: #059669;
    --ok-bg: #ecfdf5;
    --warn: #d97706;
    --warn-bg: #fef3c7;
    --avg-bg: #ffedd5;
    --high-bg: #fee2e2;
    --down: #b91c1c;
    --down-bg: #fee2e2;
    /* Пульс: «норма» = спокойный зелёный (как у GitHub / SaaS), не «пустой» серый */
    --heat-clear: #dcfce7;
    --heat-l4: #fbbf24;
    --heat-l5: #ef4444;
    --timeline-line: #d1d5db;
    --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.06);
    --radius: 12px;
    --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--page-bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--ok); text-underline-offset: 2px; }
a:hover { color: #047857; }
.shell { max-width: 42rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
@media (min-width: 640px) { .shell { padding: 2rem 1.5rem 4rem; max-width: 48rem; } }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    flex-wrap: wrap;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.topbar__left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1 1 12rem;
}
.topbar img { max-height: 2rem; width: auto; display: block; flex-shrink: 0; }
.topbar__titles { min-width: 0; }
.topbar__brand { font-weight: 600; font-size: 0.9375rem; letter-spacing: -0.01em; line-height: 1.25; }
.topbar__tabs {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex-shrink: 0;
}
@media (max-width: 520px) {
    .topbar__tabs { flex-basis: 100%; justify-content: flex-start; }
}
.tab {
    appearance: none;
    border: none;
    background: transparent;
    padding: 0.4rem 0.65rem;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    border-radius: 6px;
    white-space: nowrap;
}
.tab:hover { color: var(--text); background: rgba(0,0,0,0.04); }
.tab[aria-selected="true"] {
    color: var(--text);
    font-weight: 600;
    background: var(--border-subtle);
    box-shadow: inset 0 0 0 1px var(--border);
}
.tab-panel.is-hidden { display: none !important; }

.hero { margin-bottom: 1.75rem; }
.hero h1 {
    margin: 0 0 0.75rem;
    font-size: clamp(1.5rem, 4vw, 1.875rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--text);
}
.hero--warn h1 { color: #c2410c; }
.hero--high h1 { color: #ea580c; }
.hero--down h1 { color: var(--down); }
.hero .meta {
    margin: 0;
    font-size: 0.875rem;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.hero .meta-sep { color: var(--border); user-select: none; }
.hero .meta--sub { margin-top: 0.35rem; font-size: 0.8125rem; color: var(--muted2); }

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: 0.01em;
}
.pill--ok { background: var(--ok-bg); color: #065f46; }
.pill--info { background: #f3f4f6; color: #374151; }
.pill--minor { background: #eef2ff; color: #3730a3; }
.pill--warn { background: var(--warn-bg); color: #c2410c; }
.pill--avg { background: var(--avg-bg); color: #9a3412; }
.pill--high { background: var(--high-bg); color: #991b1b; }
.pill--down { background: var(--down-bg); color: #7f1d1d; }

.metric-strip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}
.metric-strip__label { font-size: 0.8125rem; color: var(--muted); }
.uptime-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 1.125rem;
}
.uptime-value--high { color: var(--ok); }
.uptime-value--mid { color: var(--warn); }
.uptime-value--low { color: #dc2626; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    margin-bottom: 1.5rem;
    overflow: hidden;
}
/* История и пульс на обзоре: тултип не обрезается overflow панели */
#history-block.panel,
#overview-pulse-panel.panel {
    overflow: visible;
}
.panel__head {
    padding: 0.65rem 1.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.panel__head--history-title {
    text-transform: none;
    letter-spacing: 0.02em;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
}
.panel__body--flush { padding: 0; }
#history-container.panel__body--flush {
    overflow: visible;
}

.service-card {
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background 0.15s ease;
}
.service-card:last-child { border-bottom: none; }
.service-card:hover { background: #f8fafc; }
.service-card__row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.25rem;
}
.service-card__title { font-weight: 600; font-size: 0.9375rem; letter-spacing: -0.01em; }
.service-card__aside { flex-shrink: 0; }

.status-details {
    display: none;
    padding: 0.85rem 1.25rem 1rem;
    font-size: 0.875rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
    background: #f8fafc;
}
.status-details__lead {
    margin: 0 0 0.5rem;
    line-height: 1.45;
}
.status-details__ok {
    margin: 0;
    line-height: 1.45;
}
.status-details ul { list-style: none; margin: 0; padding: 0; }
.status-details li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.5rem;
    border-left-width: 3px;
}
.status-details li:last-child { margin-bottom: 0; }
.status-details li strong { color: var(--text); }

.uptime-group-block { padding: 1rem 1.25rem 1.25rem; }
.uptime-group-block h3 {
    margin: 0 0 0.75rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
}
.uptime-group-block .footnote {
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.45;
    margin-top: 1rem;
}
.uptime-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.65rem; }
.uptime-item {
    background: var(--border-subtle);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    text-align: center;
}
.uptime-item span:first-child { font-size: 0.75rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: 0.2rem; }
.uptime-percent { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }

/* —— История инцидентов: пульс + таймлайн —— */
.history-pulse {
    position: relative;
    z-index: 1;
    overflow: visible;
    padding: 1rem 1.25rem 0.85rem;
    border-bottom: 1px solid var(--border);
}
.history-pulse--overview {
    border-bottom: none;
}
.history-heatmap {
    display: grid;
    width: 100%;
    gap: 4px;
    grid-template-columns: repeat(var(--history-cols, 30), minmax(0, 1fr));
    list-style: none;
    margin: 0 0 0.65rem;
    padding: 0.25rem 0 0;
    box-sizing: border-box;
    overflow: visible;
}
.history-heatmap__cell {
    position: relative;
    min-height: 40px;
    border-radius: 4px;
    box-sizing: border-box;
    border: 1px solid #fff;
    min-width: 0;
    cursor: default;
    outline: none;
    overflow: visible;
}
.history-heatmap__cell:focus-visible {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ok);
}
.history-heatmap__cell--clear { background: var(--heat-clear); }
.history-heatmap__cell--l4 { background: var(--heat-l4); }
.history-heatmap__cell--l5 { background: var(--heat-l5); }
.history-heatmap__cell[data-tip]:hover::after,
.history-heatmap__cell[data-tip]:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    z-index: 200;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 12.5rem;
    max-width: min(12.5rem, calc(100vw - 2rem));
    padding: 0.45rem 0.6rem;
    font-size: 0.6875rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
    pointer-events: none;
}
/* Края сетки: тултип не уезжает за вьюпорт и не режется по горизонтали */
.history-heatmap__cell--tip-start[data-tip]:hover::after,
.history-heatmap__cell--tip-start[data-tip]:focus-visible::after {
    left: 0;
    transform: translateX(0);
}
.history-heatmap__cell--tip-end[data-tip]:hover::after,
.history-heatmap__cell--tip-end[data-tip]:focus-visible::after {
    left: auto;
    right: 0;
    transform: translateX(0);
}
.history-heatmap-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.1rem;
    font-size: 0.6875rem;
    color: var(--muted2);
    margin: 0;
}
.history-heatmap-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.history-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.history-legend-dot--clear { background: var(--heat-clear); }
.history-legend-dot--l4 { background: var(--heat-l4); border-color: rgba(180, 83, 9, 0.35); }
.history-legend-dot--l5 { background: var(--heat-l5); border-color: rgba(220, 38, 38, 0.45); }

.history-open-block {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}
.history-open-block__label {
    margin: 0 0 0.65rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.history-open-block__cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-empty-state {
    text-align: center;
    padding: 2.25rem 1.5rem 2.5rem;
    margin: 0 0.5rem 0.5rem;
}
.history-empty-state__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--ok-bg);
    color: var(--ok);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}
.history-empty-state__title {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
    max-width: 22rem;
    margin-left: auto;
    margin-right: auto;
}
.history-empty-state__note {
    margin: 0;
    font-size: 0.875rem;
    color: var(--muted);
    line-height: 1.5;
    max-width: 24rem;
    margin-left: auto;
    margin-right: auto;
}

.history-timeline {
    padding: 0.25rem 0 0.5rem;
    margin: 0 1.25rem;
    border-left: 2px solid var(--timeline-line);
}
.history-tl-row {
    position: relative;
    padding: 0 0 1.25rem 1.15rem;
    margin-left: -1px;
}
.history-tl-row:last-child { padding-bottom: 0.75rem; }
.history-tl-axis {
    position: absolute;
    left: -7px;
    top: 0.35rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border);
    box-sizing: border-box;
}
.history-tl-row--calm .history-tl-axis {
    border-color: #a7f3d0;
    background: var(--ok-bg);
}
.history-tl-row--incident .history-tl-axis {
    border-color: var(--border);
    background: var(--muted2);
}
.history-tl-row--note .history-tl-axis {
    border-color: #fed7aa;
    background: #fff7ed;
}
.history-tl-body { min-width: 0; }
.history-tl-date {
    display: block;
    font-size: 0.8125rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}
.history-tl-calm {
    font-size: 0.9375rem;
    color: var(--text);
    font-weight: 500;
}
.history-tl-calm-ic {
    color: var(--ok);
    margin-right: 0.25rem;
    font-weight: 700;
}
.history-tl-dayline {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem 1rem;
    margin-bottom: 0.65rem;
}
.history-tl-dayline .history-tl-date {
    display: inline;
    margin: 0;
    font-weight: 600;
    color: var(--text);
}
.history-tl-uptime {
    font-size: 0.8125rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.history-tl-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.history-tl-note {
    margin: 0.15rem 0 0;
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.45;
}

.history-inc {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    padding: 1rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-card);
}
.history-inc--active {
    border-color: #fcd34d;
    background: #fffbeb;
}
.history-inc__badge {
    flex-shrink: 0;
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    line-height: 1.25;
    max-width: 11rem;
    text-align: center;
}
.history-inc__body { min-width: 0; flex: 1; }
.history-inc__title {
    margin: 0 0 0.35rem;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    letter-spacing: -0.02em;
}
.history-inc__timing {
    margin: 0 0 0.4rem;
    font-size: 0.8125rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.history-inc__dur { color: var(--muted2); font-weight: 500; }
.history-inc__meta {
    margin: 0 0 0.45rem;
    font-size: 0.8125rem;
    color: var(--muted2);
    line-height: 1.4;
}
.history-inc__pill {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.02em;
}
@media (max-width: 520px) {
    .history-inc { flex-direction: column; }
    .history-inc__badge { align-self: flex-start; }
}
.severity-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--muted2);
}
.empty-hint { padding: 1.25rem; color: var(--muted); font-size: 0.875rem; margin: 0; }
.empty-hint--pulse { padding: 1rem 1.25rem 1.1rem; }
