:root {
  --green: #1f9d55;
  --green-dark: #167a42;
  --bg: #f6f7f5;
  --card: #ffffff;
  --ink: #14261c;
  --muted: #667066;
  --border: #e3e7e1;
  --danger: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  background: #101913;
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar .brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 18px;
}

.topbar .brand span { color: var(--green); }

.topbar a.linklike {
  color: #cfd8d0;
  text-decoration: none;
  font-size: 14px;
}
.topbar a.linklike:hover { color: #fff; }

.auth-wrap {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card h1 {
  font-size: 20px;
  margin: 0 0 6px;
}

.card p.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 24px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0 6px;
  color: var(--ink);
}

input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}

textarea { resize: vertical; min-height: 70px; }

button, .btn {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: var(--green-dark); }

.btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: #f0f1ee; }

.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #a5301f; }

.error {
  background: #fdeceb;
  border: 1px solid #f3c6c2;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.full-btn { width: 100%; margin-top: 20px; }

/* Admin dashboard */
.wrap { max-width: 900px; margin: 0 auto; padding: 32px 24px; }
.wrap h1 { font-size: 22px; margin-bottom: 4px; }
.wrap .sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

.client-list { display: flex; flex-direction: column; gap: 10px; }
.client-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.client-row .info strong { font-size: 15px; }
.client-row .info .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  margin-left: 8px;
}
.badge.on { background: #e7f6ec; color: var(--green-dark); }
.badge.off { background: #f1f1ee; color: var(--muted); }

.row-actions { display: flex; gap: 8px; }
.row-actions .btn, .row-actions button { padding: 7px 12px; font-size: 13px; }

.top-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }

form.stack { display: flex; flex-direction: column; }

.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Chat */
.chat-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 20px 100px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 60px);
}
.chat-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.chat-header h1 { font-size: 18px; margin: 0; }
.chat-header .sub { color: var(--muted); font-size: 13px; }

.messages { flex: 1; display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }

.msg { max-width: 85%; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 3px; }
.msg.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 3px; }

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.composer {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding-top: 12px;
  display: flex;
  gap: 8px;
}
.composer textarea {
  flex: 1;
  min-height: 46px;
  max-height: 140px;
}
.composer button { align-self: flex-end; }

.typing { color: var(--muted); font-size: 13px; font-style: italic; }
