:root {
  color-scheme: light;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --ink: #1f2330;
  --muted: #687083;
  --line: #e3e6ee;
  --primary: #6457e5;
  --primary-soft: #efedff;
  --success: #16a085;
  --danger: #c54b64;
  --shadow: 0 12px 34px rgba(32, 38, 55, 0.08);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-header {
  min-height: 68px;
  padding: 12px clamp(20px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
}

.user-menu,
.user-menu form {
  display: flex;
  align-items: center;
  gap: 14px;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}

.page-shell {
  width: min(1400px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 26px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.hero-copy {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.eyebrow {
  margin-bottom: 9px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.status-card {
  min-width: 270px;
  padding: 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-card strong,
.status-card small {
  display: block;
}

.status-card small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(22, 160, 133, 0.12);
}

.stack-grid {
  margin-bottom: 22px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stack-chip {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.stack-chip strong,
.stack-chip span {
  display: block;
}

.stack-chip span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
}

.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.inline-form {
  margin-bottom: 18px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

label {
  margin-bottom: 6px;
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #cfd4df;
  border-radius: 9px;
  background: white;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 3px solid rgba(100, 87, 229, 0.16);
  border-color: var(--primary);
}

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

.metric {
  min-height: 106px;
  padding: 16px;
  border-radius: 12px;
  background: #f7f8fb;
}

.metric span,
.metric small,
.metric strong {
  display: block;
}

.metric span,
.metric small {
  color: var(--muted);
}

.metric span {
  margin-bottom: 9px;
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  margin-bottom: 3px;
  font-size: 24px;
}

.metric small {
  font-size: 12px;
}

.metric-alert strong {
  color: var(--danger);
}

.chart {
  width: 100%;
  min-height: 310px;
}

.table-panel {
  margin-top: 22px;
}

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

.compact {
  margin-bottom: 18px;
}

.form-errors {
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff0f3;
  color: #8f2d42;
}

.login-panel {
  width: min(440px, 100%);
  margin: 7vh auto 0;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  font-size: 36px;
}

.stacked-form {
  margin-top: 24px;
  display: grid;
  gap: 8px;
}

.stacked-form input {
  width: 100%;
  margin-bottom: 10px;
}

.primary-button {
  min-height: 44px;
  margin-top: 8px;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-weight: 750;
  cursor: pointer;
}

.htmx-indicator {
  display: none;
  padding-bottom: 12px;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-block;
}

.tabulator {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  font-size: 14px;
}

@media (max-width: 900px) {
  .hero {
    align-items: stretch;
    flex-direction: column;
  }

  .status-card {
    min-width: 0;
  }

  .stack-grid,
  .content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .page-shell {
    width: min(100% - 24px, 1400px);
    padding-top: 28px;
  }

  .stack-grid,
  .content-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .login-panel {
    padding: 20px;
  }
}
