/* Heartbeat app styles — built on tokens.css.
   Sourced from .design-fetch/deadmanswitch/project/app.css.
   Asset paths rewritten to /static/assets/. */
@import url("/static/css/tokens.css");

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
}

/* ─────────── primitives ─────────── */
.btn {
  font-family: var(--mono);
  font-size: 13px;
  padding: 7px 14px;
  border: 1px solid var(--line-1);
  background: var(--bg-0);
  color: var(--fg-0);
  cursor: pointer;
  box-shadow: 2px 2px 0 0 var(--line-1);
  transition: transform 80ms var(--ease), box-shadow 80ms var(--ease), background 80ms var(--ease), color 80ms var(--ease);
  letter-spacing: 0;
  border-radius: 0;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  text-decoration: none;
  font-weight: 500;
}
.btn:hover { background: var(--fg-0); color: var(--bg-0); }
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn.primary { background: var(--fg-0); color: var(--bg-0); }
.btn.primary:hover { background: var(--bg-0); color: var(--fg-0); }
.btn.ghost { box-shadow: none; border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--line-1); }
.btn.sm { font-size: 12px; padding: 4px 10px; box-shadow: none; gap: 6px; }
.btn.lg { font-size: 14px; padding: 11px 22px; box-shadow: 3px 3px 0 0 var(--line-1); }
.btn.lg:active { transform: translate(3px, 3px); }
.btn.icon { padding: 4px; box-shadow: none; border-color: transparent; background: transparent; }
.btn.icon:hover { border-color: var(--line-1); background: var(--bg-2); color: var(--fg-0); }
.btn.full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover { background: var(--bg-0); color: var(--fg-0); }

.input, .select, .textarea {
  font-family: var(--mono);
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--line-1);
  background: var(--bg-elev);
  color: var(--fg-0);
  width: 100%;
  border-radius: 0;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--fg-0); outline-offset: 2px; }
.input::placeholder, .textarea::placeholder { color: var(--fg-3); font-style: italic; }
.textarea { resize: vertical; line-height: 1.6; min-height: 120px; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2316140f'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  background: var(--bg-elev);
  color: var(--fg-1);
}

.label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-2);
  font-weight: 500;
}
.label-strong {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-0);
  font-weight: 700;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line-1);
  box-shadow: 2px 2px 0 0 var(--line-1);
  padding: 24px;
}
.card.flat { box-shadow: none; }
.card.sunken { background: var(--bg-1); box-shadow: none; }
.card.bare { background: transparent; box-shadow: none; border-color: var(--line-2); }

.badge {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid var(--line-1);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-weight: 500;
}
.badge.solid { background: var(--fg-0); color: var(--bg-0); }
.badge.dashed { border-style: dashed; border-color: var(--line-2); color: var(--fg-2); }
.badge.dot::before { content: "●"; font-size: 8px; line-height: 1; }

.toggle {
  width: 36px; height: 18px;
  border: 1px solid var(--line-1);
  display: inline-block;
  position: relative;
  cursor: pointer;
  background: var(--bg-elev);
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 1px; left: 1px;
  width: 14px; height: 14px;
  background: var(--fg-0);
  transition: transform 120ms var(--ease);
}
.toggle.off::after { transform: translateX(0); background: var(--fg-3); }
.toggle.on::after { transform: translateX(18px); }

.checkbox {
  width: 16px; height: 16px;
  border: 1px solid var(--line-1);
  background: var(--bg-elev);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.checkbox.on { background: var(--fg-0); color: var(--bg-0); }

.radio {
  width: 16px; height: 16px;
  border: 1px solid var(--line-1);
  background: var(--bg-elev);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
}
.radio.on::after {
  content: "";
  width: 8px; height: 8px;
  background: var(--fg-0);
  border-radius: 50%;
}

.divider { border: 0; border-top: 1px solid var(--line-2); margin: 24px 0; }
.divider.hard { border-top-color: var(--line-1); }
.divider.double { border: 0; border-top: 3px double var(--line-1); }
.divider.dashed { border-top: 1px dashed var(--line-2); }

table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
table.t th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-2);
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-1);
}
table.t td { padding: 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: var(--bg-1); }

