:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #dbe3ee;
  --green: #15803d;
  --yellow: #b45309;
  --red: #b91c1c;
  --blue: #2563eb;
  --shadow-accent: rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.login-page {
  min-height: 100vh;
}

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

button,
.button {
  background: var(--blue);
  color: #fff;
  border: 1px solid transparent;
  padding: 0.6rem 0.9rem;
  border-radius: 0.55rem;
  cursor: pointer;
  display: inline-block;
  box-shadow: 0 1px 2px 0 var(--shadow-accent);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

button:hover,
.button:hover {
  background: #1d4ed8;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.18);
  transform: translateY(-1px);
}

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

th, td {
  padding: 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.topbar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-left: auto;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  color: inherit;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.08em;
  border-radius: 0.75rem;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.18);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.brand {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}

.brand-sub {
  font-size: 0.85rem;
  color: var(--muted);
}

.nav-link {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 2px 0 var(--shadow-accent);
  border-radius: 0.55rem;
  font-weight: 600;
}

.nav-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
  background: #eff6ff;
}

.logout-form .button {
  padding: 0.6rem 0.85rem;
  border: 1px solid transparent;
  min-height: auto;
  line-height: 1.2;
  font-weight: 600;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
  align-items: stretch;
}

.full-span {
  grid-column: 1 / -1;
}

.project-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.project-header h2 {
  margin: 0;
}

.project-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.project-inline {
  gap: 0.75rem;
  align-items: center;
}

.project-inline input {
  min-width: 220px;
}

.filter-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.project-filter {
  align-items: flex-start;
}

.project-filter,
.status-filter {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.project-filter {
  min-width: 280px;
}

.status-filter {
  min-width: 180px;
}

.search-filter {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 360px;
  min-width: 320px;
}

.filter-submit {
  display: flex;
  align-items: flex-end;
}

.filter-submit button {
  white-space: nowrap;
}

.project-resources {
  margin-top: 0.5rem;
}

.project-resources summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.project-resources summary::-webkit-details-marker {
  display: none;
}

.project-resources summary::before {
  content: "+";
  display: inline-block;
  width: 1rem;
  margin-right: 0.35rem;
}

.project-resources[open] summary::before {
  content: "-";
}

.project-resources-list {
  margin-top: 0.9rem;
}

.card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.container > .card + .card {
  margin-top: 1.5rem;
}

.grid .card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card-head, .actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.page-head + .actions {
  margin-bottom: 1rem;
}

form .actions {
  margin-top: 1rem;
}

.meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.meta dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.meta dd {
  margin: 0.2rem 0 0;
}

.muted {
  color: var(--muted);
}

.summary {
  margin: 1rem 0;
}

.badge {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid currentColor;
}

.badge-up {
  background: rgba(95, 173, 86, 0.18);
  color: var(--green);
}

.badge-degraded {
  background: rgba(197, 138, 0, 0.18);
  color: var(--yellow);
}

.badge-down {
  background: rgba(184, 12, 9, 0.15);
  color: var(--red);
}

.badge-unknown {
  background: rgba(13, 24, 33, 0.08);
  color: var(--muted);
}

.config-editor {
  width: 100%;
  min-height: 28rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
}

.flash {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 0.85rem;
  border: 1px solid var(--border);
}

.flash-ok {
  background: rgba(95, 173, 86, 0.18);
  color: var(--green);
}

.flash-error {
  background: rgba(184, 12, 9, 0.15);
  color: var(--red);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.projects-list {
  margin-top: 1.5rem;
}

.projects-merged {
  margin-top: 2rem;
}

.projects-merged > .card + .card,
.projects-merged > .list,
.projects-merged > .page-head + .card {
  margin-top: 1.5rem;
}

.row-card {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) auto minmax(150px, 1fr) minmax(130px, 1fr) auto;
  gap: 1rem;
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 1rem;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

.row-title {
  font-weight: 700;
}

.row-status {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.form-card h2 {
  margin-top: 0;
}

.empty-state {
  padding: 1rem;
}

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

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

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--panel);
  color: var(--text);
}

.button-danger {
  background: var(--red);
  box-shadow: 0 1px 2px rgba(185, 28, 28, 0.18);
}

.button-danger:hover {
  background: #991b1b;
  box-shadow: 0 6px 16px rgba(185, 28, 28, 0.2);
}

.button-plain {
  background: #374151;
}

.button-secondary {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
  box-shadow: none;
}

.button-secondary:hover {
  background: #f3f4f6;
  color: var(--text);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.actions-secondary {
  justify-content: flex-end;
}

.logout-form {
  margin: 0;
}

.inline-form {
  margin: 0;
  display: flex;
}

.inline-form .button,
.inline-form button {
  height: 100%;
  font: inherit;
  line-height: 1.2;
}

@media (max-width: 800px) {
  .topbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .nav {
    margin-left: 0;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .logout-form {
    align-self: flex-start;
  }
}

@media (max-width: 800px) {
  .row-card,
  .form-grid,
  .meta {
    grid-template-columns: 1fr;
  }

  .project-inline {
    width: 100%;
    flex-wrap: wrap;
  }

  .project-inline input {
    min-width: 0;
  }

  .filter-row,
  .project-filter,
  .status-filter,
  .search-filter,
  .filter-submit {
    width: 100%;
  }

  .project-filter,
  .status-filter,
  .search-filter {
    min-width: 0;
  }

  .filter-submit {
    align-items: stretch;
  }
}

.break {
  word-break: break-all;
}
