:root {
  --bg: #0a0e13;
  --panel: #11161d;
  --panel-2: #151b24;
  --border: #212b36;
  --text: #dbe4ec;
  --muted: #7c8b99;
  --cyan: #22d3ee;
  --cyan-dim: #0e7490;
  --cyan-glow: rgba(34, 211, 238, 0.12);
  --danger: #f87171;
  --ok: #34d399;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* Sidebar */

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.4rem 1.25rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  flex-shrink: 0;
}
.brand-title { color: var(--cyan); font-weight: 700; font-size: 1rem; line-height: 1.1; }
.brand-subtitle { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.nav-item {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--muted);
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active {
  background: var(--cyan-glow);
  color: var(--cyan);
  font-weight: 600;
}

.nav-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.nav-status-dot.online { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.nav-status-dot.offline { background: var(--danger); }

.logout-btn {
  margin-top: 1rem;
  width: 100%;
}

/* Content */

.content {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 900px;
}

.page { display: none; }
.page.active { display: block; }

.page h1 {
  font-size: 1.15rem;
  color: var(--cyan);
  margin: 0 0 1.1rem;
  letter-spacing: 0.01em;
}

.hint { color: var(--muted); font-size: 0.85rem; margin: -0.5rem 0 1rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card h2 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.big-status { font-size: 1.4rem; font-weight: 600; margin: 0 0 1rem; }

input, button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  font-family: inherit;
}

button {
  cursor: pointer;
  color: var(--cyan);
  border-color: var(--cyan-dim);
  transition: background 0.12s, color 0.12s;
}
button:hover { background: var(--cyan-dim); color: #04222b; }
button:disabled { opacity: 0.5; cursor: default; }
button:disabled:hover { background: var(--panel-2); color: var(--cyan); }

.button-link {
  display: inline-block;
  text-decoration: none;
  background: var(--panel-2);
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
}
.button-link:hover { background: var(--cyan-dim); color: #04222b; }

table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
th, td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
th { color: var(--muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

#qrImage { max-width: 220px; display: block; margin: 0.75rem 0 1rem; border-radius: 8px; border: 1px solid var(--border); }

.pairing-code {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--cyan);
  background: var(--panel-2);
  border: 1px solid var(--cyan-dim);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  text-align: center;
  margin: 0.5rem 0 1rem;
}

.qr-fallback {
  margin: 0.5rem 0 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.qr-fallback summary { cursor: pointer; }

.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.inline-form input { flex: 1; min-width: 140px; }
.inline-form input#gcHours { max-width: 80px; flex: 0; }
.inline-form input[type="file"] { flex: 1; padding: 0.45rem; }

.action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.action-row:last-child { border-bottom: none; }

.status-ok { color: var(--ok); }
.status-bad { color: var(--danger); }

/* Chat */

.chat-card { padding: 0; overflow: hidden; }
.chat-layout {
  display: flex;
  height: 560px;
}

.chat-numbers {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.chat-numbers-add {
  display: flex;
  gap: 0.4rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.chat-numbers-add input { flex: 1; min-width: 0; }

.chat-number-item {
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.chat-number-item:hover { background: var(--panel-2); }
.chat-number-item.active { background: var(--cyan-glow); color: var(--cyan); font-weight: 600; }
.chat-number-item .num-name { display: block; color: var(--muted); font-size: 0.75rem; }
.chat-number-item.active .num-name { color: var(--cyan); opacity: 0.8; }

.chat-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-thread-header {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  color: var(--cyan);
  font-weight: 600;
  font-size: 0.92rem;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat-bubble {
  max-width: 70%;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-bubble.out {
  align-self: flex-end;
  background: var(--cyan-dim);
  color: #04222b;
  border-bottom-right-radius: 2px;
}
.chat-bubble.in {
  align-self: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 2px;
}
.chat-send-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}
.chat-send-form input { flex: 1; }

@media (max-width: 780px) {
  .chat-layout { flex-direction: column; height: auto; }
  .chat-numbers { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 180px; overflow-y: auto; }
  .chat-messages { height: 320px; }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 360px;
}
.modal-box button { margin-right: 0.5rem; margin-top: 1rem; }

.toggle-link { color: var(--cyan); cursor: pointer; font-size: 0.85rem; }
.remove-link { color: var(--danger); cursor: pointer; font-size: 0.85rem; margin-left: 0.6rem; }

@media (max-width: 780px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .brand { border-bottom: none; padding-bottom: 0; margin-bottom: 0; border-right: 1px solid var(--border); padding-right: 1rem; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .logout-btn { width: auto; margin-top: 0; margin-left: auto; }
  .content { padding: 1.25rem; }
}

/* Login page */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: 0 0 60px rgba(34, 211, 238, 0.06);
}
.login-box h1 {
  font-size: 1.15rem;
  color: var(--cyan);
  margin: 0 0 0.5rem;
  text-align: center;
}
.login-box button { margin-top: 0.35rem; }