a { color: var(--fg-0); text-decoration: underline; text-underline-offset: 3px; }
a:hover { background: var(--fg-0); color: var(--bg-0); text-decoration: none; }

/* ─────────── App scaffold ─────────── */
.app {
  display: grid;
  grid-template-rows: 56px 1fr;
  grid-template-columns: 256px 1fr;
  grid-template-areas: "topbar topbar" "sidebar main";
  min-height: 100vh;
}
.topbar {
  grid-area: topbar;
  border-bottom: 1px solid var(--line-1);
  background: var(--bg-0);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  white-space: nowrap;
  z-index: 10;
}
.sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--line-1);
  padding: 20px 0;
  overflow-y: auto;
  background: var(--bg-0);
  display: flex;
  flex-direction: column;
}
.main {
  grid-area: main;
  overflow-y: auto;
  padding: 40px 48px 80px;
  background-color: var(--bg-0);
  background-image: url("/static/assets/dotgrid-bg.svg");
  background-size: 16px 16px;
  background-repeat: repeat;
}

.nav-group { margin-bottom: 22px; padding: 0 14px; }
.nav-group-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-2);
  padding: 4px 10px;
  margin-bottom: 6px;
  font-weight: 500;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--fg-1);
  border-left: 2px solid transparent;
  text-decoration: none;
  user-select: none;
}
.nav-item:hover { background: var(--bg-2); color: var(--fg-0); text-decoration: none; }
.nav-item.active { color: var(--fg-0); border-left-color: var(--fg-0); background: var(--bg-1); font-weight: 500; }
.nav-item .icon { width: 14px; height: 14px; flex-shrink: 0; }
.nav-item .badge-mini {
  margin-left: auto;
  font-size: 10px;
  color: var(--fg-2);
  letter-spacing: 0.04em;
}

/* ─────────── Page chrome ─────────── */
.page-head {
  margin-bottom: 32px;
}
.page-head .label {
  margin-bottom: 8px;
}
.page-head h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
}
.page-head .lede {
  color: var(--fg-1);
  font-size: 14px;
  margin-top: 10px;
  max-width: 60ch;
  line-height: 1.6;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-1);
}
.section-head h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
}
.section-head .meta {
  font-size: 11px;
  color: var(--fg-2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ─────────── Form rows ─────────── */
.field {
  margin-bottom: 20px;
}
.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.field-label .label { color: var(--fg-0); font-weight: 500; }
.field-help {
  font-size: 12px;
  color: var(--fg-2);
  margin-top: 6px;
  line-height: 1.5;
}

.row { display: flex; gap: 16px; align-items: center; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 12px; }

/* ─────────── Status (the heartbeat) ─────────── */
.heartbeat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-1);
}
.heartbeat .pulse {
  width: 8px; height: 8px;
  background: var(--fg-0);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
.heartbeat.ok .pulse { background: var(--fg-0); }
.heartbeat.warn .pulse { animation-duration: 0.8s; background: var(--fg-0); }
.heartbeat.crit .pulse { animation-duration: 0.4s; background: var(--orange); }
.heartbeat.off .pulse { background: var(--fg-3); animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.7); }
}
@media (prefers-reduced-motion: reduce) {
  .heartbeat .pulse { animation: none; }
}

/* ─────────── Empty state ─────────── */
.empty {
  text-align: center;
  padding: 64px 24px;
  border: 1px dashed var(--line-2);
  background: var(--bg-elev);
}
.empty h3 {
  font-size: 18px;
  margin-bottom: 8px;
}
.empty p {
  color: var(--fg-2);
  font-size: 13px;
  max-width: 50ch;
  margin: 0 auto 20px;
  line-height: 1.6;
}

