:root {
  --paper: #f2f0ea;
  --surface: #ffffff;
  --surface-soft: #f8f6f0;
  --ink: #3f3c38;
  --muted: #6f665b;
  --line: #e5dfd3;
  --gold: #a78955;
  --gold-dark: #80663e;
  --green: #52695c;
  --green-soft: #e6eee6;
  --red: #9d4e43;
  --red-soft: #f3e4e1;
  --blue: #566a78;
  --blue-soft: #e5edf0;
  --shadow: 0 24px 60px rgba(49, 45, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.75), rgba(242, 240, 234, 0.65)),
    var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 42px;
}

.narrow {
  width: min(520px, calc(100% - 32px));
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.hero {
  position: relative;
  overflow: hidden;
  min-height: 430px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 255, 255, 0.9) 48%, rgba(248, 246, 240, 0.78) 100%),
    url("/assets/logo.png") right -80px center / min(48vw, 560px) no-repeat;
  box-shadow: var(--shadow);
}

.topbar,
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}

.brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(63, 60, 56, 0.18));
}

.brand span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  font-size: 13px;
}

.admin-link,
.ghost-button,
.button,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.admin-link,
.ghost-button {
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--line);
  color: var(--ink);
}

.admin-link:hover,
.ghost-button:hover,
.mini-button:hover,
.button:hover {
  transform: translateY(-1px);
}

.button {
  padding: 0 18px;
  background: var(--gold);
  color: #fff;
  font-weight: 700;
}

.button:hover {
  background: var(--gold-dark);
}

.button.full {
  width: 100%;
}

.hero-copy {
  max-width: 650px;
  min-width: 0;
  padding: 84px 0 34px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  overflow-wrap: break-word;
}

h1 {
  font-size: clamp(40px, 7vw, 78px);
  line-height: 0.95;
}

h2 {
  font-size: 31px;
  line-height: 1.12;
}

h3 {
  font-size: 24px;
  line-height: 1.14;
}

