:root {
  --bg: #f5f5ef;
  --panel: #fffdfa;
  --ink: #101820;
  --muted: #5f6a72;
  --accent: #0f766e;
  --accent-2: #ef7d57;
  --ok: #1f9d68;
  --line: #d4d8d9;
  --shadow: 0 18px 40px rgba(16, 24, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 80% -10%, #f8e9d8 0%, transparent 45%),
    radial-gradient(circle at 10% -20%, #d9efe9 0%, transparent 45%), var(--bg);
}

.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(15, 118, 110, 0.08), transparent 32%),
    linear-gradient(290deg, rgba(239, 125, 87, 0.08), transparent 28%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  backdrop-filter: blur(8px);
  background: rgba(245, 245, 239, 0.78);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-badge {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  background: var(--ink);
  color: #f8f4ef;
  border-radius: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.brand strong {
  display: block;
  font-size: 1.05rem;
}

.brand small {
  color: var(--muted);
}

nav a {
  text-decoration: none;
  color: var(--ink);
  margin-left: 1.1rem;
  font-weight: 600;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem;
}

.hero {
  margin: 1rem 0 1.8rem;
  padding: 1.8rem;
  border-radius: 22px;
  background: linear-gradient(135deg, #0f766e, #1f4f7e 72%);
  color: #f4f9f9;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  grid-template-areas: "copy filter";
  gap: 1rem;
  align-items: start;
}

.hero > div {
  grid-area: copy;
  min-width: 0;
}

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  margin: 0 0 0.4rem;
  color: #b9ece1;
}

.hero h1 {
  margin: 0;
  font-family: "Source Serif 4", serif;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  white-space: nowrap;
}

.hero p {
  max-width: 62ch;
  opacity: 0.93;
}

.domain-filter {
  grid-area: filter;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  padding: 0.75rem;
  align-self: start;
  justify-self: end;
  width: 100%;
  max-width: 360px;
  display: grid;
  gap: 0.5rem;
}

.domain-filter label {
  display: block;
  margin-bottom: 0.1rem;
  font-size: 0.85rem;
}

.domain-filter button[type="submit"] {
  margin-top: 0.2rem;
}

select,
textarea,
input,
button {
  font: inherit;
}

select,
textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.7rem;
  background: #fffcf8;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.kpi-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 1rem;
}

.kpi-card h2 {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.kpi-card p {
  margin: 0.5rem 0 0;
  font-size: 2rem;
  font-weight: 800;
}

.kpi-card.warn p {
  color: #b74b2c;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1rem;
}

.panel {
  padding: 1rem;
  margin-bottom: 1rem;
}

.panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.panel h3 {
  margin: 0;
  font-size: 1rem;
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.bar-list,
.tag-cloud,
.quick-prompts {
  list-style: none;
  padding: 0;
  margin: 0.8rem 0 0;
}

.bar-list li {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
  position: relative;
  align-items: center;
}

.bar-list i {
  grid-column: 1 / -1;
  display: block;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #5abfb0);
}

.tag-cloud li {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0.45rem 0.5rem 0;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8faf8;
}

.trend-bars-wrap {
  margin-top: 0.8rem;
}

.trend-bars-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-items: end;
  gap: 0.5rem;
  min-height: 180px;
  position: relative;
}

.trend-bars-grid::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.2rem;
  height: 118px;
  pointer-events: none;
  background: repeating-linear-gradient(
    to top,
    rgba(95, 106, 114, 0.22) 0,
    rgba(95, 106, 114, 0.22) 1px,
    transparent 1px,
    transparent 29px
  );
}

.trend-bar-item {
  display: grid;
  justify-items: center;
  align-items: end;
  gap: 0.35rem;
  position: relative;
  z-index: 1;
}

.trend-bar-track {
  height: 118px;
  width: min(28px, 80%);
  display: flex;
  align-items: flex-end;
}

.trend-bar-item strong {
  font-size: 0.86rem;
  color: #2d363c;
}

.trend-bar-item i {
  display: block;
  width: 100%;
  min-height: 4px;
  border-radius: 10px;
  background: linear-gradient(180deg, #ef7d57, #f1b17a);
}

.trend-bar-item small {
  color: var(--muted);
  font-size: 0.7rem;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.8rem;
}

.column-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.8rem;
  margin-top: 0.7rem;
  align-items: center;
}

.column-controls-title {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.column-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.86rem;
  line-height: 1.2;
  white-space: nowrap;
}

.column-controls input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  flex: 0 0 auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.65rem;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 0.82rem;
}

.materia-toggle {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.materia-toggle:hover {
  color: var(--accent);
}

.ementa-row td {
  background: #faf8f2;
}

.ementa-text {
  margin: 0.4rem 0 0;
  color: #2d363c;
  line-height: 1.45;
}

.pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #edf0f1;
  font-size: 0.8rem;
}

.pill.ok {
  background: #d9f4e8;
  color: #0a6b44;
}

.running-badge {
  background: #fff3cd;
  color: #7a5800;
  animation: pulse 1.6s ease-in-out infinite;
}

.warn-pill {
  background: #fff3cd;
  color: #7a5800;
}

.err-pill {
  background: #fde8e8;
  color: #b74b2c;
}

.err-text {
  color: #b74b2c;
}

.muted-label {
  color: var(--muted);
  font-size: 0.85rem;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
}

.chat-sidebar h3,
.chat-sidebar h4 {
  margin-top: 0;
}

.ghost-btn {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fffcf8;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
}

.ghost-btn:hover {
  border-color: var(--accent);
}

.chat-main {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 560px;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 62vh;
  overflow: auto;
  padding-right: 0.4rem;
}

.bubble {
  max-width: 85%;
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  line-height: 1.45;
  border: 1px solid var(--line);
}

.bubble.user {
  align-self: flex-end;
  background: #ddeef8;
}

.bubble.assistant {
  align-self: flex-start;
  background: #f7f4ef;
}

.chat-form {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
}

button[type="submit"] {
  border: 0;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--accent), #1f4f7e);
  color: white;
  padding: 0.7rem 1rem;
  font-weight: 700;
  cursor: pointer;
}