/* ─────────── Marketing ─────────── */
.marketing {
  min-height: 100vh;
  background: var(--bg-0);
  display: flex;
  flex-direction: column;
}
.marketing-bar {
  position: sticky;
  top: 0;
  background: var(--bg-0);
  border-bottom: 1px solid var(--line-1);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  z-index: 5;
}
.marketing-nav {
  display: flex;
  gap: 24px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-1);
}
.marketing-nav .marketing-link {
  text-decoration: none;
  color: var(--fg-1);
}
.marketing-nav .marketing-link:hover { background: var(--fg-0); color: var(--bg-0); }
.marketing-nav .marketing-link.active { color: var(--fg-0); border-bottom: 1px dashed var(--line-1); }
.marketing-actions { display: flex; gap: 8px; align-items: center; }
.marketing-main { flex: 1; }
.marketing-footer {
  border-top: 1px solid var(--line-1);
  padding: 28px 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-2);
  background: var(--bg-1);
}
.marketing-footer .footer-line { font-weight: 500; color: var(--fg-1); }
.marketing-footer .footer-nav { display: flex; gap: 18px; }
.marketing-footer a { color: var(--fg-2); text-decoration: none; }
.marketing-footer a:hover { background: var(--fg-0); color: var(--bg-0); }

/* ─────────── Brand / topbar pieces ─────────── */
.brand-link { text-decoration: none; color: var(--fg-0); display: inline-flex; }
.brand-link:hover { background: transparent; color: var(--fg-0); }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
}
.brand-mark { color: var(--fg-0); }
.brand-text { color: var(--fg-0); }
.brand-dot { color: var(--fg-2); }

.topbar .heartbeat-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-1);
}

/* User dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-toggle .caret { color: var(--fg-2); font-size: 10px; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--bg-elev);
  border: 1px solid var(--line-1);
  box-shadow: 4px 4px 0 0 var(--line-1);
  display: none;
  z-index: 20;
  padding: 6px 0;
}
.dropdown:hover .dropdown-menu,
.dropdown.open .dropdown-menu,
.dropdown:focus-within .dropdown-menu { display: block; }
.dropdown-item {
  display: block;
  padding: 6px 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-1);
  text-decoration: none;
}
.dropdown-item:hover { background: var(--fg-0); color: var(--bg-0); }
.dropdown-divider { border-top: 1px dashed var(--line-2); margin: 6px 0; }

.user-menu .user-email {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─────────── Misc ─────────── */
.mono-pre {
  font-family: var(--mono);
  background: var(--bg-1);
  padding: 16px;
  border: 1px solid var(--line-2);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}

.glyph { font-variant-numeric: tabular-nums; }

.spinner-dots::after {
  content: "···";
  display: inline-block;
  animation: dots 1.2s steps(4, end) infinite;
  width: 1.5em;
  text-align: left;
  overflow: hidden;
  vertical-align: bottom;
}
@keyframes dots {
  0%, 20% { width: 0; }
  40% { width: 0.5em; }
  60% { width: 1em; }
  80%, 100% { width: 1.5em; }
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(22, 20, 15, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 32px;
  animation: fadeIn 160ms var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--line-1);
  box-shadow: 4px 4px 0 0 var(--line-1);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-body { padding: 24px; }
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--line-2);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg-0);
  color: var(--bg-0);
  padding: 12px 20px;
  font-size: 13px;
  z-index: 200;
  animation: slideUp 200ms var(--ease);
  display: flex;
  align-items: center;
  gap: 10px;
}
@keyframes slideUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ─────────── Flash messages (alerts) ─────────── */
.flash-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}
.alert {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border: 1px dashed var(--line-1);
  background: var(--bg-elev);
  color: var(--fg-0);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.alert .alert-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--fg-1);
  font-size: 16px;
  line-height: 1;
}
.alert.alert-error,
.alert.alert-danger { border-color: var(--orange); }
