:root {
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-smooth: cubic-bezier(.16, 1, .3, 1);
  --black: #191919;
  --panel: #1a1a1a;
  --muted: rgba(255, 255, 255, .62);
  --shadow: 0 22px 45px rgba(0, 0, 0, .22), 0 8px 16px rgba(0, 0, 0, .12);
  --page-pad: clamp(18px, 3vw, 42px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  color: #111;
  background: #fff;
  font-family: Inter, Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: fixed;
  z-index: 50;
  inset: 0 0 auto;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.brand {
  font-size: clamp(14px, 1.15vw, 18px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.035em;
}

.icon-btn {
  position: absolute;
  top: 21px;
  width: 32px;
  height: 32px;
  padding: 2px;
  color: #050505;
  background: transparent;
  pointer-events: auto;
  transition: transform .25s var(--ease), opacity .25s ease;
}

.icon-btn:hover {
  transform: scale(1.06);
}

.icon-btn:active {
  transform: scale(.95);
}

.icon-btn:first-child {
  left: var(--page-pad);
}

.icon-btn:last-child {
  right: var(--page-pad);
}

.icon-btn img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.stage {
  position: relative;
  min-height: 100svh;
  padding: 92px var(--page-pad) 42px;
  display: grid;
  place-items: center;
}

.ambient {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% 38%, rgba(0, 0, 0, .055), transparent 24%),
    radial-gradient(circle at 50% 78%, rgba(0, 0, 0, .035), transparent 34%);
  opacity: 0;
  transition: opacity .7s var(--ease);
  pointer-events: none;
}

.hero {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: calc(50% - 170px);
  width: 180px;
  height: 142px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  transition:
    top .85s var(--ease),
    transform .85s var(--ease),
    width .85s var(--ease),
    height .85s var(--ease);
}

.hero-gif {
  position: absolute;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, .14));
  transition: opacity .48s var(--ease), transform .85s var(--ease);
  will-change: transform, opacity;
}

.hero-laptop {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.hero-clip,
.hero-briefcase {
  opacity: 0;
  transform: translateY(22px) scale(.86);
}

.control-card {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 50%;
  width: 320px;
  height: 78px;
  overflow: hidden;
  border-radius: 22px;
  background: var(--black);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
  transition:
    width .82s var(--ease),
    height .82s var(--ease),
    border-radius .82s var(--ease),
    top .82s var(--ease),
    transform .82s var(--ease),
    opacity .5s var(--ease);
  will-change: width, height, transform, top;
}

.add-btn,
.bot-pill {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: #fff;
  background: transparent;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .01em;
  transition: opacity .35s ease, transform .55s var(--ease);
}

.add-btn:hover {
  transform: scale(1.025);
}

.setup-form {
  position: absolute;
  inset: 0;
  padding: 30px 54px 38px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .36s ease;
}

.form-head {
  margin-bottom: 28px;
  text-align: center;
  opacity: 0;
  transform: translateY(12px);
  transition: .58s var(--ease);
}

.form-head h1 {
  margin: 0 0 6px;
  font-size: 16px;
}

.form-head p {
  min-height: 34px;
  margin: 0;
  color: rgba(255, 255, 255, .45);
  font-size: 15px;
  line-height: 1.14;
}

.form-head p.error {
  color: #ffb1b1;
}

.field-wrap {
  display: block;
  margin-bottom: 24px;
  opacity: 0;
  transform: translateY(16px);
  transition: .62s var(--ease);
}

.field-wrap:nth-of-type(1) {
  transition-delay: .08s;
}

.field-wrap:nth-of-type(2) {
  transition-delay: .15s;
}

.field-wrap > span {
  display: block;
  margin: 0 0 8px 22px;
  font-size: 15px;
  font-weight: 900;
}

.field {
  height: 50px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  border-radius: 999px;
  background: linear-gradient(90deg, #f4f4f4 0%, #ededed 54%, #7f7f7f 100%);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .8), 0 8px 18px rgba(0, 0, 0, .2);
}

.field img {
  width: 32px;
  height: 32px;
  margin-right: 14px;
  object-fit: contain;
}

.field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: #262626;
  background: transparent;
  font-size: 15px;
}

.field input::placeholder {
  color: #666;
}

.next-btn {
  height: 54px;
  margin-top: 15px;
  border-radius: 15px;
  color: #111;
  background: #9d9d9d;
  font-size: 16px;
  font-weight: 900;
  opacity: 0;
  transform: translateY(18px);
  transition: .64s var(--ease), background .2s ease;
}

.next-btn:hover {
  background: #b5b5b5;
}

.next-btn:disabled {
  cursor: wait;
  opacity: .5 !important;
}

.stars-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(.82);
  pointer-events: none;
  transition: .55s var(--ease);
}

.stars-layer img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.bot-pill {
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  opacity: 0;
  pointer-events: none;
}

.bot-title {
  max-width: 180px;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: rgba(255, 255, 255, .45);
  font-size: 14px;
  font-weight: 500;
  text-align: right;
}

.dashboard {
  width: min(1500px, 100%);
  padding-top: 110px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(42px) scale(.985);
  transition: opacity .72s var(--ease), transform .85s var(--ease);
}

.dashboard-context {
  margin-bottom: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: #777;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
}

.dashboard-context h1 {
  margin: 0;
  font-size: clamp(24px, 3.4vw, 46px);
  line-height: 1;
  letter-spacing: -.05em;
}

.live-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #777;
  font-size: 12px;
}

.live-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .05);
}

.live-status i.online {
  background: #2ba76c;
  box-shadow: 0 0 0 4px rgba(43, 167, 108, .12);
}

.metric-grid {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
}

.metric-card,
.panel {
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #1b1b1b, #141414);
  box-shadow: 0 18px 30px rgba(0, 0, 0, .19), inset 0 1px 0 rgba(255, 255, 255, .06);
}

.metric-card {
  min-height: 130px;
  padding: 25px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.metric-card p,
.panel h2 {
  margin: 0;
  color: rgba(255, 255, 255, .82);
  font-size: 15px;
  font-weight: 600;
}

.metric-card strong {
  display: inline-block;
  margin-top: 15px;
  font-size: 33px;
  line-height: .95;
  letter-spacing: -.035em;
}

.metric-card > div:first-child > span {
  margin-left: 6px;
  font-size: 22px;
}

.metric-card small {
  display: block;
  margin-top: 17px;
  color: rgba(255, 255, 255, .65);
  font-size: 13px;
}

.metric-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: rgba(255, 255, 255, .13);
  font-size: 30px;
}

