/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s;
  min-height: 44px;
  border: none;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border2);
}
.btn-secondary:hover { background: var(--surface2); }
.btn-danger { background: var(--red-bg); color: var(--red-text); }
.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 34px; }
.btn-icon { padding: 8px; min-height: 44px; min-width: 44px; justify-content: center; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
}
.card + .card { margin-top: .75rem; }

/* ── Form ── */
.form-group { margin-bottom: .875rem; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 4px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--accent); }
select.form-control { appearance: none; }
textarea.form-control { min-height: 80px; resize: vertical; }

/* ── Chips ── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  gap: 4px;
}
.chip-filter {
  cursor: pointer;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  transition: all .1s;
  min-height: 32px;
}
.chip-filter.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip-green { background: var(--green-bg); color: var(--green-text); }
.chip-red { background: var(--red-bg); color: var(--red-text); }
.chip-amber { background: var(--amber-bg); color: var(--amber-text); }
.chip-blue { background: var(--blue-bg); color: var(--blue-text); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
@media (min-width: 768px) {
  .modal-backdrop { align-items: center; padding: 1rem; }
}
.modal {
  background: var(--surface);
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
@media (min-width: 768px) {
  .modal {
    max-width: 520px;
    border-radius: var(--radius-lg);
  }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-footer {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  animation: toast-in .2s ease;
  max-width: 320px;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-success { background: var(--green-bg); color: var(--green-text); border: 1px solid #a5d6a7; }
.toast-error   { background: var(--red-bg);   color: var(--red-text);   border: 1px solid #ef9a9a; }
.toast-info    { background: var(--blue-bg);  color: var(--blue-text);  border: 1px solid #90caf9; }

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
}
.badge-red { background: var(--red); color: #fff; }
.badge-amber { background: var(--amber); color: #fff; }

/* ── Toggle ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 0;
}
.toggle-label { font-size: 13px; }

/* ── Checkbox Grid ── */
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .5rem;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}
.check-item input { width: 16px; height: 16px; cursor: pointer; }

/* ── Empty State ── */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text3);
}
.empty-icon { font-size: 40px; margin-bottom: .75rem; }
.empty-text { font-size: 14px; }

/* ── Search Bar ── */
.search-bar {
  position: relative;
  margin-bottom: 1rem;
}
.search-bar input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  min-height: 44px;
}
.search-bar::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── Connection Indicator ── */
#connection-indicator {
  position: fixed;
  bottom: calc(var(--tab-bar-height) + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--amber);
  color: white;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  white-space: nowrap;
}
@media (min-width: 768px) {
  #connection-indicator {
    bottom: 1rem;
    right: 1rem;
    left: auto;
    transform: none;
  }
}
