/* Buttons */
.btn {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 8px 14px;
  border: 1px solid var(--border-2);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--t-base);
  letter-spacing: 0.04em;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  min-height: 36px;
}
.btn:hover { border-color: var(--border-3); color: var(--text); background: var(--surface-2); }
.btn.primary { border-color: var(--green); color: var(--green); }
.btn.primary:hover { background: var(--green-dim); }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red-dim); }
.btn.ghost { border-color: transparent; }
.btn.tiny { font-size: 10px; padding: 5px 10px; min-height: 28px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color var(--t-base);
}
.card:hover { border-color: var(--border-2); }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.card-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text);
}

/* Inputs */
.input, .select, .textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  transition: border-color var(--t-base);
  min-height: 38px;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--green); }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.textarea { min-height: 64px; resize: vertical; }

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  min-width: 80px;
}

/* Badges */
.badge {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  background: var(--surface-3);
  color: var(--text-3);
  display: inline-block;
}
.badge.ok { background: var(--green-dim); color: var(--green); }
.badge.warn { background: var(--amber-dim); color: var(--amber); }
.badge.err { background: var(--red-dim); color: var(--red); }
.badge.info { background: var(--blue-dim); color: var(--blue); }
.badge.purple { background: var(--purple-dim); color: var(--purple); }
.badge.cyan { background: var(--cyan-dim); color: var(--cyan); }

/* Stat */
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-width: 0;
}
.stat:last-child { border-right: none; }
.stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--text-4);
  text-transform: uppercase;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}
.stat-value.ok { color: var(--green); }
.stat-value.warn { color: var(--amber); }
.stat-value.err { color: var(--red); }
.stat-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-4);
}

/* Status pills */
.status-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  display: inline-block;
  letter-spacing: 0.02em;
  min-width: 30px;
  text-align: center;
}
.status-pill.s2xx { background: var(--green-dim); color: var(--green); }
.status-pill.s4xx { background: var(--amber-dim); color: var(--amber); }
.status-pill.s5xx { background: var(--red-dim); color: var(--red); }
.status-pill.s0 { background: var(--surface-3); color: var(--text-4); }

/* Toast */
.toast-area {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-left-width: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  pointer-events: all;
  min-width: 220px;
  border-radius: 3px;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: none; }
}
.toast.ok { border-left-color: var(--green); color: var(--green); }
.toast.err { border-left-color: var(--red); color: var(--red); }
.toast.info { border-left-color: var(--blue); color: var(--blue); }
.toast.warn { border-left-color: var(--amber); color: var(--amber); }

/* Empty */
.empty {
  display: grid;
  place-items: center;
  padding: 32px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-4);
}
.empty.with-icon::before {
  content: '◌';
  display: block;
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.4;
}

/* Modal */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  width: min(720px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
}
.modal-close {
  font-size: 18px;
  color: var(--text-4);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 3px;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Bottom Sheet (mobile) / Modal (desktop) ────────────────── */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--t-base), visibility 0s linear var(--t-base);
}
.sheet-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity var(--t-base), visibility 0s linear 0s;
}
@keyframes sheet-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  max-height: 92vh;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  z-index: 201;
  transform: translateY(100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform var(--t-slow), opacity var(--t-base), visibility 0s linear var(--t-slow);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.sheet.open {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: transform var(--t-slow), opacity var(--t-base), visibility 0s linear 0s;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-3);
  border-radius: 2px;
  margin: 8px auto 4px;
  flex-shrink: 0;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sheet-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
}
.sheet-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--text-3);
  border-radius: var(--radius-sm);
  font-size: 16px;
}
.sheet-close:hover { background: var(--surface-2); color: var(--text); }

.sheet-body {
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0));
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

@media (min-width: 769px) {
  .sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: min(720px, 90vw);
    max-height: 85vh;
    border-radius: var(--radius);
    transform: translate(-50%, -50%) scale(0.96);
  }
  .sheet.open {
    transform: translate(-50%, -50%) scale(1);
  }
  .sheet-handle { display: none; }
  .sheet-head { padding: 14px 18px; }
}