﻿:root {
  --bg: #f8fafc;
  --bg-strong: rgba(255,255,255,0.86);
  --surface: rgba(255,255,255,0.72);
  --surface-border: rgba(15, 23, 42, 0.08);
  --text: #020617;
  --muted: #475569;
  --primary: #0f172a;
  --accent: #0369a1;
  --accent-soft: rgba(3,105,161,0.12);
  --success: #0f766e;
  --danger: #b91c1c;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: 'DM Sans', sans-serif; background: linear-gradient(180deg, #f8fbff 0%, #eef4fb 100%); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; }

.bg-orb {
  position: fixed;
  width: 34rem;
  height: 34rem;
  border-radius: 999px;
  filter: blur(70px);
  opacity: 0.34;
  pointer-events: none;
  animation: drift 16s ease-in-out infinite;
}
.orb-a { top: -10rem; right: -9rem; background: #7dd3fc; }
.orb-b { bottom: -12rem; left: -12rem; background: #c4b5fd; animation-delay: -4s; }
@keyframes drift {
  0%,100% { transform: translate3d(0,0,0) scale(1); }
  50% { transform: translate3d(0,-18px,0) scale(1.04); }
}

.app-shell {
  min-height: 100vh;
  padding: 24px 16px 32px;
  position: relative;
}

.frame {
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.hero, .panel, .item-card, .detail-card, .stat-chip, .tab-bar {
  border: 1px solid var(--surface-border);
  background: var(--surface);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
}

.hero {
  border-radius: var(--radius-xl);
  padding: 24px;
  overflow: hidden;
  position: relative;
}
.hero::after {
  content: '';
  position: absolute;
  inset: auto -10% -30% 40%;
  height: 180px;
  background: radial-gradient(circle at center, rgba(3,105,161,0.18), transparent 70%);
}
.brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; display: grid; place-items: center; font-weight: 800;
  letter-spacing: 0.08em;
}
.brand-copy small { display:block; color: var(--muted); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.brand-copy strong { display:block; font-size: 24px; margin-top: 2px; }
.hero-title { margin: 22px 0 8px; font-size: clamp(28px, 5vw, 40px); line-height: 1.02; letter-spacing: -0.04em; max-width: 12ch; }
.hero-subtitle { margin: 0; color: var(--muted); max-width: 46ch; font-size: 15px; line-height: 1.5; }
.hero-actions { display:flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.tab-bar {
  display: grid;
  grid-template-columns: repeat(var(--tabs, 2), minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border-radius: 22px;
}
.tab {
  border: 0; border-radius: 16px; background: transparent; padding: 12px 10px; color: var(--muted);
  transition: background-color .2s ease, color .2s ease, transform .25s ease;
}
.tab:hover, .tab:focus-visible { background: rgba(255,255,255,.6); color: var(--text); outline: none; }
.tab.active { background: var(--primary); color: white; }

.panel { border-radius: var(--radius-lg); padding: 18px; display: grid; gap: 14px; }
.panel-header { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.panel-title { font-size: 18px; margin: 0; letter-spacing: -0.03em; }
.panel-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  background: rgba(255,255,255,.72);
  color: var(--primary);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition: background-color .2s ease, border-color .2s ease;
}
.icon-btn svg { display: block; overflow: visible; }
.icon-btn:hover, .icon-btn:focus-visible {
  background: #fff;
  border-color: rgba(3,105,161,.28);
  outline: none;
}

.filters {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
}
.filter-field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.filter-field input {
  width: 100%;
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 11px 12px;
  background: rgba(255,255,255,.82);
  color: var(--text);
  outline: none;
}
.filter-field input:focus {
  border-color: rgba(3,105,161,.35);
}
.period-filter select {
  width: 100%;
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 11px 12px;
  background: rgba(255,255,255,.82);
  color: var(--text);
  outline: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.period-filter select:focus {
  border-color: rgba(3,105,161,.35);
}

.stage-filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.stage-chip {
  flex: 0 0 auto;
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 9px 13px;
  font-size: 13px;
  color: var(--primary);
  background: rgba(255,255,255,.7);
  white-space: nowrap;
}
.stage-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.stage-board {
  display: grid;
  gap: 18px;
  margin: 0 -8px;
  overflow: visible;
}
.stage-row {
  display: grid;
  gap: 10px;
  min-width: 0;
  overflow: visible;
}
.stage-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
}
.stage-row-title {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.stage-row-count {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}
.stage-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 14px 12px 22px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.deal-card {
  flex: 0 0 min(78vw, 280px);
  scroll-snap-align: start;
  text-align: left;
  border-radius: 20px;
  padding: 14px;
  border: 1px solid var(--surface-border);
  background: rgba(255,255,255,.92);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  display: grid;
  gap: 12px;
  transition: border-color .22s ease, background-color .22s ease;
}
.deal-card:hover, .deal-card:focus-within { border-color: rgba(3,105,161,.28); }

.stats { display:flex; gap:10px; flex-wrap:wrap; }
.stat-chip { border-radius: 999px; padding: 10px 14px; font-size: 14px; color: var(--primary); background: rgba(255,255,255,.58); }

.list { display:grid; gap:12px; }
.item-card {
  width: 100%; text-align:left; border-radius: 20px; padding: 14px; border: 1px solid var(--surface-border);
  background: rgba(255,255,255,.72);
  display: grid;
  gap: 12px;
  transition: border-color .22s ease, background-color .22s ease;
}
.item-main {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
}
.item-card:hover, .item-card:focus-within { border-color: rgba(3,105,161,.28); }
.item-top { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.item-title { margin:0; font-size:16px; line-height:1.3; }
.item-amount {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--primary);
}
.badge {
  padding: 8px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; white-space: nowrap;
}
.item-meta { display:flex; gap:10px; flex-wrap:wrap; margin-top:12px; color: var(--muted); font-size:13px; }
.item-actions, .detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--surface-border);
  background: rgba(255,255,255,.8);
  color: var(--primary);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  transition: background-color .2s ease, border-color .2s ease;
}
.chip-btn:hover, .chip-btn:focus-visible {
  background: #fff;
  border-color: rgba(3,105,161,.28);
  outline: none;
}

.detail-card { border-radius: var(--radius-xl); padding: 20px; display:grid; gap:16px; animation: rise .28s ease; }
@keyframes rise { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }
.detail-highlight {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.78);
  border: 1px solid var(--surface-border);
}
.amount-block {
  display: grid;
  gap: 4px;
  padding-top: 4px;
}
.amount-label {
  color: var(--muted);
  font-size: 13px;
}
.amount-value {
  font-size: clamp(28px, 7vw, 36px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--primary);
}
.fields { display:grid; gap:10px; }
.field-row { display:grid; grid-template-columns: minmax(120px, 180px) 1fr; gap:12px; padding: 10px 0; border-bottom: 1px solid rgba(15,23,42,.08); }
.field-row:last-child { border-bottom: 0; }
.field-label { color: var(--muted); font-size: 13px; }
.field-value { font-weight: 500; line-height: 1.45; }
.field-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--accent);
}

.admin-panel { gap: 14px; }
.admin-panel .list { gap: 8px; }
.admin-block {
  display: grid;
  gap: 8px;
  padding-top: 2px;
  border-top: 1px solid rgba(15,23,42,.08);
}
.admin-block:first-of-type { border-top: 0; padding-top: 0; }
.admin-block-title { margin: 0; font-size: 14px; letter-spacing: -0.02em; }
.admin-block-text { margin: 0; color: var(--muted); font-size: 12px; }
.admin-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}
.admin-form-fields {
  grid-template-columns: 1fr 1fr auto;
}
.admin-form input {
  width: 100%;
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,.82);
  color: var(--text);
  outline: none;
  font-size: 13px;
}
.admin-form input:focus { border-color: rgba(3,105,161,.35); }
.admin-panel .compact-card { padding: 8px 10px; border-radius: 14px; }
.admin-panel .item-title { font-size: 14px; }
.admin-panel .item-meta { margin-top: 4px; font-size: 11px; gap: 6px; }
.admin-panel .btn-sm,
.btn-sm {
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.2;
}
.admin-panel .actions { gap: 6px; }
.notice {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  line-height: 1.35;
}
.fields-subtitle {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.sortable-list {
  display: grid;
  gap: 6px;
  position: relative;
}
.field-manage-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
  background: rgba(255,255,255,.82);
  touch-action: none;
  will-change: transform;
}
.field-manage-card.is-floating {
  pointer-events: none;
  background: #fff;
  border-color: rgba(3,105,161,.35);
}
.field-placeholder {
  border-radius: 12px;
  border: 1.5px dashed rgba(3,105,161,.35);
  background: rgba(3,105,161,.08);
}
.drag-handle {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgba(15,23,42,.06);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
}
.drag-handle:active { cursor: grabbing; }
.field-manage-body { min-width: 0; display: grid; gap: 2px; }
.field-rename-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 5px 8px;
  background: rgba(248,250,252,.9);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  outline: none;
}
.field-rename-input:focus {
  border-color: rgba(3,105,161,.35);
  background: #fff;
}
.catalog-box {
  display: grid;
  gap: 8px;
  padding-top: 4px;
}
.catalog-list {
  max-height: 280px;
  overflow: auto;
  padding-right: 2px;
  gap: 6px;
}
.catalog-card .catalog-top {
  align-items: flex-start;
}
.catalog-text {
  min-width: 0;
  flex: 1;
}
.catalog-title {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}
.catalog-hint {
  color: var(--muted);
  font-size: 13px;
}
.bx-html {
  font-weight: 500;
  line-height: 1.5;
}
.bx-html .bx-list {
  margin: 6px 0 0;
  padding-left: 1.2em;
}
.bx-html .bx-list li {
  margin: 4px 0;
}
.bx-html a {
  color: var(--accent);
}

