:root {
  --bg: #f5f7ef;
  --surface: #ffffff;
  --surface-2: #f0f4e7;
  --ink: #101418;
  --muted: #667063;
  --line: #dce4d2;
  --brand: #b9ec57;
  --brand-strong: #83c92f;
  --teal: #2a9d8f;
  --coral: #e76f51;
  --blue: #4267d6;
  --shadow: 0 18px 50px rgba(16, 20, 24, .10);
  --shadow-hover: 0 24px 60px rgba(16, 20, 24, .16);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
}

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

button {
  cursor: pointer;
}

.boot {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
}

.boot-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto;
  border-radius: 14px;
  background: var(--ink);
  position: relative;
  box-shadow: var(--shadow);
}

.boot-mark::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--brand);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

.auth-hero {
  display: none;
  padding: 52px;
  color: #fff;
  background: #101418;
}

.auth-hero h1 {
  margin: 0;
  font-size: clamp(42px, 8vw, 96px);
  line-height: .92;
  font-weight: 780;
}

.auth-hero p {
  max-width: 540px;
  margin: 24px 0 0;
  color: rgba(255, 255, 255, .74);
  font-size: 18px;
  line-height: 1.5;
}

.hero-signal {
  width: min(620px, 100%);
  height: 240px;
  margin-top: 48px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, transparent 0 8%, rgba(185, 236, 87, .26) 8% 9%, transparent 9% 20%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.05), rgba(255,255,255,.05) 1px, transparent 1px, transparent 42px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.05), rgba(255,255,255,.05) 1px, transparent 1px, transparent 42px);
  position: relative;
  overflow: hidden;
}

.hero-signal svg {
  position: absolute;
  inset: 20px;
  width: calc(100% - 40px);
  height: calc(100% - 40px);
}

.auth-panel {
  width: min(520px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 26px 0;
  align-self: center;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--ink);
  display: grid;
  place-items: center;
  color: var(--brand);
  font-weight: 800;
}

.brand-row b {
  font-size: 22px;
}

.card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.card {
  padding: 18px;
}

.panel {
  padding: 22px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 4px;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
}

.tabs button,
.seg button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  min-height: 38px;
  color: var(--muted);
}

.tabs button.active,
.seg button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 6px rgba(16, 20, 24, .08);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 7px;
}

.field label,
.label {
  font-size: 12px;
  color: var(--muted);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--brand-strong);
  box-shadow: 0 0 0 3px rgba(185, 236, 87, .34);
}

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 650;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .68;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.btn.primary {
  background: var(--brand);
  color: var(--ink);
}

.btn.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: transparent;
}

.btn.warn {
  background: var(--coral);
  color: #fff;
}

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

.small {
  font-size: 12px;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  background: #101418;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar .brand-row {
  margin-bottom: 0;
}

.sidebar .brand-logo {
  background: var(--brand);
  color: var(--ink);
}

.nav {
  display: grid;
  gap: 4px;
}

.nav button {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.72);
  text-align: left;
  transition: background-color .18s ease, color .18s ease, transform .18s ease;
}

.nav button.active {
  background: rgba(185, 236, 87, .16);
  color: #fff;
}

.nav svg {
  width: 18px;
  height: 18px;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.12);
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}

.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.stat {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 12px;
}

.stat .k {
  color: var(--muted);
  font-size: 12px;
}

.stat .v {
  font-size: 28px;
  line-height: 1;
  font-weight: 760;
}

.chart-box {
  min-height: 340px;
  overflow: hidden;
}

.chart-shell {
  position: relative;
  min-height: 300px;
}

.chart {
  width: 100%;
  height: 300px;
  display: block;
}

.chart-box.span-12 .chart-shell {
  max-width: 1040px;
  margin: 0 auto;
}

.chart-box.span-12 .chart {
  height: 270px;
}

.chart-point {
  cursor: pointer;
  transition: r .16s ease, filter .16s ease, stroke-width .16s ease;
}

.chart-point:hover,
.chart-point:focus {
  r: 6;
  stroke-width: 2;
  filter: drop-shadow(0 5px 8px rgba(131, 201, 47, .5));
  outline: none;
}

.chart-tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  padding: 7px 9px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 12px 28px rgba(16, 20, 24, .2);
  transition: opacity .14s ease;
  white-space: nowrap;
}

.chart-tip.show {
  opacity: 1;
}

.empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eedc;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  max-width: 100%;
  background: var(--brand-strong);
}

.entry-result,
.notice {
  border-left: 4px solid var(--brand-strong);
  background: #f2f8e7;
  padding: 12px;
  border-radius: var(--radius);
}

.notice.warn {
  border-left-color: var(--coral);
  background: #fff0ec;
}

.seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 4px;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.method-card {
  min-height: 280px;
  line-height: 1.62;
  white-space: pre-wrap;
}

.chat-box {
  min-height: 430px;
  max-height: 58vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.bubble {
  max-width: min(760px, 88%);
  padding: 12px;
  border-radius: var(--radius);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble.user {
  align-self: flex-end;
  background: var(--ink);
  color: #fff;
}

.bubble.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
}

.bubble.typing {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.chat-form textarea {
  min-height: 52px;
  max-height: 160px;
}

.tariff {
  display: grid;
  gap: 12px;
  align-content: start;
}

.tariff .price {
  font-size: 34px;
  font-weight: 800;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
}

.pill.good {
  background: rgba(185, 236, 87, .24);
  color: #395a14;
}

.bottom-nav {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(120%);
  max-width: min(520px, calc(100vw - 28px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  transition: transform .2s ease;
  z-index: 20;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.reveal-up {
  animation: revealUp .42s ease both;
}

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

@media (hover: hover) {
  .card:hover,
  .panel:hover {
    transform: translateY(-2px);
    border-color: #cdddb9;
    box-shadow: var(--shadow-hover);
  }

  .btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(16, 20, 24, .14);
  }

  .nav button:hover {
    transform: translateX(2px);
    background: rgba(255, 255, 255, .08);
    color: #fff;
  }
}

@media (min-width: 940px) {
  .auth-page {
    grid-template-columns: minmax(460px, .96fr) minmax(420px, 1fr);
  }
  .auth-hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding-bottom: 72px;
  }
  .sidebar {
    display: none;
  }
  .main {
    padding: 16px;
  }
  .topbar {
    align-items: flex-start;
  }
  .grid {
    gap: 10px;
  }
  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8 {
    grid-column: span 12;
  }
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 6px;
    background: rgba(255,255,255,.94);
    border-top: 1px solid var(--line);
    z-index: 10;
  }
  .bottom-nav button {
    border: 0;
    background: transparent;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    gap: 2px;
    color: var(--muted);
    font-size: 11px;
  }
  .bottom-nav button.active {
    color: var(--ink);
    background: rgba(185,236,87,.28);
  }
  .bottom-nav svg {
    width: 19px;
    height: 19px;
  }
}

@media (max-width: 640px) {
  .form-grid.two,
  .chat-form {
    grid-template-columns: 1fr;
  }
  .panel,
  .card {
    padding: 14px;
  }
  .topbar h1 {
    font-size: 22px;
  }
  .chart-box {
    min-height: 280px;
  }
  .chart {
    height: 240px;
  }
}
