:root {
  --pink: #ff4f8b;
  --pink-soft: #ffd0e0;
  --yellow: #f5c518;
  --yellow-soft: #ffe9a8;
  --green: #2bb673;
  --green-soft: #c9f0dc;
  --ink: #1a1a1a;
  --muted: #5c5c5c;
  --glass: rgba(255, 255, 255, 0.88);
  --glass-strong: rgba(255, 255, 255, 0.96);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  --radius: 22px;
  --font: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #111;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--pink), #ff7aa8);
  color: #fff;
  box-shadow: 0 10px 24px rgba(255, 79, 139, 0.35);
}
.btn-primary:disabled { opacity: 0.6; cursor: wait; transform: none; }
.btn-ghost {
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.btn-block { width: 100%; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
}
.brand img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.25));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { font-weight: 600; color: var(--muted); }
.topbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.55)),
    var(--login-bg) center/cover no-repeat;
}
.login-card {
  width: min(420px, 100%);
  background: var(--glass-strong);
  border-radius: 28px;
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin-bottom: 0.5rem;
}
.login-card h1 {
  margin: 0.25rem 0;
  font-size: 1.85rem;
}
.login-sub { margin: 0 0 1.5rem; color: var(--muted); }
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: left;
  margin-bottom: 1rem;
}
.field span { font-weight: 700; font-size: 0.9rem; }
.field input {
  border: 1px solid #e4e4e4;
  border-radius: 14px;
  padding: 0.9rem 1rem;
  background: #fff;
}
.alert {
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}
.alert-error {
  background: #ffe3ea;
  color: #b0003a;
}

/* ---------- Home / roles ---------- */
.home-page,
.chat-page,
.admin-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.72)),
    var(--page-bg) center/cover no-repeat;
}

.home-hero {
  max-width: 980px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  text-align: center;
}
.home-hero h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}
.home-hero > p {
  margin: 0 0 2rem;
  color: var(--muted);
  font-weight: 600;
}
.role-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.role-card {
  background: var(--glass);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow);
  text-align: left;
  border: 2px solid transparent;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.role-card:hover {
  transform: translateY(-4px);
}
.role-mark {
  display: block;
  width: 42px;
  height: 8px;
  border-radius: 999px;
  margin-bottom: 1rem;
}
.role-employee .role-mark { background: var(--green); }
.role-manager .role-mark { background: var(--yellow); }
.role-admin .role-mark { background: var(--pink); }
.role-employee:hover { border-color: var(--green); }
.role-manager:hover { border-color: var(--yellow); }
.role-admin:hover { border-color: var(--pink); }
.role-card h2 { margin: 0 0 0.4rem; }
.role-card p { margin: 0; color: var(--muted); font-weight: 600; }

/* ---------- Chat ---------- */
.chat-shell {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  height: calc(100vh - 88px);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  background: var(--glass);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.bubble {
  max-width: min(78%, 620px);
  padding: 0.85rem 1rem;
  border-radius: 18px;
  line-height: 1.45;
  animation: rise 0.25s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.bubble-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--green), #57d39a);
  color: #083b24;
}
.bubble-assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #eee;
}
.bubble-meta {
  font-size: 0.75rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
  opacity: 0.7;
}
.bubble-text { white-space: pre-wrap; }
.bubble-sources {
  margin-top: 0.55rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.feedback {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px dashed #e6e6e6;
}
.stars {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.55rem;
}
.star {
  border: 0;
  background: transparent;
  font-size: 1.35rem;
  cursor: pointer;
  color: #d0d0d0;
  line-height: 1;
  padding: 0;
}
.star.active, .star:hover { color: var(--yellow); }
.feedback-extra { display: none; margin-top: 0.5rem; }
.feedback-extra.open { display: block; }
.feedback-extra label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.35rem 0;
  font-size: 0.9rem;
  font-weight: 600;
}
.feedback-extra textarea {
  width: 100%;
  min-height: 70px;
  border-radius: 12px;
  border: 1px solid #e2e2e2;
  padding: 0.65rem 0.75rem;
  resize: vertical;
  margin-top: 0.4rem;
}
.feedback-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.55rem;
}
.feedback-done {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--green);
  margin-top: 0.4rem;
}

.chat-input-row {
  display: flex;
  gap: 0.6rem;
  background: var(--glass-strong);
  border-radius: 999px;
  padding: 0.45rem;
  box-shadow: var(--shadow);
}
.chat-input-row input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 0.7rem 1rem;
  outline: none;
}
.typing {
  align-self: flex-start;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.25rem 0.5rem;
}

/* ---------- Admin ---------- */
.admin-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 2.5rem;
}
.admin-wrap h1 { margin: 0 0 1rem; }

.admin-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.admin-tab {
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  font-weight: 800;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}
.admin-tab.active {
  background: linear-gradient(135deg, var(--pink), #ff7aa8);
  color: #fff;
}
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.75rem;
}
.admin-tab.active .tab-badge { background: rgba(255, 255, 255, 0.25); }
.admin-tab-panel { display: none; }
.admin-tab-panel.active { display: block; }
.panel-note {
  margin: -0.25rem 0 0.85rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}
.stat-danger strong { color: #c6284a; }

.bubble-warning {
  align-self: flex-start;
  background: #fff3f6;
  border: 1px solid #ffc1d2;
  color: #8a1238;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--glass);
  border-radius: 18px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.stat-card span {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
}
.stat-card strong { font-size: 1.7rem; }
.stat-card .stat-sub {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.admin-panels {
  display: grid;
  grid-template-columns: 1.1fr 1.4fr;
  gap: 1rem;
}
.panel {
  background: var(--glass);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.panel-wide { grid-column: 1 / -1; }
.panel h2 { margin: 0 0 0.85rem; font-size: 1.1rem; }
.table-wrap { overflow: auto; max-height: 360px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid #ececec;
  vertical-align: top;
}
th { color: var(--muted); font-size: 0.8rem; }
.clip { max-width: 280px; }

@media (max-width: 900px) {
  .role-grid,
  .stat-grid,
  .admin-panels {
    grid-template-columns: 1fr;
  }
  .bubble { max-width: 92%; }
  .brand span, .brand-text strong { font-size: 0.95rem; }
}
