:root {
  --blue1: #1e91d6;
  --blue2: #0072bb;
  --green: #8fc93a;
  --red: #d64545;
  --bg: #f7f9fb;
  --ink: #1e2a38;
  --muted: #66788a;
  --line: #dfe6ec;
  --card: #ffffff;
}

* { box-sizing: border-box; }

/* Keep the HTML `hidden` attribute authoritative even on elements that
   declare a display (e.g. .modal-backdrop, .nav use flex). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* Top bar */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 960px;
  margin: auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand { font-weight: bold; font-size: 18px; }
.brand-sub {
  font-size: 12px;
  font-weight: normal;
  color: var(--blue1);
  border: 1px solid var(--blue1);
  border-radius: 10px;
  padding: 1px 8px;
  margin-left: 6px;
}
.nav { display: flex; gap: 18px; align-items: center; }
.nav a { color: var(--blue2); text-decoration: none; font-weight: bold; }
.nav a:hover { text-decoration: underline; }

.wrap { max-width: 960px; margin: 32px auto 64px; padding: 0 16px; }

/* Auth cards */
.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  max-width: 440px;
  margin: 0 auto;
}
.auth-card h1 { margin-top: 0; }
.auth-card label { display: block; margin: 14px 0 4px; font-weight: bold; font-size: 14px; }
.auth-card input {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--blue1); }
.btn-primary { background: var(--blue1); border-color: var(--blue1); color: #fff; }
.btn-primary:hover { background: var(--blue2); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn + .btn { margin-left: 8px; }

.error { color: var(--red); font-size: 14px; }
.ok { color: var(--green); font-size: 14px; }

/* Channels */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.connect-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.channel-list { display: flex; flex-direction: column; gap: 12px; }

.channel-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.channel-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}
.channel-avatar i { font-size: 20px; }
.channel-main { flex: 1; min-width: 200px; }
.channel-name { font-weight: bold; font-size: 16px; }
.channel-provider { color: var(--muted); font-size: 13px; }
.channel-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.channel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: bold;
  padding: 2px 10px;
  border-radius: 12px;
  margin-left: 8px;
}
.badge-active { background: #e6f4d9; color: #4a7c12; }
.badge-inactive { background: #fdeaea; color: var(--red); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 35, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 40;
}
.modal {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 460px;
  max-height: 80vh;
  overflow: auto;
}
.modal.modal-wide { max-width: 760px; }
.modal h3 { margin-top: 0; }
.modal label { display: block; margin: 12px 0 4px; font-weight: bold; font-size: 14px; }
.modal input, .modal select, .modal textarea {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
}
.modal textarea { resize: vertical; min-height: 64px; }
.modal-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; }

.modal-subtitle { color: var(--muted); font-size: 13px; margin: -6px 0 14px; }
.form-section { margin: 20px 0 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-section h4 { margin: 0 0 2px; font-size: 15px; }
.form-section small { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.form-section .btn-sm { margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
.profile-pic-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 12px 0;
}
.profile-pic-row img,
.profile-pic-fallback {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.profile-pic-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
}
.profile-pic-text { display: flex; flex-direction: column; gap: 2px; }
.profile-pic-text strong { font-size: 14px; }
.profile-pic-text small { color: var(--muted); font-size: 13px; }
.modal-hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.modal-hint.issue { color: var(--red); }
.required-star { color: var(--red); }
.dynamic-rows { margin: 8px 0; }
.dynamic-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.dynamic-row input { flex: 1; margin-top: 0; }
.dynamic-label { min-width: 84px; padding-top: 10px; font-size: 13px; color: var(--muted); }
.hours-row { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.hours-day { min-width: 44px; font-weight: bold; font-size: 14px; }
.hours-row input { margin-top: 0; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn i { margin-right: 6px; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--red); border-color: var(--red); }
.modal-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid var(--blue1);
  border-top-color: transparent;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -2px;
  animation: modal-spin 0.7s linear infinite;
}
.modal-spinner[hidden] { display: none; }
@keyframes modal-spin { to { transform: rotate(360deg); } }

.danger-zone { margin-top: 24px; border-color: #f0c9c9; }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e2a38;
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 60;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.toast-error { background: var(--red); }

@media (max-width: 640px) {
  .page-head { flex-direction: column; align-items: stretch; }
}
