* { box-sizing: border-box; }

:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-soft: #fbfbfc;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --text: #17181c;
  --muted: #7a7f8c;
  --green: #16a34a;
  --yellow: #f59e0b;
  --red: #dc2626;
  --empty: #d8dde6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 12px 30px rgba(16, 24, 40, .07);
  --radius: 10px;
  --radius-sm: 8px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.page-shell {
  width: min(800px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.headline-card,
.status-card,
.subscribe-panel,
.admin-panel {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.headline-card {
  min-height: 96px;
  margin-bottom: 28px;
  padding: 24px 28px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfbfc 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logout-form {
  margin: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.1; letter-spacing: -.02em; }
h2 { font-size: 20px; line-height: 1.2; }

.admin-link,
.subscribe-form button,
.admin-form button,
.logout-form button,
.telegram-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.admin-link:hover,
.subscribe-form button:hover,
.admin-form button:hover,
.logout-form button:hover,
.telegram-link:hover {
  background: var(--panel-soft);
  border-color: #b8c0cc;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}

.login-shell {
  width: min(800px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 36px 0;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-heading {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.login-heading h1 {
  font-size: 28px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 650;
}

.login-form label span {
  font-size: 14px;
}

.login-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.login-form input:focus {
  outline: 2px solid #344054;
  outline-offset: 1px;
}

.login-form button {
  min-height: 42px;
  border: 1px solid #17181c;
  border-radius: var(--radius-sm);
  background: #17181c;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.login-form button:hover {
  background: #2b2d33;
  border-color: #2b2d33;
}

.login-error {
  margin-top: 18px;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  background: #fff5f5;
  color: var(--red);
  font-weight: 650;
}

.login-back {
  display: inline-flex;
  margin-top: 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.login-back:hover {
  color: var(--text);
  text-decoration: underline;
}

.status-card {
  overflow: hidden;
}

.status-card__header {
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.date-range {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 18px;
}

.date-range span {
  color: #c7cbd3;
  font-size: 34px;
  line-height: 1;
}

.date-range strong {
  font-weight: 450;
}

.component-row {
  padding: 22px 20px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.component-row:last-child {
  border-bottom: 0;
}

.component-row:hover {
  background: #fcfcfd;
}

.component-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.component-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.component-left strong {
  font-size: 18px;
  line-height: 1.1;
  white-space: nowrap;
}

.check-badge {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.check-badge.ok { background: var(--green); }
.check-badge.bad { background: var(--red); }
.check-badge.unknown { background: #a7adb8; }

.info-badge {
  width: 17px;
  height: 17px;
  border: 1px solid #aeb3bd;
  border-radius: 50%;
  color: #a1a6b1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.component-count,
.chevron,
.uptime-percent {
  color: var(--muted);
  font-size: 17px;
}

.chevron {
  font-size: 24px;
  line-height: 1;
  color: #a6abb5;
}

.uptime-percent {
  flex: none;
  white-space: nowrap;
}

.history-strip {
  display: grid;
  grid-template-columns: repeat(90, 1fr);
  gap: 3px;
  height: 18px;
}

.history-bar {
  appearance: none;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--green);
  cursor: pointer;
}

.history-bar.ok { background: var(--green); }
.history-bar.warn { background: var(--yellow); }
.history-bar.bad { background: var(--red); }
.history-bar.empty { background: var(--empty); }
.history-bar:hover,
.history-bar.is-selected {
  outline: 2px solid #344054;
  outline-offset: 1px;
}

.history-detail {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--text);
  font-size: 14px;
}

.detail-header span,
.detail-loading {
  color: var(--muted);
  font-size: 13px;
}

.hour-grid,
.minute-grid {
  display: grid;
  gap: 4px;
}

.hour-grid {
  grid-template-columns: repeat(24, 1fr);
  height: 28px;
}

.minute-header {
  margin-top: 18px;
}

.minute-grid {
  grid-template-columns: repeat(60, 1fr);
  height: 18px;
}

.subscribe-panel {
  margin-top: 28px;
  padding: 18px;
  display: grid;
  gap: 14px;
  background: #fff;
}

.subscribe-form {
  display: grid;
  grid-template-columns: 1fr 230px auto;
  gap: 12px;
  align-items: center;
}

.subscribe-form div {
  display: grid;
  gap: 2px;
}

.subscribe-form span,
.muted {
  color: var(--muted);
  font-size: 14px;
}

.subscribe-form input,
.admin-form input,
.admin-form select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

.telegram-link {
  justify-self: start;
}

.history-cta {
  margin-top: 28px;
  display: flex;
  justify-content: center;
}

.page-footer {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 24px;
}

.admin-panel {
  padding: 20px;
  background: #fff;
}

.admin-panel h2 {
  margin-bottom: 16px;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-form button {
  justify-self: start;
}

.admin-card {
  margin-top: 20px;
}

.admin-table {
  display: grid;
}

.admin-table > div {
  display: grid;
  grid-template-columns: 1fr 110px 1.6fr;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.admin-table > div:last-child { border-bottom: 0; }
.admin-table span { color: var(--muted); overflow-wrap: anywhere; }
.admin-table p { padding: 18px 20px; }
.admin-note { margin-top: 12px; }

.history-shell {
  padding-top: 26px;
}

.history-rule {
  height: 1px;
  background: var(--line);
  margin-bottom: 52px;
}

.history-crumb {
  margin-bottom: 54px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #666b76;
  font-size: 25px;
  line-height: 1.2;
}

.history-crumb a {
  color: #666b76;
  text-decoration: none;
}

.history-crumb strong {
  color: var(--text);
  font-weight: 500;
}

.history-titlebar {
  min-height: 70px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.history-titlebar h1 {
  font-size: 28px;
  line-height: 1.15;
}

.history-list {
  padding-top: 44px;
}

.history-month {
  margin-bottom: 40px;
}

.history-month > h2 {
  margin-bottom: 36px;
  font-size: 27px;
}

.history-entry {
  display: grid;
  grid-template-columns: 88px 8px minmax(0, 1fr) 70px;
  gap: 24px;
  min-height: 132px;
  padding: 0 0 34px;
  border-bottom: 1px solid var(--line);
}

.history-entry-link {
  color: inherit;
  text-decoration: none;
}

.history-entry-link:hover .history-copy h3 {
  text-decoration: underline;
}

.history-entry + .history-entry {
  padding-top: 34px;
}

.history-date {
  min-height: 88px;
  display: grid;
  grid-template-columns: 42px 28px;
  align-items: start;
  gap: 8px;
}

.history-date strong {
  display: grid;
  color: var(--text);
  font-size: 25px;
  line-height: 1.05;
}

.history-date strong span {
  font-weight: 450;
}

.history-date em {
  color: var(--muted);
  font-size: 20px;
  font-style: normal;
  font-weight: 650;
  line-height: 1.25;
  writing-mode: vertical-rl;
}

.history-marker {
  width: 7px;
  height: 88px;
  border-radius: 999px;
  background: var(--green);
}

.history-marker.warn { background: var(--yellow); }
.history-marker.bad { background: var(--red); }

.history-copy {
  min-width: 0;
}

.history-copy h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 25px;
  line-height: 1.2;
  font-weight: 650;
}

.history-copy p {
  color: var(--muted);
  font-size: 24px;
  line-height: 1.35;
}

.history-entry time {
  color: var(--muted);
  font-size: 22px;
  line-height: 1.4;
  text-align: right;
}

.history-empty {
  padding: 28px 0 54px;
  border-bottom: 1px solid var(--line);
}

.history-empty h2 {
  margin-bottom: 8px;
  font-size: 25px;
}

.history-empty p {
  color: var(--muted);
  font-size: 20px;
}

.incident-shell {
  padding-top: 28px;
}

.incident-top {
  margin-bottom: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-link {
  color: var(--text);
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
}

.subscribe-button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 18px;
  background: #24262d;
  color: #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 20px rgba(36, 38, 45, .18);
  text-decoration: none;
  font-weight: 650;
}

.incident-summary-card,
.incident-card {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.incident-summary-card {
  margin-bottom: 28px;
}

.incident-summary-card.ok { border-color: var(--green); }
.incident-summary-card.warn { border-color: var(--yellow); }
.incident-summary-card.bad { border-color: var(--red); }

.incident-summary-title {
  min-height: 82px;
  padding: 22px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.incident-summary-card.ok .incident-summary-title { background: #ecfdf5; }
.incident-summary-card.warn .incident-summary-title { background: #fffbeb; }
.incident-summary-card.bad .incident-summary-title { background: #fef2f2; }

.incident-summary-title a {
  color: var(--muted);
  font-size: 38px;
  line-height: 1;
  text-decoration: none;
}

.incident-summary-title h1 {
  font-size: 27px;
  line-height: 1.2;
}

.incident-meta {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 22px;
}

.incident-message {
  padding: 24px 22px;
}

.incident-message p {
  margin-bottom: 18px;
  font-size: 20px;
}

.incident-message span,
.incident-message a {
  color: var(--muted);
  font-size: 18px;
}

.incident-card {
  margin-top: 28px;
}

.incident-card > header {
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.incident-card > header h2 {
  font-size: 24px;
}

.affected-timeline {
  padding: 18px 22px 22px;
}

.timeline-times {
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 16px;
}

.affected-name {
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.affected-name strong {
  font-size: 20px;
}

.affected-name span {
  color: var(--muted);
  font-size: 18px;
}

.affected-bars {
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  gap: 4px;
  height: 24px;
}

.affected-bars span {
  background: var(--green);
  border-radius: 3px;
}

.affected-bars.warn span:nth-child(2) { background: var(--yellow); }
.affected-bars.bad span:nth-child(2) { background: var(--red); }

.updates-list {
  padding: 26px 22px 34px;
}

.update-item {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 18px;
  padding-bottom: 38px;
}

.update-item:last-child {
  padding-bottom: 0;
}

.update-item::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 20px;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.update-item:last-child::before {
  display: none;
}

.update-dot {
  width: 10px;
  height: 10px;
  margin-top: 8px;
  background: var(--green);
}

.update-item.warn .update-dot { background: var(--yellow); }
.update-item.bad .update-dot { background: var(--red); }

.update-item h3 {
  margin: 0 0 16px;
  font-size: 22px;
}

.update-item p {
  margin-bottom: 18px;
  font-size: 20px;
}

.update-item time {
  color: var(--muted);
  font-size: 18px;
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 800px);
    padding-top: 18px;
  }

  .headline-card,
  .status-card__header,
  .component-top,
  .page-footer,
  .history-titlebar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .component-left {
    flex-wrap: wrap;
  }

  .uptime-percent {
    align-self: flex-end;
  }

  .history-strip {
    gap: 2px;
  }

  .subscribe-form,
  .admin-form,
  .admin-table > div {
    grid-template-columns: 1fr;
  }

  .history-rule {
    margin-bottom: 34px;
  }

  .history-crumb {
    margin-bottom: 38px;
    font-size: 22px;
  }

  .history-entry {
    grid-template-columns: 58px 7px minmax(0, 1fr);
    gap: 16px;
    min-height: 120px;
  }

  .history-entry time {
    grid-column: 3;
    text-align: left;
    font-size: 16px;
  }

  .history-date {
    grid-template-columns: 30px 22px;
    gap: 6px;
  }

  .history-date strong {
    font-size: 22px;
  }

  .history-date em {
    font-size: 17px;
  }

  .history-copy h3 {
    font-size: 20px;
  }

  .history-copy p {
    font-size: 18px;
  }

  .incident-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .affected-bars {
    grid-template-columns: 56px 1fr 56px;
  }
}
