:root {
  --bg: #1a1a2e;
  --card-bg: #16213e;
  --text: #e0e0e0;
  --text-muted: #9aa0c3;
  --border: #2a2a4a;
  --green: #00c853;
  --yellow: #ffd600;
  --red: #ff1744;
  --blue: #64b5f6;
  --btn-bg: #0f3460;
  --btn-hover: #1a4a7a;
  --input-bg: #111930;
}

html.light {
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666666;
  --border: #dddddd;
  --green: #00c853;
  --yellow: #f9a825;
  --red: #d32f2f;
  --blue: #1976d2;
  --btn-bg: #e0e0e0;
  --btn-hover: #cfcfcf;
  --input-bg: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--blue);
  text-decoration: none;
}

h1,
h2 {
  margin: 0 0 12px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}

.brand {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.brand-with-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 6px;
  flex: 0 0 auto;
}

.nav-links,
.action-group,
.title-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-card strong {
  font-size: 30px;
}

.btn {
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
}

.btn:hover {
  background: var(--btn-hover);
}

.btn-secondary {
  background: transparent;
}

.user-chip,
.muted {
  color: var(--text-muted);
}

.flash {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.flash-success {
  background: rgba(0, 200, 83, 0.12);
  border: 1px solid rgba(0, 200, 83, 0.4);
}

.flash-error {
  background: rgba(255, 23, 68, 0.12);
  border: 1px solid rgba(255, 23, 68, 0.4);
}

.plain-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.app-list,
.history-list,
.status-list,
.public-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.healthy-apps-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.healthy-apps-row {
  display: grid;
  grid-template-columns: 56px minmax(120px, 1fr) minmax(180px, 1.4fr) 100px 100px;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

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

.healthy-apps-header {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding-top: 0;
}

.healthy-apps-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

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

.row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-weight: 600;
}

.status-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.status-dot.healthy {
  background: var(--green);
}

.status-dot.issue {
  background: var(--red);
}

.status-dot.warning {
  background: var(--yellow);
}

.progress {
  width: 100%;
  height: 14px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.08);
}

.progress::-webkit-progress-value {
  background: var(--blue);
  border-radius: 999px;
}

.progress::-moz-progress-bar {
  background: var(--blue);
  border-radius: 999px;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
}

.text-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--text);
}

.compact-input {
  min-width: 200px;
}

.form-actions {
  grid-column: 1 / -1;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 0;
}

.detail-grid dt {
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-grid dd {
  margin: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
}

.top-gap {
  margin-top: 16px;
}

.public-container {
  max-width: 760px;
}

@media (max-width: 700px) {
  .site-header,
  .app-row {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .healthy-apps-row {
    grid-template-columns: 56px 1fr;
  }

  .healthy-apps-header {
    display: none;
  }

  .container {
    padding: 16px;
  }
}