.hero-copy p:last-child {
  max-width: 580px;
  margin: 18px 0 0;
  color: #514d48;
  font-size: 18px;
  line-height: 1.6;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.stat span,
.metric span,
td span,
.muted,
.timestamp {
  color: var(--muted);
}

.stat span {
  display: block;
  min-height: 34px;
  font-size: 13px;
  line-height: 1.25;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
}

.stat.good strong {
  color: var(--green);
}

.stat.warn strong {
  color: var(--blue);
}

.stat.bad strong {
  color: var(--red);
}

.section-shell {
  margin-top: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.section-heading .muted {
  margin: 0;
  text-align: right;
}

.section-side {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.filter-result {
  margin: 0;
  color: var(--gold-dark);
  font-size: 13px;
  font-weight: 700;
}

.service-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -6px 0 22px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.filter-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

button.filter-option {
  padding: 0 14px;
}

label.filter-option {
  padding: 0;
}

.filter-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.filter-option span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
}

.filter-option b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 12px;
}

.filter-option:hover {
  transform: translateY(-1px);
  border-color: #d3c7b5;
}

.filter-option.active,
.filter-option:has(input:checked) {
  border-color: rgba(167, 137, 85, 0.55);
  background: #efe8db;
  color: var(--ink);
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.service-card,
.panel,
.login-panel,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.service-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 320px;
  padding: 18px;
  border-top: 4px solid var(--muted);
}

.service-card.online {
  border-top-color: var(--green);
}

.service-card.degraded {
  border-top-color: var(--blue);
}

.service-card.offline {
  border-top-color: var(--red);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex: 0 0 215px;
  min-width: 0;
}

.protocol {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 700;
}

.card-top h3 {
  overflow-wrap: anywhere;
}

.card-top p {
  margin: 8px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.vhost {
  display: block;
  margin-top: 4px;
  color: var(--gold-dark);
  font-size: 13px;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: start;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.status-pill i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.status-pill.online {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.degraded,
.status-pill.unknown {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-pill.offline {
  background: var(--red-soft);
  color: var(--red);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.metric span {
  display: block;
  min-height: 18px;
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 22px;
}

.service-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
  line-height: 1.35;
}

.sparkline {
  display: flex;
  align-items: end;
  gap: 4px;
  flex: 0 0 58px;
  margin-top: auto;
  width: 100%;
  height: 58px;
  padding-top: 4px;
  border-bottom: 1px solid var(--line);
}

.bar {
  flex: 1;
  min-width: 3px;
  max-height: 100%;
  border-radius: 3px 3px 0 0;
  background: var(--muted);
}

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

.bar.degraded,
.bar.unknown,
.bar.idle {
  background: var(--blue);
}

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

.timestamp {
  margin: 0;
  font-size: 13px;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 28px;
  min-height: 230px;
}

.empty-state p:last-of-type {
  max-width: 540px;
  color: var(--muted);
  line-height: 1.55;
}

.admin-page {
  width: min(1120px, calc(100% - 32px));
}

.admin-header {
  margin-bottom: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.admin-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
}

.panel,
.login-panel {
  padding: 24px;
  box-shadow: 0 18px 40px rgba(49, 45, 39, 0.08);
}

.login-panel {
  width: 100%;
}

.login-brand {
  margin-bottom: 34px;
}

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

.xmpp-shell {
  margin-top: 16px;
}

.xmpp-form {
  display: grid;
  gap: 16px;
}

.toggle-line,
.rule-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
}

.toggle-line input,
.rule-toggle input {
  width: 22px;
  height: 22px;
  min-height: 0;
  flex: 0 0 22px;
  accent-color: var(--gold);
}

.toggle-line span,
.rule-toggle span {
  display: grid;
  gap: 4px;
}

.toggle-line strong,
.rule-toggle strong {
  font-size: 15px;
}

.toggle-line small,
.rule-toggle small {
  color: var(--muted);
  font-weight: 400;
  line-height: 1.35;
}

.notification-rules {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.rule-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rule-card .rule-toggle {
  padding: 0;
  border: 0;
  background: transparent;
}

.rule-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.rule-fields label:only-child {
  grid-column: 1 / -1;
}

.unit-input {
  display: flex;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.unit-input input {
  min-height: 44px;
  border: 0;
  border-radius: 0;
}

.unit-input input:focus {
  box-shadow: none;
}

.unit-input em {
  padding: 0 12px;
  color: var(--muted);
  font-style: normal;
  font-weight: 700;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

input:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(167, 137, 85, 0.16);
}

.text-link {
  display: inline-flex;
  margin-top: 20px;
  color: var(--gold-dark);
  font-weight: 700;
}

.flash {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 8px;
  font-weight: 700;
}

.flash.notice {
  background: var(--green-soft);
  color: var(--green);
}

.flash.error {
  background: var(--red-soft);
  color: var(--red);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td strong,
td span {
  display: block;
}

td span {
  margin-top: 4px;
  font-size: 12px;
}

tr:last-child td {
  border-bottom: 0;
}

.actions {
  display: flex;
  gap: 8px;
}

.actions form {
  margin: 0;
}

.mini-button {
  min-height: 34px;
  padding: 0 10px;
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.mini-button.danger {
  color: var(--red);
}

@media (max-width: 980px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .services-grid,
  .admin-grid,
  .notification-rules {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .page,
  .admin-page,
  .narrow {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .hero {
    min-height: auto;
    padding: 18px;
    background:
      linear-gradient(115deg, rgba(255, 255, 255, 0.96), rgba(248, 246, 240, 0.9)),
      url("/assets/logo.png") right -95px top 82px / 310px no-repeat;
  }

  .topbar,
  .admin-header,
  .section-heading,
  .card-top {
    align-items: stretch;
    flex-direction: column;
  }

  .card-top {
    flex: 0 1 auto;
  }

  .admin-link,
  .ghost-button {
    width: 100%;
  }

  .hero-copy {
    padding: 56px 0 24px;
  }

  h1 {
    font-size: 38px;
    line-height: 1.04;
  }

  h2 {
    font-size: 27px;
  }

  .hero-copy p:last-child {
    max-width: 100%;
    font-size: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .section-shell,
  .panel,
  .login-panel,
  .empty-state {
    padding: 18px;
  }

  .metrics,
  .form-row {
    grid-template-columns: 1fr;
  }

  .section-heading .muted {
    text-align: left;
  }

  .section-side {
    justify-items: start;
  }

  .service-filter {
    margin-top: 0;
  }

  .brand strong {
    font-size: 19px;
  }

  .brand img {
    width: 50px;
    height: 50px;
  }

  .actions {
    min-width: 180px;
  }
}
