/* Pulse design system.
   Direction: sophistication & trust for a monitoring panel — cool slate
   foundation, borders-only depth, one trust-blue accent, color reserved
   for status meaning, monospace for data. 4px grid throughout. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e5e8ee;
  --border-subtle: #eef0f4;

  --text-1: #1c2333;
  --text-2: #49536b;
  --text-3: #8a93a6;
  --text-4: #b6bdcc;

  --accent: #2f6bde;
  --accent-hover: #2558bd;
  --accent-soft: #ecf2fd;

  --ok: #178d54;
  --ok-soft: #e8f5ee;
  --warn: #b45309;
  --warn-soft: #fdf3e5;
  --bad: #cf3d4f;
  --bad-soft: #fceef0;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 30, 55, 0.04);
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
}

body {
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Application shell ---------- */

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 224px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
}

.app-main { flex: 1 1 auto; min-width: 0; }

.app-content {
  max-width: 1200px;
  padding: 28px 32px 48px;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.app-offcanvas {
  width: 248px;
  background: var(--bg);
}
.app-offcanvas .offcanvas-body { padding: 16px 12px; }

/* ---------- Sidebar ---------- */

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text-1);
  text-decoration: none;
}
.brand-mark { color: var(--accent); }

.sidebar-head { padding: 4px 10px 16px; }
.sidebar-org {
  margin-top: 2px;
  padding-left: 26px;
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.sidebar-link svg { color: var(--text-3); transition: color 150ms var(--ease); }
.sidebar-link:hover { background: rgba(28, 35, 51, 0.045); color: var(--text-1); }
.sidebar-link:hover svg { color: var(--text-2); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-link.active svg { color: var(--accent); }

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 10px 4px;
  border-top: 1px solid var(--border-subtle);
}
.sidebar-user {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  background: transparent;
}
.btn-icon:hover { background: rgba(28, 35, 51, 0.05); color: var(--text-1); }

/* ---------- Page structure ---------- */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.page-title {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0;
}
.breadcrumb { font-size: 12px; margin-bottom: 6px; }
.breadcrumb .breadcrumb-item a { color: var(--text-3); text-decoration: none; }
.breadcrumb .breadcrumb-item a:hover { color: var(--accent); }
.breadcrumb .breadcrumb-item.active { color: var(--text-3); }

/* ---------- Surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-3);
}
.card-body { padding: 16px; }

/* ---------- Stat tiles ---------- */

.stat-tile .stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}
.stat-tile .stat-value {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-tile .stat-denominator {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-4);
}
.stat-value.is-ok { color: var(--ok); }
.stat-value.is-warn { color: var(--warn); }
.stat-value.is-bad { color: var(--bad); }

/* ---------- Tables ---------- */

.table { --bs-table-hover-bg: #fafbfc; margin-bottom: 0; font-size: 13.5px; }
.table thead th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  white-space: nowrap;
}
.table tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-2);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table a { color: var(--text-1); font-weight: 500; text-decoration: none; }
.table a:hover { color: var(--accent); }

.list-group-item { border-color: var(--border-subtle); padding: 12px 16px; }

/* ---------- Status ---------- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-4);
}
.status.status-success::before { background: var(--ok); }
.status.status-warning::before { background: var(--warn); }
.status.status-danger::before { background: var(--bad); }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.chip-success { background: var(--ok-soft); color: var(--ok); }
.chip-warning { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--bad-soft); color: var(--bad); }
.chip-secondary { background: rgba(28, 35, 51, 0.06); color: var(--text-2); }

/* ---------- Controls ---------- */

.btn { font-size: 13px; font-weight: 500; border-radius: var(--radius-sm); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}
.btn-primary:hover, .btn-primary:focus { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-outline-secondary { color: var(--text-2); border-color: var(--border); }
.btn-outline-secondary:hover { background: var(--bg); color: var(--text-1); border-color: var(--border); }
.btn-group-sm > .btn { font-size: 12px; padding: 3px 10px; }
.btn-group > .btn-outline-secondary.active {
  background: var(--text-1);
  border-color: var(--text-1);
  color: #fff;
}

.form-control, .form-select {
  font-size: 13.5px;
  border-color: var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-label { font-size: 12.5px; font-weight: 550; color: var(--text-2); margin-bottom: 5px; }
.form-text { font-size: 12px; color: var(--text-3); }

.font-monospace { font-size: 0.92em; letter-spacing: 0; }

.alert { font-size: 13px; border-radius: var(--radius-sm); padding: 10px 14px; border: 1px solid transparent; }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: rgba(23, 141, 84, 0.15); }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: rgba(180, 83, 9, 0.15); }

dl.row dt { font-size: 12.5px; font-weight: 550; color: var(--text-3); }
dl.row dd { font-size: 13.5px; color: var(--text-2); }

.text-muted { color: var(--text-3) !important; }

/* ---------- Auth / onboarding shell ---------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-main { width: 100%; max-width: 400px; }
.auth-main .card { box-shadow: 0 1px 2px rgba(20, 30, 55, 0.04), 0 8px 24px rgba(20, 30, 55, 0.05); }
.auth-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-3);
}

/* ---------- HTMX ---------- */

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

/* ---------- Mobile ---------- */

@media (max-width: 991.98px) {
  .app-content { padding: 16px 16px 40px; }
  .page-header { margin-bottom: 16px; }
  .stat-tile .stat-value { font-size: 22px; }
}