.empty {
  color: var(--muted);
}

.alert {
  margin: 0.75rem 0;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 0.92rem;
}

.feature-notice {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.feature-notice[hidden] {
  display: none;
}

.feature-notice__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.48);
  backdrop-filter: blur(4px);
}

.feature-notice__card {
  position: relative;
  width: min(480px, 100%);
  padding: 1.35rem;
  border-radius: 22px;
  border: 1px solid rgba(181, 94, 32, 0.2);
  background: linear-gradient(180deg, #fffdf6 0%, #fff4dd 100%);
  box-shadow: 0 22px 60px rgba(64, 37, 8, 0.22);
}

.feature-notice__eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9a5c12;
}

.feature-notice__card h3 {
  margin: 0;
  font-size: 1.45rem;
}

.feature-notice__card p:last-of-type {
  margin: 0.6rem 0 0;
  color: #704414;
}

.feature-notice__card button {
  margin-top: 1rem;
}

.alert-warning {
  background: #fff5da;
  border-color: #f1d38f;
  color: #7a5800;
}

.alert-error {
  background: #fde8e8;
  border-color: #f3b2b2;
  color: #8a1f1f;
}

.alert-info {
  background: #edf7ff;
  border-color: #b8dcf8;
  color: #1f4f7e;
}

.auth-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 170px);
  padding: 1.2rem 0;
}

.auth-wrap.auth-glass {
  position: relative;
  isolation: isolate;
}

.auth-wrap.auth-glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 26px;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.24) 0%, rgba(239, 125, 87, 0.2) 100%);
  z-index: -1;
}

.auth-wrap.auth-glass::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.38) 0%, rgba(255, 255, 255, 0) 72%);
  top: 8%;
  right: 8%;
  z-index: -1;
}

