:root {
  --ink: #0b1220;
  --ink-soft: #152238;
  --slate: #334155;
  --mist: #64748b;
  --line: rgba(15, 23, 42, 0.08);
  --paper: #f3f6fb;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #0d9488;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow: 0 18px 50px rgba(11, 18, 32, 0.08);
  --radius: 18px;
  --font-display: "Syne", "Noto Sans SC", sans-serif;
  --font-body: "Manrope", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 90% -10%, rgba(13, 148, 136, 0.16), transparent 55%),
    radial-gradient(900px 500px at -10% 20%, rgba(30, 64, 175, 0.10), transparent 50%),
    linear-gradient(180deg, #eef3f9 0%, var(--paper) 45%, #e8eef7 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.45), transparent 70%);
  z-index: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 10px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background:
    linear-gradient(145deg, #134e4a, #0f766e 55%, #5eead4);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.28);
  position: relative;
  overflow: hidden;
}

.brand-mark::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  right: 8px;
  bottom: 7px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: -8px -6px 0 rgba(255, 255, 255, 0.35);
}

.brand span {
  font-size: 1.15rem;
}

.nav-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  font-weight: 600;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #115e59);
  color: #fff;
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.28);
}

.btn-primary:hover {
  box-shadow: 0 16px 32px rgba(15, 118, 110, 0.35);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  color: var(--ink);
  backdrop-filter: blur(8px);
}

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-danger {
  background: rgba(185, 28, 28, 0.08);
  color: var(--danger);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 28px;
  align-items: center;
  padding: 36px 0 48px;
  min-height: calc(100vh - 100px);
}

.hero-copy h1 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.hero-copy h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero-copy p {
  margin: 0 0 28px;
  max-width: 34ch;
  color: var(--slate);
  font-size: 1.08rem;
  line-height: 1.7;
}

.hero-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-panel {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px;
  backdrop-filter: blur(16px);
  position: relative;
  overflow: hidden;
  animation: rise 0.7s ease both;
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(13, 148, 136, 0.25), transparent 70%);
}

.panel-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.panel-kicker i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: pulse 2s ease infinite;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
  background: rgba(15, 23, 42, 0.04);
  padding: 6px;
  border-radius: 14px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  color: var(--mist);
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--slate);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.hint {
  font-size: 0.82rem;
  color: var(--mist);
  margin-top: -4px;
  margin-bottom: 12px;
}

.form-error {
  display: none;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(185, 28, 28, 0.08);
  color: var(--danger);
  font-size: 0.9rem;
}

.form-error.show {
  display: block;
}

.form-ok {
  display: none;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(21, 128, 61, 0.08);
  color: var(--ok);
  font-size: 0.9rem;
}

.form-ok.show {
  display: block;
}

.section {
  padding: 28px 0 60px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: -0.02em;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--mist);
}

.card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.msg-list {
  display: grid;
  gap: 14px;
}

.msg-item {
  padding: 18px 18px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  animation: rise 0.45s ease both;
}

.msg-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 0.84rem;
  color: var(--mist);
}

.msg-meta strong {
  color: var(--ink);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-wait {
  background: rgba(180, 83, 9, 0.1);
  color: var(--warn);
}

.badge-done {
  background: rgba(21, 128, 61, 0.1);
  color: var(--ok);
}

.msg-body {
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.reply-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(15, 118, 110, 0.03));
  border: 1px solid rgba(15, 118, 110, 0.12);
}

.reply-box .label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--mist);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  padding: 18px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}

.stat .n {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat .t {
  color: var(--mist);
  font-size: 0.88rem;
  margin-top: 4px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mist);
  background: rgba(15, 23, 42, 0.02);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.pill-group {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.04);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.pill {
  border: 0;
  background: transparent;
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 700;
  color: var(--mist);
  font-size: 0.88rem;
}

.pill.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.06);
}

.footer {
  padding: 24px 0 40px;
  color: var(--mist);
  font-size: 0.88rem;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  margin-top: 20px;
}

.hidden {
  display: none !important;
}

.auth-gate,
.app-shell {
  min-height: 100vh;
}

.app-main {
  padding: 18px 0 40px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 600;
}

.user-chip b {
  color: var(--accent);
}

.reply-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.reply-form .row {
  display: flex;
  gap: 10px;
  align-items: start;
}

.reply-form textarea {
  flex: 1;
  min-height: 72px;
}

.tg-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid rgba(15, 118, 110, 0.35);
}

.tg-link:hover {
  color: var(--accent-strong);
  border-bottom-color: var(--accent-strong);
}

.btn-xs {
  padding: 6px 10px;
  font-size: 0.82rem;
  border-radius: 9px;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(11, 18, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(11, 18, 32, 0.22);
  animation: rise 0.25s ease both;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #e2e8f0;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f766e, #115e59);
  color: #fff;
  font-weight: 800;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-cell .sub {
  color: var(--mist);
  font-size: 0.78rem;
  margin-top: 2px;
}

.profile-card {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 8px;
}

.tg-banner {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.tg-banner-ok {
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent);
}

.tg-banner-warn {
  background: rgba(180, 83, 9, 0.1);
  color: var(--warn);
}

.tg-auto-card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 14px;
  background: rgba(15, 118, 110, 0.06);
  border: 1px solid rgba(15, 118, 110, 0.12);
}

.tg-auto-card p {
  margin: 4px 0 0;
  color: var(--mist);
  font-size: 0.88rem;
}

.tg-auto-spin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(15, 118, 110, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent-soft); }
  50% { box-shadow: 0 0 0 8px rgba(15, 118, 110, 0.08); }
}

@media (max-width: 880px) {
  .hero,
  .grid-2,
  .stats {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 18px;
  }

  .hero-copy h1 {
    font-size: 2.35rem;
  }
}