.analytics-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}
.metric-card {
  border-radius: 18px;
  padding: 14px;
  border: 1px solid var(--surface-border);
  background: rgba(255,255,255,.78);
  display: grid;
  gap: 4px;
}
.metric-accent {
  background: linear-gradient(135deg, rgba(3,105,161,.12), rgba(255,255,255,.9));
}
.metric-label {
  color: var(--muted);
  font-size: 13px;
}
.metric-value {
  font-size: clamp(24px, 6vw, 32px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
}
.metric-sub {
  color: var(--muted);
  font-size: 12px;
}
.chart-card {
  display: grid;
  gap: 14px;
  padding-top: 8px;
}
.donut-wrap {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: center;
}
.donut {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  mask: radial-gradient(circle at center, transparent 52%, #000 53%);
  -webkit-mask: radial-gradient(circle at center, transparent 52%, #000 53%);
}
.donut-legend { display: grid; gap: 8px; }
.legend-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.chart-bars { display: grid; gap: 10px; }
.chart-row {
  display: grid;
  grid-template-columns: minmax(90px, 140px) 1fr auto;
  gap: 8px;
  align-items: center;
}
.chart-label {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.chart-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(15,23,42,.06);
  overflow: hidden;
}
.chart-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0369a1, #0ea5e9);
}
.chart-value {
  font-size: 12px;
  font-weight: 700;
  min-width: 1.5em;
  text-align: right;
}

.actions { display:flex; gap:10px; flex-wrap:wrap; }
.btn {
  border: 0; border-radius: 16px; padding: 12px 16px; transition: transform .2s ease, opacity .2s ease, background-color .2s ease;
}
.btn:hover, .btn:focus-visible { transform: translateY(-1px); outline:none; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: rgba(255,255,255,.72); color: var(--primary); border: 1px solid var(--surface-border); }
.btn-danger { background: rgba(185,28,28,.12); color: var(--danger); }

.empty, .locked {
  text-align:center; padding: 34px 18px; border-radius: var(--radius-lg); background: rgba(255,255,255,.6); border: 1px dashed rgba(15,23,42,.12); color: var(--muted);
}
.loading { color: var(--muted); padding: 12px 0; }
.error { color: var(--danger); font-weight: 500; }
.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.error-banner .error { flex: 1; }

@media (max-width: 640px) {
  .app-shell { padding: 16px 12px 28px; }
  .hero, .panel, .detail-card { padding: 16px; }
  .field-row { grid-template-columns: 1fr; gap: 6px; }
  .filters { grid-template-columns: 1fr; }
  .deal-card { flex-basis: min(82vw, 260px); }
  .admin-form,
  .admin-form-fields { grid-template-columns: 1fr; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .chart-row { grid-template-columns: 1fr auto; }
  .chart-label { grid-column: 1 / -1; }
}

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