.auth-card.auth-card-glass {
  width: min(430px, 100%);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.26);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 44px rgba(16, 24, 32, 0.2);
}

.glass-header {
  text-align: center;
  margin-bottom: 1rem;
}

.glass-header .kicker {
  margin: 0;
  color: #0f766e;
}

.glass-header h1 {
  margin: 0.1rem 0 0;
  font-size: clamp(1.7rem, 5vw, 2.1rem);
}

.glass-header p {
  margin-top: 0.45rem;
  color: #35565a;
}

.auth-form.auth-form-glass {
  gap: 0.85rem;
}

.glass-field {
  display: grid;
  gap: 0.38rem;
}

.glass-field label {
  font-size: 0.88rem;
  color: #1e3f42;
  font-weight: 700;
}

.glass-field input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.68);
  color: #23383b;
  padding: 0.72rem 0.78rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.glass-field input:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.82);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
  transform: translateY(-1px);
}

.auth-form-row {
  display: flex;
  justify-content: flex-end;
}

.forgot-link {
  color: #0f766e;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 700;
  transition: color 0.2s ease;
}

.forgot-link:hover {
  color: #0b5d57;
}

.auth-form.auth-form-glass button {
  min-height: 50px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0f766e 0%, #1f4f7e 100%);
  box-shadow: 0 14px 26px rgba(15, 118, 110, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.auth-form.auth-form-glass button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(15, 118, 110, 0.35);
  filter: brightness(1.03);
}

.auth-form.auth-form-glass button:active {
  transform: translateY(0);
}

.auth-wrap.auth-eco {
  position: relative;
  overflow: hidden;
}

.auth-wrap.auth-eco::before,
.auth-wrap.auth-eco::after {
  content: "";
  position: absolute;
  pointer-events: none;
  width: 220px;
  height: 220px;
  border-radius: 24% 76% 33% 67% / 41% 30% 70% 59%;
  background: radial-gradient(circle at 30% 30%, rgba(139, 195, 74, 0.26), rgba(76, 175, 80, 0.06));
  animation: floatLeaf 10s ease-in-out infinite;
}

.auth-wrap.auth-eco::before {
  top: 4%;
  left: 4%;
}

.auth-wrap.auth-eco::after {
  bottom: 4%;
  right: 2%;
  animation-delay: 2s;
}

.auth-card.auth-card-eco {
  width: min(470px, 100%);
  position: relative;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(76, 175, 80, 0.25);
  border-radius: 30px;
  box-shadow: 0 22px 45px rgba(76, 122, 90, 0.18);
  overflow: hidden;
}

.auth-card {
  padding: 1.45rem;
}

.organic-border {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  border-radius: 30px 30px 0 0;
  background: linear-gradient(90deg, #4caf50, #8bc34a, #66bb6a, #4caf50);
  background-size: 200% 100%;
  animation: organicFlow 4s ease-in-out infinite;
}

.mindful-header {
  text-align: center;
  margin: 0.3rem 0 1.05rem;
}

.zen-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 0.95rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #4caf50;
  position: relative;
}

.zen-logo::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 195, 74, 0.28) 0%, transparent 72%);
  animation: zenGlow 3s ease-in-out infinite;
}

.zen-logo svg {
  position: relative;
  z-index: 1;
  animation: zenBreath 4s ease-in-out infinite;
}

.auth-card h1 {
  margin: 0.15rem 0 0;
  font-family: "Source Serif 4", serif;
  font-size: clamp(1.5rem, 4vw, 2rem);
}

.auth-card p {
  margin: 0.7rem 0 0;
}

.auth-card .kicker {
  color: #2e7d32;
  margin: 0;
  font-weight: 800;
}

.auth-form {
  margin-top: 1rem;
  display: grid;
  gap: 0.55rem;
}

.auth-form label {
  font-weight: 700;
  font-size: 0.92rem;
}

