:root {
  --bg-0: #eef2ec;
  --bg-1: #ffffff;
  --bg-2: #dfebe2;
  --text: #1a211d;
  --muted: #5f6d65;
  --line: #cfdbd2;
  --brand: #1f6f4f;
  --brand-2: #2e8f66;
  --danger: #ba3e2d;
  --warn: #c48e0f;
  --ok: #2e8f66;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(22, 35, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, #f5f8f4 0%, #eaf3ea 40%, #e6edf3 100%);
  min-height: 100vh;
}

.app-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 22%, rgba(31, 111, 79, 0.18), transparent 36%),
    radial-gradient(circle at 92% 8%, rgba(196, 142, 15, 0.14), transparent 26%),
    radial-gradient(circle at 74% 84%, rgba(46, 143, 102, 0.1), transparent 30%);
  z-index: 0;
}

.sidebar {
  position: fixed;
  z-index: 20;
  inset: 0 auto 0 0;
  width: 280px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
}

.brand-block h1 {
  margin: 0.2rem 0 0;
  font-size: 1.35rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--brand);
}

.nav-list {
  display: grid;
  gap: 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--text);
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0.62rem 0.7rem;
  font-weight: 600;
}

.nav-item:hover {
  border-color: var(--line);
  background: var(--bg-0);
}

.nav-item.active {
  background: var(--brand);
  color: #fff;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.signout-link {
  margin-top: auto;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
}

.content-shell {
  position: relative;
  z-index: 1;
  margin-left: 280px;
  padding: 1rem;
  min-height: 100vh;
}

.topbar {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.topbar h2 {
  margin: 0.28rem 0;
  font-size: 1.32rem;
}

.topbar-actions {
  min-width: 240px;
}

.tenant-scope-form label,
.inline-form label,
.form-grid label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.85rem;
}

.page-grid {
  margin-top: 1rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }

.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.panel h3 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
}

h4 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-0);
  padding: 0.66rem;
}

.metric span {
  color: var(--muted);
  font-size: 0.76rem;
}

.metric strong {
  display: block;
  font-size: 1.34rem;
}

.stack {
  display: grid;
  gap: 0.6rem;
}

.mini-card,
.incident-card {
  border: 1px solid var(--line);
  background: #f7faf7;
  border-radius: 10px;
  padding: 0.62rem;
}

.mini-card p,
.incident-card p {
  margin: 0.24rem 0 0;
  font-size: 0.86rem;
}

.compact-scroll {
  max-height: 340px;
  overflow: auto;
  padding-right: 0.3rem;
}

.timeline-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.timeline-wide {
  grid-column: span 2;
}

.line-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.line-head.wrap {
  flex-wrap: wrap;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.mono,
.mono-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  color: var(--muted);
}

.badge {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.18rem 0.55rem;
  font-size: 0.74rem;
}

.badge.good {
  background: rgba(46, 143, 102, 0.14);
  color: var(--ok);
  border-color: rgba(46, 143, 102, 0.34);
}

.badge.warn {
  background: rgba(196, 142, 15, 0.14);
  color: var(--warn);
  border-color: rgba(196, 142, 15, 0.34);
}

.badge.muted {
  background: #edf2ef;
  color: var(--muted);
  border-color: #dce6df;
}

.flash {
  margin-top: 1rem;
  border-radius: 10px;
  padding: 0.66rem 0.76rem;
  border: 1px solid transparent;
}

.flash.success {
  border-color: rgba(46, 143, 102, 0.34);
  background: rgba(46, 143, 102, 0.12);
}

.flash.error {
  border-color: rgba(186, 62, 45, 0.34);
  background: rgba(186, 62, 45, 0.12);
}

.form-grid {
  display: grid;
  gap: 0.58rem;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: end;
}

.inline-form-wide {
  flex-wrap: wrap;
}

.row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn.secondary {
  background: #e5ece7;
  color: var(--text);
}

input,
select,
textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.56rem 0.66rem;
  color: var(--text);
  font-family: inherit;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1rem 0;
}

.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 40;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: #143025;
  cursor: pointer;
}

.mobile-menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  margin: 4px auto;
  background: #fff;
}

.login-layer {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(430px, 96vw);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  background: rgba(255, 255, 255, 0.95);
  padding: 1rem;
  display: grid;
  gap: 0.66rem;
}

.login-card h1 {
  margin: 0.2rem 0;
  font-size: 1.48rem;
}

@media (max-width: 1200px) {
  .span-8,
  .span-7,
  .span-6,
  .span-5,
  .span-4,
  .span-3 {
    grid-column: span 12;
  }

  .metric-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .mobile-menu-toggle {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: min(84vw, 320px);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content-shell {
    margin-left: 0;
    padding: 0.7rem;
    padding-top: 3.2rem;
  }

  .topbar {
    flex-direction: column;
  }

  .timeline-grid {
    grid-template-columns: 1fr;
  }

  .timeline-wide {
    grid-column: span 1;
  }
}

@media (max-width: 620px) {
  .metric-row {
    grid-template-columns: 1fr;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }
}