.dash-grid {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.panel {
  padding: 24px;
}

.chart-panel,
.donut-panel {
  height: 315px;
}

.wide-panel {
  height: 210px;
}

.panel-head {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-head > span {
  color: rgba(255, 255, 255, .52);
  font-size: 12px;
}

.panel canvas {
  width: 100%;
  height: calc(100% - 34px);
  display: block;
}

.donut-layout {
  height: calc(100% - 22px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 20px;
}

.legend {
  display: grid;
  gap: 20px;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 13px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
}

.legend-row span:nth-child(3) {
  min-width: 36px;
  text-align: right;
}

.legend-row span:nth-child(4) {
  min-width: 34px;
  color: rgba(255, 255, 255, .65);
  text-align: right;
}

.reveal {
  opacity: 0;
  transform: translateY(32px) scale(.965);
  transition: opacity .72s var(--ease), transform .82s var(--ease);
  transition-delay: var(--d);
}

body[data-state="setup"] .ambient,
body[data-state="creating"] .ambient,
body[data-state="dashboard"] .ambient {
  opacity: 1;
}

body[data-state="setup"] .control-card,
body[data-state="creating"] .control-card {
  top: 52%;
  width: min(500px, calc(100vw - 34px));
  height: min(470px, calc(100svh - 170px));
  border-radius: 22px;
}

body[data-state="setup"] .add-btn,
body[data-state="creating"] .add-btn {
  opacity: 0;
  transform: scale(.92);
  pointer-events: none;
}

body[data-state="setup"] .setup-form {
  opacity: 1;
  pointer-events: auto;
}

body[data-state="setup"] .form-head,
body[data-state="setup"] .field-wrap,
body[data-state="setup"] .next-btn {
  opacity: 1;
  transform: translateY(0);
}

body[data-state="setup"] .hero,
body[data-state="creating"] .hero {
  top: calc(50% - 250px);
  transform: translate(-50%, -50%) scale(1.04);
}

body[data-state="setup"] .hero-laptop,
body[data-state="creating"] .hero-laptop {
  opacity: 0;
  transform: translateY(-46px) scale(.82) rotate(-5deg);
}

body[data-state="setup"] .hero-clip,
body[data-state="creating"] .hero-clip {
  opacity: 1;
  transform: translateY(-4px) scale(1.05) rotate(-10deg);
}

body[data-state="creating"] .setup-form {
  opacity: .12;
  pointer-events: none;
}

body[data-state="creating"] .stars-layer {
  opacity: 1;
  transform: scale(1);
}

body[data-state="bot"] .control-card {
  width: 320px;
  height: 78px;
}

body[data-state="bot"] .add-btn,
body[data-state="bot"] .setup-form {
  opacity: 0;
  pointer-events: none;
}

body[data-state="bot"] .bot-pill {
  opacity: 1;
  pointer-events: auto;
}

body[data-state="dashboard"] .stage {
  display: block;
}

body[data-state="dashboard"] .hero {
  top: 125px;
  width: 140px;
  height: 108px;
  transform: translate(-50%, -50%) scale(1);
  animation: briefFloat 4s ease-in-out infinite;
}

body[data-state="dashboard"] .hero-laptop,
body[data-state="dashboard"] .hero-clip {
  opacity: 0;
  transform: translateY(-30px) scale(.85);
}

body[data-state="dashboard"] .hero-briefcase {
  opacity: 1;
  transform: translateY(0) scale(1);
}

body[data-state="dashboard"] .control-card {
  top: 155px;
  width: 260px;
  height: 58px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.92);
  pointer-events: none;
}

body[data-state="dashboard"] .dashboard {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

body[data-state="dashboard"] .reveal {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@keyframes briefFloat {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(-1.4deg);
  }
  50% {
    transform: translate(-50%, -54%) rotate(1.4deg);
  }
}

@media (max-width: 1200px) {
  .dashboard {
    padding-top: 105px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dash-grid {
    grid-template-columns: 1fr;
  }

  .chart-panel,
  .donut-panel {
    height: 300px;
  }
}

@media (max-width: 720px) {
  .topbar {
    height: 62px;
  }

  .icon-btn {
    top: 16px;
    width: 28px;
    height: 28px;
  }

  .stage {
    padding-top: 78px;
  }

  .hero {
    top: calc(50% - 132px);
    width: 135px;
    height: 112px;
  }

  .control-card {
    width: 280px;
    height: 68px;
    border-radius: 19px;
  }

  body[data-state="setup"] .hero,
  body[data-state="creating"] .hero {
    top: calc(50% - 245px);
    width: 120px;
    height: 100px;
  }

  body[data-state="setup"] .control-card,
  body[data-state="creating"] .control-card {
    top: 53%;
    height: min(430px, calc(100svh - 145px));
    border-radius: 20px;
  }

  .setup-form {
    padding: 26px 24px 30px;
  }

  .form-head p {
    font-size: 13px;
  }

  .field-wrap > span {
    margin-left: 14px;
  }

  .field {
    height: 48px;
    padding: 0 16px;
  }

  .next-btn {
    height: 50px;
  }

  .dashboard {
    padding-top: 95px;
  }

  .dashboard-context {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .metric-card {
    min-height: 108px;
    padding: 20px;
  }

  .dash-grid {
    gap: 14px;
  }

  .chart-panel,
  .donut-panel {
    height: 330px;
  }

  .wide-panel {
    height: 230px;
  }

  .donut-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .donut-layout canvas {
    height: 170px !important;
  }

  .legend {
    gap: 10px;
  }

  .panel {
    padding: 18px;
  }

  body[data-state="dashboard"] .hero {
    top: 85px;
    width: 86px;
    height: 72px;
  }
}

@media (max-height: 760px) and (min-width: 721px) {
  .hero {
    top: calc(50% - 135px);
  }

  body[data-state="setup"] .hero,
  body[data-state="creating"] .hero {
    top: calc(50% - 225px);
  }

  body[data-state="setup"] .control-card,
  body[data-state="creating"] .control-card {
    height: 430px;
  }

  .setup-form {
    padding-top: 24px;
    padding-bottom: 30px;
  }

  .field-wrap {
    margin-bottom: 18px;
  }

  .form-head {
    margin-bottom: 20px;
  }

  .next-btn {
    margin-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}


/* Mobile/PWA shell ------------------------------------------------------- */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html,
body {
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

button {
  touch-action: manipulation;
}

.topbar {
  height: calc(72px + var(--safe-top));
  padding-top: var(--safe-top);
}

.icon-btn {
  top: calc(21px + var(--safe-top));
}

.icon-btn.left-action {
  left: max(var(--page-pad), calc(var(--safe-left) + 12px));
}

.icon-btn.right-action {
  right: max(var(--page-pad), calc(var(--safe-right) + 12px));
}

.nav-back {
  display: none;
  place-items: center;
  padding: 4px;
}

.nav-back svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stage {
  min-height: 100dvh;
  padding-top: calc(92px + var(--safe-top));
  padding-right: max(var(--page-pad), calc(var(--safe-right) + 18px));
  padding-bottom: calc(42px + var(--safe-bottom));
  padding-left: max(var(--page-pad), calc(var(--safe-left) + 18px));
}

/* The hidden dashboard used to stretch .stage and move the whole intro
   below the visual center, especially on tall phone layouts. */
.dashboard {
  display: none;
}

body[data-state="empty"],
body[data-state="setup"],
body[data-state="creating"],
body[data-state="bot"] {
  height: 100dvh;
  overflow: hidden;
}

body[data-state="dashboard"] .stage {
  min-height: 100dvh;
  padding-top: calc(88px + var(--safe-top));
}

body[data-state="dashboard"] .dashboard {
  display: block;
  padding-top: 0;
  padding-bottom: calc(24px + var(--safe-bottom));
}

body[data-state="dashboard"] .hero {
  display: none;
}

body[data-state="dashboard"] #backBtn {
  display: grid;
}

body[data-state="dashboard"] #settingsBtn {
  display: none;
}

body[data-state="dashboard"] .topbar {
  border-bottom: 1px solid rgba(0, 0, 0, .06);
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  backdrop-filter: blur(18px) saturate(1.25);
}

@media (max-width: 720px) {
  :root {
    --page-pad: 16px;
  }

  .topbar {
    height: calc(64px + var(--safe-top));
  }

  .brand {
    max-width: 58vw;
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .icon-btn {
    top: calc(10px + var(--safe-top));
    width: 44px;
    height: 44px;
    padding: 9px;
  }

  .stage {
    min-height: 100dvh;
    padding-top: calc(72px + var(--safe-top));
    padding-right: max(16px, calc(var(--safe-right) + 16px));
    padding-bottom: calc(20px + var(--safe-bottom));
    padding-left: max(16px, calc(var(--safe-left) + 16px));
  }

  .control-card {
    width: min(300px, calc(100vw - 32px));
  }

  body[data-state="setup"] .control-card,
  body[data-state="creating"] .control-card {
    top: 50%;
    width: min(500px, calc(100vw - 32px));
    height: min(430px, calc(100dvh - var(--safe-top) - var(--safe-bottom) - 92px));
  }

  body[data-state="setup"] .hero,
  body[data-state="creating"] .hero {
    display: none;
  }

  .setup-form {
    padding: 24px 22px 26px;
  }

  .form-head {
    margin-bottom: 22px;
  }

  .field-wrap {
    margin-bottom: 20px;
  }

  .field {
    min-height: 50px;
  }

  .field input {
    font-size: 16px;
  }

  .next-btn {
    min-height: 50px;
    margin-top: 8px;
  }

  body[data-state="dashboard"] .stage {
    padding-top: calc(76px + var(--safe-top));
  }

  body[data-state="dashboard"] .dashboard {
    width: 100%;
    padding-top: 10px;
  }

  .dashboard-context {
    margin-bottom: 16px;
    gap: 10px;
  }

  .dashboard-context h1 {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: clamp(28px, 9vw, 40px);
  }

  .live-status {
    padding: 7px 10px;
    border-radius: 999px;
    background: #f4f4f4;
    font-size: 11px;
  }

  .metric-grid,
  .dash-grid {
    gap: 12px;
  }

  .metric-card,
  .panel {
    border-radius: 18px;
  }

  .metric-card {
    min-height: 104px;
    padding: 18px;
  }

  .metric-card strong {
    font-size: 31px;
  }

  .metric-icon {
    width: 44px;
    height: 44px;
    font-size: 26px;
  }

  .panel {
    padding: 17px;
  }

  .panel-head {
    align-items: flex-start;
    gap: 10px;
  }

  .panel-head > span {
    max-width: 48%;
    text-align: right;
  }

  .chart-panel {
    height: 300px;
  }

  .donut-panel {
    height: 350px;
  }

  .wide-panel {
    height: 230px;
  }

  .donut-layout canvas {
    height: 165px !important;
  }
}

@media (max-width: 380px) {
  .setup-form {
    padding-right: 18px;
    padding-left: 18px;
  }

  .field {
    padding: 0 14px;
  }

  .field img {
    width: 28px;
    height: 28px;
    margin-right: 10px;
  }

  .metric-card p,
  .panel h2 {
    font-size: 14px;
  }
}

@media (max-width: 720px) and (max-height: 700px) {
  body[data-state="setup"] .control-card,
  body[data-state="creating"] .control-card {
    height: min(390px, calc(100dvh - var(--safe-top) - var(--safe-bottom) - 78px));
  }

  .form-head {
    margin-bottom: 14px;
  }

  .field-wrap {
    margin-bottom: 13px;
  }

  .next-btn {
    margin-top: 2px;
  }
}

@media (display-mode: standalone) {
  html,
  body,
  .stage {
    min-height: 100dvh;
  }

  .topbar {
    -webkit-user-select: none;
    user-select: none;
  }
}


/* App shell, settings and notifications --------------------------------- */
body.modal-open {
  overflow: hidden !important;
}

.app-overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(18px + var(--safe-top)) max(18px, var(--safe-right)) calc(18px + var(--safe-bottom)) max(18px, var(--safe-left));
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s ease;
}

.app-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .36);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.app-sheet {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(760px, calc(100dvh - var(--safe-top) - var(--safe-bottom) - 36px));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 28px;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 28px;
  color: #111;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .24);
  -webkit-overflow-scrolling: touch;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.sheet-eyebrow,
.settings-kicker {
  display: block;
  margin-bottom: 5px;
  color: #777;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
}

.sheet-head h2 {
  margin: 0;
  font-size: 27px;
  line-height: 1;
  letter-spacing: -.04em;
}

.sheet-close {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: currentColor;
  background: #f1f1f1;
  font-size: 29px;
  font-weight: 300;
  line-height: 1;
}

.settings-section {
  padding: 20px 0;
  border-top: 1px solid rgba(0, 0, 0, .09);
}

.settings-section-head {
  margin-bottom: 14px;
}

.settings-section h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -.02em;
}

.settings-count {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  margin-left: 5px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: #171717;
  font-size: 12px;
}

.theme-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 15px;
  background: #efefef;
}

.theme-switch button {
  min-height: 42px;
  border-radius: 11px;
  color: #555;
  background: transparent;
  font-size: 13px;
  font-weight: 800;
}

.theme-switch button.is-active {
  color: #fff;
  background: #171717;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .16);
}

.settings-bots {
  display: grid;
  gap: 8px;
}

.settings-bot-row {
  width: 100%;
  min-height: 62px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 15px;
  color: inherit;
  background: #f7f7f7;
  text-align: left;
}

.settings-bot-row > span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.settings-bot-row b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-bot-row small {
  color: #777;
  font-size: 11px;
}

.settings-bot-row i {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #c5c5c5;
}

.settings-bot-row.is-active {
  border-color: #171717;
  background: #fff;
}

.settings-bot-row.is-active i {
  background: #25a86b;
  box-shadow: 0 0 0 4px rgba(37, 168, 107, .12);
}

.settings-empty {
  padding: 16px;
  border: 1px dashed rgba(0, 0, 0, .16);
  border-radius: 14px;
  color: #777;
  font-size: 13px;
  line-height: 1.4;
}

.settings-primary {
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  border-radius: 14px;
  color: #fff;
  background: #171717;
  font-size: 13px;
  font-weight: 900;
}

.settings-actions {
  display: grid;
  gap: 8px;
}

.settings-action {
  width: 100%;
  min-height: 62px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 14px;
  color: inherit;
  background: #f5f5f5;
  text-align: left;
}

.settings-action span {
  display: grid;
  gap: 3px;
}

.settings-action small {
  color: #777;
  font-size: 11px;
}

.settings-action i {
  font-size: 27px;
  font-style: normal;
  font-weight: 300;
}

.settings-action:disabled {
  opacity: .42;
  cursor: default;
}

.settings-footnote {
  margin: 2px 0 0;
  color: #888;
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

.settings-toggles { display:grid; gap:2px; }
.settings-toggles label { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:11px 0; cursor:pointer; }
.settings-toggles label + label { border-top:1px solid rgba(127,127,127,.16); }
.settings-toggles label span { display:grid; gap:3px; }
.settings-toggles label b { font-size:12px; }
.settings-toggles label small { color:#858585; font-size:10px; line-height:1.35; }
.settings-toggles input { width:38px; height:22px; accent-color:#111; flex:0 0 auto; }
.settings-save-row { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:12px; }
.settings-save-row small { color:#777; font-size:10px; }
.settings-save-row small.error { color:#a83b22; }
.icon-btn.has-alerts::after { content:""; position:absolute; top:8px; right:8px; width:7px; height:7px; border:2px solid var(--surface,#fff); border-radius:50%; background:#f0523c; }

.notifications-sheet {
  width: min(500px, 100%);
}

.notification-empty {
  min-height: 280px;
  padding: 42px 20px 28px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.notification-empty-icon {
  width: 60px;
  height: 60px;
  margin-bottom: 18px;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 0;
}

.notification-empty-icon::after {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
}

.notification-empty h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.notification-empty p {
  max-width: 350px;
  margin: 0;
  color: #777;
  font-size: 13px;
  line-height: 1.5;
}

.notification-row {
  padding: 14px 0;
  border-top: 1px solid rgba(0, 0, 0, .08);
}

.notification-row b,
.notification-row small {
  display: block;
}

.notification-row small {
  margin-top: 5px;
  color: #777;
}

.pwa-install-hint {
  position: fixed;
  z-index: 140;
  right: max(14px, calc(var(--safe-right) + 10px));
  bottom: calc(14px + var(--safe-bottom));
  width: min(390px, calc(100vw - var(--safe-left) - var(--safe-right) - 28px));
  padding: 16px 44px 16px 17px;
  display: grid;
  gap: 5px;
  border-radius: 18px;
  color: #fff;
  background: rgba(20, 20, 20, .96);
  box-shadow: 0 16px 50px rgba(0, 0, 0, .3);
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: .28s var(--ease);
}

.pwa-install-hint.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.pwa-install-hint strong {
  font-size: 14px;
}

.pwa-install-hint span {
  color: rgba(255, 255, 255, .68);
  font-size: 12px;
  line-height: 1.4;
}

.pwa-install-hint button {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .1);
  font-size: 21px;
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  color: #f5f5f5;
  background: #0d0d0d;
}

html[data-theme="dark"] .ambient {
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, .055), transparent 24%),
    radial-gradient(circle at 50% 78%, rgba(255, 255, 255, .025), transparent 34%);
}

html[data-theme="dark"] .icon-btn img {
  filter: invert(1);
}

html[data-theme="dark"] .eyebrow,
html[data-theme="dark"] .live-status {
  color: #aaa;
}

html[data-theme="dark"] body[data-state="dashboard"] .topbar {
  border-color: rgba(255, 255, 255, .08);
  background: rgba(13, 13, 13, .88);
}

html[data-theme="dark"] .live-status {
  background: #1c1c1c;
}

html[data-theme="dark"] .app-sheet {
  border-color: rgba(255, 255, 255, .1);
  color: #f6f6f6;
  background: rgba(22, 22, 22, .98);
}

html[data-theme="dark"] .sheet-close,
html[data-theme="dark"] .settings-action,
html[data-theme="dark"] .settings-bot-row {
  background: #272727;
}

html[data-theme="dark"] .settings-section,
html[data-theme="dark"] .notification-row {
  border-color: rgba(255, 255, 255, .09);
}

html[data-theme="dark"] .theme-switch {
  background: #292929;
}

html[data-theme="dark"] .theme-switch button {
  color: #aaa;
}

html[data-theme="dark"] .theme-switch button.is-active {
  color: #111;
  background: #f3f3f3;
}

html[data-theme="dark"] .settings-count,
html[data-theme="dark"] .settings-primary {
  color: #111;
  background: #f1f1f1;
}

html[data-theme="dark"] .settings-bot-row.is-active {
  border-color: #f1f1f1;
  background: #202020;
}

html[data-theme="dark"] .settings-empty {
  border-color: rgba(255, 255, 255, .16);
}

@media (max-width: 720px) {
  .app-overlay {
    place-items: end center;
    padding: var(--safe-top) 0 0;
  }

  .app-sheet {
    width: 100%;
    max-height: calc(100dvh - var(--safe-top) - 8px);
    padding: 24px 20px calc(22px + var(--safe-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 26px 26px 0 0;
  }

  .sheet-head {
    position: sticky;
    z-index: 2;
    top: -24px;
    padding-top: 4px;
  }

  .theme-switch button {
    min-height: 46px;
    font-size: 12px;
  }

  .settings-bot-row,
  .settings-action,
  .settings-primary {
    min-height: 52px;
  }
}


/* Startup splash --------------------------------------------------------- */
.app-splash {
  position: fixed;
  z-index: 300;
  inset: 0;
  display: grid;
  place-items: center;
  background: #fff;
  opacity: 1;
  visibility: visible;
  pointer-events: none;
  transition: opacity .28s ease, visibility .28s ease;
  /* CSS-only circuit breaker: even mismatched/failed JS can never leave
     the application permanently covered by the splash. */
  animation: splashFailsafe 0s linear 3s forwards;
}

.app-splash img {
  width: clamp(128px, 34vw, 176px);
  height: clamp(128px, 34vw, 176px);
  display: block;
}

.app-splash.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  animation: none;
}

@keyframes splashFailsafe {
  to {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

html[data-theme="dark"] .app-splash {
  background: #0d0d0d;
}

html[data-theme="dark"] .app-splash img {
  filter: invert(1);
}

@media (prefers-reduced-motion: reduce) {
  .app-splash {
    /* The global reduced-motion rule uses animation:none!important. Keep the
       zero-motion splash circuit breaker alive so it can never cover the app. */
    animation: splashFailsafe 0s linear 3s forwards !important;
    transition: none;
  }
}


/* Account authentication ------------------------------------------------- */
body[data-auth-state="loading"] .topbar,
body[data-auth-state="loading"] .stage,
body[data-auth-state="loading"] .app-overlay,
body[data-auth-state="loading"] .pwa-install-hint,
body[data-auth-state="guest"] .topbar,
body[data-auth-state="guest"] .stage,
body[data-auth-state="guest"] .app-overlay,
body[data-auth-state="guest"] .pwa-install-hint {
  display: none !important;
}

body[data-auth-state="guest"] {
  min-height: 100dvh;
  overflow: auto;
  background: #dfe4ee;
}

.auth-gate {
  position: relative;
  z-index: 210;
  min-height: 100dvh;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: calc(30px + var(--safe-top)) max(20px, var(--safe-right)) calc(36px + var(--safe-bottom)) max(20px, var(--safe-left));
  color: #111827;
  background:
    radial-gradient(circle at 50% 20%, rgba(255,255,255,.65), transparent 32%),
    radial-gradient(circle at 22% 82%, rgba(255,255,255,.35), transparent 35%),
    #dfe4ee;
}

body[data-auth-state="guest"] .auth-gate {
  display: flex;
}

.auth-brand {
  flex: 0 0 auto;
  font-size: clamp(14px, 2vw, 18px);
  font-weight: 900;
  letter-spacing: .34em;
  line-height: 1;
  text-indent: .34em;
}

.auth-content {
  width: min(620px, 100%);
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 0 7vh;
  text-align: center;
}

.auth-sticker {
  width: clamp(190px, 33vw, 300px);
  height: clamp(165px, 28vw, 250px);
  margin-bottom: clamp(22px, 5vh, 48px);
  display: grid;
  place-items: center;
  filter: drop-shadow(0 26px 35px rgba(15, 23, 42, .16));
}

.auth-sticker img,
.auth-sticker > svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-eyebrow {
  margin-bottom: 10px;
  color: rgba(17, 24, 39, .5);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .24em;
}

.auth-content h1 {
  margin: 0;
  font-size: clamp(34px, 7vw, 64px);
  line-height: .98;
  letter-spacing: -.055em;
}

.auth-content > p {
  max-width: 560px;
  margin: 26px auto 30px;
  color: rgba(17, 24, 39, .74);
  font-size: clamp(15px, 2.3vw, 20px);
  line-height: 1.45;
}

.telegram-login-wrap {
  position: relative;
  width: min(360px, 100%);
  height: 58px;
}

.telegram-login-visual {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 17px;
  color: #fff;
  background: #111;
  box-shadow: 0 18px 34px rgba(17, 24, 39, .2);
  font-size: 16px;
  font-weight: 800;
}

.telegram-login-visual svg {
  width: 23px;
  height: 23px;
  fill: currentColor;
}

.telegram-login-widget {
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  opacity: .001;
}

.telegram-login-widget iframe {
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  min-height: 100% !important;
}

.auth-status {
  min-height: 20px;
  margin-top: 14px;
  color: rgba(17, 24, 39, .62);
  font-size: 12px;
}

.auth-status.error {
  color: #a22626;
}

.auth-content > small {
  color: rgba(17, 24, 39, .42);
  font-size: 11px;
}

.settings-account-handle {
  display: block;
  margin-top: 5px;
  color: #777;
  font-size: 12px;
}

.settings-secondary {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 14px;
  color: inherit;
  background: transparent;
  font-size: 12px;
  font-weight: 900;
}

html[data-theme="dark"] body[data-auth-state="guest"] {
  background: #111;
}

html[data-theme="dark"] .auth-gate {
  color: #f5f5f5;
  background:
    radial-gradient(circle at 50% 20%, rgba(255,255,255,.06), transparent 32%),
    #111;
}

html[data-theme="dark"] .auth-eyebrow,
html[data-theme="dark"] .auth-content > p,
html[data-theme="dark"] .auth-status,
html[data-theme="dark"] .auth-content > small {
  color: rgba(255, 255, 255, .58);
}

html[data-theme="dark"] .auth-sticker {
  filter: invert(1) drop-shadow(0 26px 35px rgba(0, 0, 0, .2));
}

html[data-theme="dark"] .telegram-login-visual {
  color: #111;
  background: #f3f3f3;
}

html[data-theme="dark"] .settings-secondary {
  border-color: rgba(255, 255, 255, .15);
}

@media (max-width: 720px) {
  .auth-gate {
    padding-top: calc(24px + var(--safe-top));
  }

  .auth-content {
    justify-content: center;
    padding-top: 18px;
    padding-bottom: max(24px, 5vh);
  }

  .auth-sticker {
    width: min(230px, 68vw);
    height: min(190px, 56vw);
    margin-bottom: 24px;
  }

  .auth-content h1 {
    max-width: 340px;
  }

  .auth-content > p {
    max-width: 390px;
    margin-top: 20px;
    margin-bottom: 24px;
    font-size: 15px;
  }

  .telegram-login-wrap {
    width: min(340px, 94%);
    height: 56px;
  }
}

@media (max-height: 720px) {
  .auth-sticker {
    width: 160px;
    height: 135px;
    margin-bottom: 14px;
  }

  .auth-content > p {
    margin-top: 14px;
    margin-bottom: 16px;
  }
}


.auth-bridge-content {
  max-width: 650px;
}

.galenite-login-btn {
  width: min(360px, 94%);
  min-height: 56px;
  border: 0;
  border-radius: 17px;
  color: #fff;
  background: #111;
  box-shadow: 0 18px 34px rgba(17,24,39,.2);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .08em;
}

html[data-theme="dark"] .galenite-login-btn {
  color: #111;
  background: #f3f3f3;
}

/* Knowledge workspace */
.dashboard-tabs {
  display: flex;
  gap: 8px;
  width: fit-content;
  margin: 10px 0 24px;
  padding: 5px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 15px;
  background: rgba(255,255,255,.06);
}

.dashboard-tabs button {
  min-height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 11px;
  color: rgba(255,255,255,.58);
  background: transparent;
  font: 800 11px/1 Arial, sans-serif;
  letter-spacing: .08em;
  cursor: pointer;
}

.dashboard-tabs button.active {
  color: #111;
  background: #f5f5f5;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}

.knowledge-workspace {
  display: grid;
  gap: 18px;
  padding-bottom: 48px;
}

.knowledge-workspace[hidden], #dashboardAnalytics[hidden] { display: none !important; }

.knowledge-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 30px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 26px;
  background: rgba(255,255,255,.055);
}

.knowledge-hero h2 { margin: 8px 0 10px; font-size: clamp(28px, 4vw, 52px); line-height: .98; letter-spacing: -.045em; }
.knowledge-hero p { max-width: 720px; margin: 0; color: rgba(255,255,255,.62); line-height: 1.55; }
.knowledge-state { flex: 0 0 auto; padding: 11px 14px; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; color: rgba(255,255,255,.76); background: rgba(255,255,255,.06); font-size: 10px; font-weight: 900; letter-spacing: .08em; }
.knowledge-state.error { color: rgba(255,255,255,.58); border-color: rgba(255,255,255,.12); background: transparent; }

.knowledge-card {
  padding: 24px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 24px;
  background: rgba(255,255,255,.055);
  box-shadow: 0 24px 60px rgba(0,0,0,.09);
}

.knowledge-card-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.knowledge-card-head > div { display: flex; align-items: center; gap: 11px; }
.knowledge-card-head span { color: rgba(255,255,255,.35); font-size: 11px; font-weight: 900; letter-spacing: .1em; }
.knowledge-card-head h3 { margin: 0; font-size: 20px; }
.knowledge-card-head small { color: rgba(255,255,255,.44); }
.knowledge-card-head > strong { display: grid; place-items: center; min-width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.10); }

.knowledge-card textarea,
.knowledge-card input,
.knowledge-card select,
.product-dialog textarea,
.product-dialog input,
.product-dialog select {
  width: 100%;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 14px;
  outline: none;
  color: #fff;
  background: rgba(0,0,0,.13);
  font: 500 14px/1.5 Arial, sans-serif;
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.knowledge-card textarea,
.product-dialog textarea { resize: vertical; padding: 14px 15px; }
.knowledge-card input,
.knowledge-card select,
.product-dialog input,
.product-dialog select { min-height: 46px; padding: 0 14px; }
.knowledge-card textarea:focus, .knowledge-card input:focus, .knowledge-card select:focus,
.product-dialog textarea:focus, .product-dialog input:focus, .product-dialog select:focus { border-color: rgba(255,255,255,.5); box-shadow: 0 0 0 3px rgba(255,255,255,.07); background: rgba(0,0,0,.2); }
.knowledge-card select option, .product-dialog select option { color: #111; }

.knowledge-actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 14px; }
.knowledge-message { min-height: 18px; margin-right: auto; color: rgba(255,255,255,.56); font-size: 12px; line-height: 1.45; }
.knowledge-message.error, .import-summary .error { color: #ffb4a8; }

.knowledge-button {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  color: #111;
  background: #f4f4f4;
  font: 900 10px/1 Arial, sans-serif;
  letter-spacing: .07em;
  cursor: pointer;
}
.knowledge-button.secondary { color: #fff; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.08); }
.knowledge-button.ghost { color: rgba(255,255,255,.65); border: 1px solid rgba(255,255,255,.12); background: transparent; }
.knowledge-button.ai { color: #111; background: #f4f4f4; }
.knowledge-button:disabled { opacity: .5; cursor: wait; }

.knowledge-columns { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr); gap: 18px; align-items: start; }
.knowledge-toolbar, .knowledge-form-row { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 10px; margin-bottom: 14px; }
.knowledge-list { display: grid; gap: 9px; max-height: 660px; overflow: auto; padding-right: 3px; }
.product-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; width: 100%; padding: 16px; border: 1px solid rgba(255,255,255,.10); border-radius: 16px; color: #fff; text-align: left; background: rgba(0,0,0,.10); cursor: pointer; }
.product-row:hover { border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.075); }
.product-row-main, .product-row-meta { display: flex; flex-direction: column; gap: 6px; }
.product-row-main small, .document-row small { color: rgba(255,255,255,.48); }
.product-row-meta { align-items: flex-end; font-size: 12px; }
.product-row-meta .status { padding: 5px 7px; border-radius: 7px; color: rgba(255,255,255,.55); background: rgba(255,255,255,.08); font: 900 8px/1 Arial, sans-serif; letter-spacing: .06em; }
.product-row-meta .status.published { color: #9effba; background: rgba(75,192,107,.12); }
.product-row-meta .status.archived { opacity: .55; }

.knowledge-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 190px; gap: 8px; padding: 30px; border: 1px dashed rgba(255,255,255,.16); border-radius: 18px; color: rgba(255,255,255,.55); text-align: center; }
.knowledge-empty b { color: rgba(255,255,255,.88); }
.knowledge-empty.compact { min-height: 120px; }

.document-uploader { display: grid; gap: 10px; margin-bottom: 16px; }
.file-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px 15px; border: 1px dashed rgba(255,255,255,.24); border-radius: 16px; color: rgba(255,255,255,.72); text-align: center; cursor: pointer; }
.file-drop:hover { border-color: rgba(255,255,255,.55); background: rgba(255,255,255,.04); }
.file-drop small { color: rgba(255,255,255,.4); }
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.knowledge-check { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.6); font-size: 12px; }
.knowledge-check input { width: 17px; min-height: 17px; accent-color: #fff; }
.document-row { display: grid; gap: 12px; padding: 14px; border: 1px solid rgba(255,255,255,.10); border-radius: 15px; background: rgba(0,0,0,.10); }
.document-row > div:first-child { display: flex; flex-direction: column; gap: 5px; }
.document-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.document-row-actions button { padding: 7px 9px; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; color: rgba(255,255,255,.65); background: rgba(255,255,255,.05); font: 800 8px/1 Arial, sans-serif; letter-spacing: .05em; cursor: pointer; }

.product-dialog, .import-dialog { width: min(900px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid rgba(255,255,255,.16); border-radius: 26px; color: #fff; background: #171717; box-shadow: 0 40px 120px rgba(0,0,0,.65); }
.product-dialog::backdrop, .import-dialog::backdrop { background: rgba(0,0,0,.68); backdrop-filter: blur(12px); }
.product-dialog-shell { display: grid; gap: 20px; max-height: calc(100dvh - 24px); padding: 25px; overflow: auto; }
.product-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.product-dialog-head h2 { margin: 7px 0 0; font-size: 28px; }
.product-dialog-head > button { width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; color: #fff; background: rgba(255,255,255,.06); font-size: 22px; cursor: pointer; }
.ai-product-box { display: grid; gap: 10px; padding: 16px; border: 1px solid rgba(255,255,255,.13); border-radius: 18px; background: rgba(255,255,255,.04); }
.ai-product-box label, .product-fields label { display: grid; gap: 7px; color: rgba(255,255,255,.55); font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.document-choices { display: flex; flex-wrap: wrap; gap: 7px; }
.document-choices label { position: relative; }
.document-choices label span { display: block; padding: 8px 10px; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; color: rgba(255,255,255,.58); background: rgba(0,0,0,.12); cursor: pointer; }
.document-choices input { position: absolute; opacity: 0; pointer-events: none; }
.document-choices input:checked + span { color: #111; border-color: #fff; background: #fff; }
.product-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.product-fields .wide { grid-column: 1 / -1; }
.product-dialog-actions { position: sticky; bottom: -25px; display: flex; justify-content: flex-end; gap: 9px; margin: 0 -25px -25px; padding: 15px 25px; border-top: 1px solid rgba(255,255,255,.10); background: rgba(23,23,23,.94); backdrop-filter: blur(15px); }
.import-summary { display: flex; flex-direction: column; gap: 7px; color: rgba(255,255,255,.58); }
.import-summary b { color: #fff; font-size: 20px; }
.import-preview { display: grid; gap: 7px; max-height: 50vh; overflow: auto; }
.import-preview article { display: grid; grid-template-columns: minmax(0,1fr) 150px 150px; gap: 12px; padding: 12px; border: 1px solid rgba(255,255,255,.09); border-radius: 12px; color: rgba(255,255,255,.55); }
.import-preview article b { color: #fff; }
.import-preview article strong { text-align: right; color: rgba(255,255,255,.78); }

/* Knowledge workspace: uses the same restrained monochrome language as Operator. */
:root {
  --knowledge-text: #111;
  --knowledge-muted: #6f6f6f;
  --knowledge-faint: #929292;
  --knowledge-surface: #fff;
  --knowledge-surface-soft: #f5f5f5;
  --knowledge-surface-hover: #ededed;
  --knowledge-border: rgba(0, 0, 0, .13);
  --knowledge-border-strong: rgba(0, 0, 0, .32);
  --knowledge-button: #171717;
  --knowledge-button-text: #fff;
  --knowledge-shadow: 0 16px 34px rgba(0, 0, 0, .08);
}

html[data-theme="dark"] {
  --knowledge-text: #f4f4f4;
  --knowledge-muted: #aaa;
  --knowledge-faint: #777;
  --knowledge-surface: #191919;
  --knowledge-surface-soft: #222;
  --knowledge-surface-hover: #292929;
  --knowledge-border: rgba(255, 255, 255, .12);
  --knowledge-border-strong: rgba(255, 255, 255, .34);
  --knowledge-button: #f2f2f2;
  --knowledge-button-text: #111;
  --knowledge-shadow: 0 18px 40px rgba(0, 0, 0, .2);
}

.dashboard-tabs {
  border-color: var(--knowledge-border);
  background: var(--knowledge-surface-soft);
}

.dashboard-tabs button { color: var(--knowledge-muted); }
.dashboard-tabs button.active {
  color: var(--knowledge-button-text);
  background: var(--knowledge-button);
  box-shadow: 0 7px 18px rgba(0, 0, 0, .12);
}

.knowledge-workspace { color: var(--knowledge-text); }

.knowledge-hero,
.knowledge-card {
  border-color: var(--knowledge-border);
  color: var(--knowledge-text);
  background: var(--knowledge-surface);
  box-shadow: var(--knowledge-shadow);
}

.knowledge-hero { background-image: none; }
.knowledge-hero p,
.knowledge-card-head small,
.knowledge-card-head span,
.knowledge-message,
.product-row-main small,
.document-row small,
.knowledge-empty,
.file-drop,
.file-drop small,
.knowledge-check,
.ai-product-box label,
.product-fields label,
.import-summary,
.import-preview article { color: var(--knowledge-muted); }

.knowledge-state,
.knowledge-state.error {
  border-color: var(--knowledge-border);
  color: var(--knowledge-text);
  background: var(--knowledge-surface-soft);
}

.knowledge-card-head > strong { background: var(--knowledge-surface-soft); }

.knowledge-card textarea,
.knowledge-card input,
.knowledge-card select,
.product-dialog textarea,
.product-dialog input,
.product-dialog select {
  border-color: var(--knowledge-border);
  color: var(--knowledge-text);
  background: var(--knowledge-surface-soft);
}

.knowledge-card textarea:focus,
.knowledge-card input:focus,
.knowledge-card select:focus,
.product-dialog textarea:focus,
.product-dialog input:focus,
.product-dialog select:focus {
  border-color: var(--knowledge-border-strong);
  background: var(--knowledge-surface);
  box-shadow: 0 0 0 3px rgba(127, 127, 127, .12);
}

.knowledge-card select option,
.product-dialog select option { color: var(--knowledge-text); background: var(--knowledge-surface); }

.knowledge-message.error,
.import-summary .error { color: #a22b2b; }

.knowledge-button,
.knowledge-button.ai {
  color: var(--knowledge-button-text);
  background: var(--knowledge-button);
  background-image: none;
}

.knowledge-button.secondary,
.knowledge-button.ghost {
  border: 1px solid var(--knowledge-border);
  color: var(--knowledge-text);
  background: var(--knowledge-surface-soft);
}

.product-row,
.document-row {
  border-color: var(--knowledge-border);
  color: var(--knowledge-text);
  background: var(--knowledge-surface-soft);
}

.product-row:hover { border-color: var(--knowledge-border-strong); background: var(--knowledge-surface-hover); }

.product-row-meta .status,
.product-row-meta .status.published {
  color: var(--knowledge-muted);
  background: var(--knowledge-surface-hover);
}

.knowledge-empty { border-color: var(--knowledge-border); }
.knowledge-empty b { color: var(--knowledge-text); }
.file-drop { border-color: var(--knowledge-border-strong); }
.file-drop:hover { border-color: var(--knowledge-text); background: var(--knowledge-surface-soft); }
.knowledge-check input { accent-color: var(--knowledge-button); }

.document-row-actions button {
  border-color: var(--knowledge-border);
  color: var(--knowledge-text);
  background: var(--knowledge-surface);
}

/* Document library: readable metadata, quiet surfaces, clear publication state. */
.documents-list { gap: 14px; }
.document-row {
  min-width: 0;
  gap: 14px;
  padding: 20px;
  border-radius: 16px;
  background: var(--knowledge-surface);
}
.document-heading { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
.document-format {
  display: grid;
  place-items: center;
  width: 44px;
  height: 48px;
  flex: 0 0 44px;
  border: 1px solid var(--knowledge-border);
  border-radius: 10px;
  background: var(--knowledge-surface-soft);
  color: var(--knowledge-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
}
.document-identity { min-width: 0; flex: 1 1 150px; }
.document-identity h4 { margin: 1px 0 5px; font-size: 15px; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.document-filename { display: block; color: var(--knowledge-muted); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.document-status {
  padding: 5px 9px;
  border: 1px solid var(--knowledge-border);
  border-radius: 6px;
  color: var(--knowledge-muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
}
.document-status.is-published { color: var(--knowledge-text); background: var(--knowledge-surface-soft); }
.document-status.is-published::before { content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 6px 2px 0; border-radius: 50%; background: currentColor; }
.document-description { margin: 0; color: var(--knowledge-text); font-size: 13px; line-height: 1.65; white-space: pre-line; overflow-wrap: anywhere; }
.document-description.is-empty { color: var(--knowledge-muted); }
.document-details { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--knowledge-muted); font-size: 11px; line-height: 1.5; }
.document-row-actions { gap: 8px; padding-top: 14px; border-top: 1px solid var(--knowledge-border); }
.document-row-actions button { min-height: 40px; padding: 9px 12px; font: 500 12px/1.4 Inter, Arial, sans-serif; letter-spacing: 0; border-radius: 8px; }
.document-row-actions button:hover { background: var(--knowledge-surface-soft); border-color: var(--knowledge-border-strong); }
.document-row-actions .document-publish { margin-left: auto; }
.document-row-actions .is-primary { background: var(--knowledge-button); color: var(--knowledge-button-text); border-color: var(--knowledge-button); }
.document-row-actions .is-primary:hover { background: var(--knowledge-button); opacity: .85; }
.document-row-actions button:focus-visible { outline: 2px solid var(--knowledge-text); outline-offset: 3px; }
.document-row-actions button:disabled { opacity: .45; cursor: wait; }
@media (max-width: 620px) {
  .document-row { padding: 16px; }
  .document-status { margin-left: 56px; }
  .document-row-actions button { min-height: 44px; flex: 1 1 auto; }
  .document-row-actions .document-publish { margin-left: 0; }
}

.product-dialog,
.import-dialog {
  border-color: var(--knowledge-border);
  color: var(--knowledge-text);
  background: var(--knowledge-surface);
  box-shadow: 0 36px 90px rgba(0, 0, 0, .28);
}

.product-dialog-head > button {
  border-color: var(--knowledge-border);
  color: var(--knowledge-text);
  background: var(--knowledge-surface-soft);
}

.ai-product-box {
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--knowledge-border);
  border-radius: 16px;
  background: var(--knowledge-surface-soft);
  background-image: none;
}

.ai-product-head { display: flex; align-items: baseline; gap: 10px; padding: 0 2px; }
.ai-product-head b { font-size: 13px; }
.ai-product-head span { color: var(--knowledge-muted); font-size: 11px; }

.ai-composer {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--knowledge-border);
  border-radius: 14px;
  background: var(--knowledge-surface);
}

.ai-composer > input { display: none; }
.ai-composer textarea {
  min-height: 38px;
  max-height: 120px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  resize: none;
  box-shadow: none;
}
.ai-composer textarea:focus { border: 0; background: transparent; box-shadow: none; }
.ai-composer .knowledge-button { min-height: 38px; }

.ai-attach-button {
  width: 38px;
  height: 38px;
  display: grid !important;
  place-items: center;
  border: 1px solid var(--knowledge-border);
  border-radius: 11px;
  color: var(--knowledge-text) !important;
  background: var(--knowledge-surface-soft);
  font-size: 22px !important;
  font-weight: 400 !important;
  line-height: 1;
  cursor: pointer;
}

.ai-attachment-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-attachment-list:empty { display: none; }
.ai-attachment {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 6px 8px 6px 10px;
  border: 1px solid var(--knowledge-border);
  border-radius: 999px;
  color: var(--knowledge-text);
  background: var(--knowledge-surface);
  font-size: 11px;
}
.ai-attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-attachment button { width: 20px; height: 20px; padding: 0; border-radius: 50%; color: var(--knowledge-muted); background: var(--knowledge-surface-soft); }

.product-document-field {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--knowledge-border);
  border-radius: 14px;
}
.product-document-field legend { padding: 0 7px; color: var(--knowledge-muted); font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.document-choices label span { border-color: var(--knowledge-border); color: var(--knowledge-muted); background: var(--knowledge-surface-soft); }
.document-choices input:checked + span { border-color: var(--knowledge-text); color: var(--knowledge-button-text); background: var(--knowledge-button); }

.product-dialog-actions {
  border-color: var(--knowledge-border);
  background: color-mix(in srgb, var(--knowledge-surface) 94%, transparent);
}

.import-summary b,
.import-preview article b { color: var(--knowledge-text); }
.import-preview article { border-color: var(--knowledge-border); }
.import-preview article strong { color: var(--knowledge-text); }

@media (max-width: 900px) {
  .knowledge-columns { grid-template-columns: 1fr; }
  .knowledge-hero { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 620px) {
  .dashboard-tabs { width: 100%; }
  .dashboard-tabs button { flex: 1; padding: 0 8px; }
  .knowledge-card, .knowledge-hero { padding: 18px; border-radius: 20px; }
  .knowledge-toolbar, .knowledge-form-row, .product-fields { grid-template-columns: 1fr; }
  .product-fields .wide { grid-column: auto; }
  .product-row { grid-template-columns: 1fr; }
  .product-row-meta { align-items: flex-start; }
  .import-preview article { grid-template-columns: 1fr; }
  .import-preview article strong { text-align: left; }
  .ai-product-head { align-items: flex-start; flex-direction: column; gap: 2px; }
  .ai-composer { grid-template-columns: 38px minmax(0, 1fr) auto; gap: 6px; }
  .ai-composer textarea { min-width: 0; }
  .ai-composer .knowledge-button { width: 38px; padding: 0; font-size: 0; }
  .ai-composer .knowledge-button::after { content: "↑"; font-size: 20px; line-height: 1; }
}