.auth-form input {
  background: #fff;
}

.auth-form.auth-form-eco {
  gap: 0.8rem;
}

.organic-field {
  position: relative;
}

.field-nature {
  position: absolute;
  inset: 0;
  background: rgba(76, 175, 80, 0.05);
  border: 1.5px solid rgba(76, 175, 80, 0.24);
  border-radius: 18px;
  transition: all 0.25s ease;
}

.organic-field input {
  position: relative;
  z-index: 2;
  background: transparent;
  border: 0;
  border-radius: 18px;
  padding: 1rem 0.95rem 0.45rem;
  color: #2e7d32;
}

.organic-field label {
  position: absolute;
  z-index: 3;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: #4f8f53;
  font-weight: 600;
  pointer-events: none;
  transition: all 0.25s ease;
  background: rgba(255, 255, 255, 0.84);
  padding: 0 0.35rem;
}

.organic-field:focus-within .field-nature {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.11);
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.16);
}

.organic-field:focus-within label,
.organic-field input:not(:placeholder-shown) + label,
.organic-field input:valid + label {
  top: 0;
  transform: translateY(-50%);
  color: #2e7d32;
  font-size: 0.8rem;
}

.auth-form.auth-form-eco button {
  min-height: 52px;
  border-radius: 18px;
  background: linear-gradient(135deg, #4caf50, #66bb6a, #8bc34a);
  box-shadow: 0 12px 22px rgba(76, 175, 80, 0.24);
}

.auth-form.auth-form-eco button:hover {
  filter: saturate(1.05);
  transform: translateY(-1px);
}

.auth-footnote {
  margin: 1rem 0 0;
  text-align: center;
  color: #4f8f53;
  font-size: 0.92rem;
}

.auth-footnote a {
  color: #2e7d32;
  font-weight: 700;
}

.auth-card-admin-eco {
  border-color: rgba(64, 122, 140, 0.28);
}

.auth-card-admin-eco .organic-border {
  background: linear-gradient(90deg, #1f4f7e, #2d7a91, #45a081, #1f4f7e);
}

.auth-card-admin-eco .zen-logo {
  color: #2d7a91;
}

.auth-card-admin-eco .auth-form.auth-form-eco button {
  background: linear-gradient(135deg, #1f4f7e, #2d7a91, #45a081);
  box-shadow: 0 12px 22px rgba(31, 79, 126, 0.24);
}

.auth-form button {
  margin-top: 0.35rem;
}

.pagination {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fffcf8;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.page-link.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page-link.disabled,
.page-link.ellipsis {
  color: var(--muted);
  pointer-events: none;
}

.reveal {
  animation: rise 0.55s ease both;
}

.reveal-stagger > * {
  animation: rise 0.55s ease both;
}

.reveal-stagger > *:nth-child(2) {
  animation-delay: 0.06s;
}

.reveal-stagger > *:nth-child(3) {
  animation-delay: 0.12s;
}

.reveal-stagger > *:nth-child(4) {
  animation-delay: 0.18s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes organicFlow {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes zenBreath {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes zenGlow {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(1);
  }
  50% {
    opacity: 0.82;
    transform: scale(1.2);
  }
}

@keyframes floatLeaf {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.32;
  }
  50% {
    transform: translateY(-18px) rotate(8deg);
    opacity: 0.58;
  }
}

@media (max-width: 980px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-grid,
  .chat-layout,
  .hero {
    grid-template-columns: 1fr;
    grid-template-areas:
      "copy"
      "filter";
  }

  .hero h1 {
    white-space: normal;
  }

  .domain-filter {
    justify-self: stretch;
    max-width: none;
  }

  .chat-main {
    min-height: 430px;
  }

  .topbar {
    padding: 0.9rem 1rem;
  }

  .container {
    padding: 1rem;
  }

  .auth-wrap.auth-eco::before,
  .auth-wrap.auth-eco::after {
    width: 150px;
    height: 150px;
  }
}
