:root {
  color-scheme: light;
  --paper: #f6f7f4;
  --panel: #ffffff;
  --ink: #18201e;
  --muted: #66736f;
  --line: #dfe5df;
  --line-strong: #c4cec7;
  --teal: #0e7c78;
  --teal-deep: #075f5c;
  --mint: #d8f4e6;
  --amber: #d99021;
  --coral: #c9583a;
  --violet: #6254b2;
  --blue: #2b6cb0;
  --danger: #b83835;
  --shadow: 0 18px 50px rgba(24, 32, 30, 0.12);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(14, 124, 120, 0.08) 1px, transparent 1px) 0 0 / 52px
      52px,
    linear-gradient(rgba(14, 124, 120, 0.07) 1px, transparent 1px) 0 0 / 52px 52px,
    var(--paper);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  z-index: 20;
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 4px;
  padding: 6px 12px;
}

.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  transition:
    background 180ms var(--ease-out),
    color 180ms var(--ease-out),
    transform 140ms var(--ease-out);
}

.nav-item:hover {
  background: rgba(14, 124, 120, 0.08);
  color: var(--ink);
  transform: translateX(2px);
}

.nav-item.is-active {
  background: var(--mint);
  color: var(--teal-deep);
}

.nav-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
}

.nav-count {
  min-width: 28px;
  border-radius: 999px;
  background: rgba(24, 32, 30, 0.08);
  color: var(--muted);
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  padding: 16px;
}

.mini-meter {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.mini-meter span,
.eyebrow,
.meta,
.fineprint {
  color: var(--muted);
  font-size: 12px;
}

.mini-meter strong {
  display: block;
  margin: 8px 0;
  font-size: 24px;
}

.mini-meter i,
.meter i {
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eee8;
}

.mini-meter i::before,
.meter i::before {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--amber));
  content: "";
  transform: scaleX(var(--value));
  transform-origin: left;
  transition: transform 420ms var(--ease-out);
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 244, 0.86);
  padding: 14px clamp(18px, 3vw, 34px);
  backdrop-filter: blur(18px);
  z-index: 15;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.08;
}

.topbar-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.role-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.user-badge {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.switch {
  position: relative;
  width: 48px;
  height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #e9eee9;
  transition:
    background 180ms var(--ease-out),
    border-color 180ms var(--ease-out);
}

.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(24, 32, 30, 0.22);
  transition: transform 260ms var(--spring);
}

.switch[aria-checked="true"] {
  border-color: var(--teal);
  background: var(--teal);
}

.switch[aria-checked="true"] i {
  transform: translateX(22px);
}

.main-panel {
  padding: 24px clamp(18px, 3vw, 34px) 44px;
  outline: 0;
}

.view {
  animation: viewIn 300ms var(--ease-out);
}

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

.grid {
  display: grid;
  gap: 16px;
}

.kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.two-column {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  align-items: start;
}

.catalog-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.product-card,
.record,
.pipeline-step {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 0 rgba(24, 32, 30, 0.03);
}

.panel {
  padding: 18px;
}

.panel-header,
.record-main,
.row,
.service-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-header {
  margin-bottom: 14px;
}

.panel-header h2,
.product-card h3,
.record h3 {
  margin: 0;
  font-size: 18px;
}

.kpi {
  position: relative;
  min-height: 132px;
  overflow: hidden;
}

.kpi::after {
  position: absolute;
  right: -24px;
  bottom: -28px;
  width: 108px;
  height: 108px;
  border: 1px solid rgba(14, 124, 120, 0.18);
  border-radius: 50%;
  content: "";
}

.kpi b {
  display: block;
  margin-top: 14px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

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

.delta {
  display: inline-flex;
  margin-top: 14px;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--mint);
  color: var(--teal-deep);
  font-size: 12px;
}

.danger-text {
  color: var(--danger);
}

.chart {
  display: grid;
  height: 232px;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 12px 0 0;
}

.bar {
  position: relative;
  min-height: 16px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--teal), #9ccbb7);
  transform: scaleY(0.08);
  transform-origin: bottom;
  animation: growBar 520ms var(--ease-out) forwards;
}

.bar::after {
  position: absolute;
  right: 50%;
  bottom: -26px;
  color: var(--muted);
  content: attr(data-label);
  font-size: 11px;
  transform: translateX(50%);
}

@keyframes growBar {
  to {
    transform: scaleY(var(--level));
  }
}

.pipeline {
  display: grid;
  gap: 10px;
}

.pipeline-step {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.pipeline-step .code {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #f1f4f0;
  color: var(--teal-deep);
  font-weight: 800;
}

.status,
.tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2ef;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status.success {
  background: var(--mint);
  color: var(--teal-deep);
}

.status.warning {
  background: #fff0d3;
  color: #855900;
}

.status.danger {
  background: #fde3df;
  color: var(--danger);
}

.product-card {
  display: flex;
  min-height: 260px;
  flex-direction: column;
  padding: 18px;
  transition:
    transform 180ms var(--ease-out),
    box-shadow 180ms var(--ease-out),
    border-color 180ms var(--ease-out);
}

.product-card:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.product-visual {
  display: grid;
  min-height: 92px;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 18px;
}

.product-visual span {
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 78%, #fff 22%);
  opacity: 0.42;
}

.product-visual span:nth-child(2n) {
  opacity: 0.74;
  transform: translateY(10px);
}

.product-visual span:nth-child(3n) {
  opacity: 1;
  transform: translateY(22px);
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.price {
  margin-top: auto;
  color: var(--muted);
}

.price strong {
  color: var(--ink);
  font-size: 28px;
}

.record-list {
  display: grid;
  gap: 10px;
}

.record {
  padding: 14px;
  transition:
    transform 160ms var(--ease-out),
    border-color 160ms var(--ease-out);
}

.record:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.record-main {
  align-items: flex-start;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.record-grid span,
.metric {
  display: block;
  border-left: 2px solid var(--line);
  padding-left: 10px;
}

.record-grid b,
.metric b {
  display: block;
  margin-top: 4px;
}

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

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  text-align: left;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.table td:last-child,
.table th:last-child {
  text-align: right;
}

.primary-button,
.ghost-button,
.danger-button,
.small-button {
  position: relative;
  min-height: 38px;
  overflow: hidden;
  border-radius: 8px;
  padding: 0 14px;
  transition:
    transform 140ms var(--ease-out),
    box-shadow 140ms var(--ease-out),
    background 140ms var(--ease-out);
}

.primary-button {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
  box-shadow: 0 8px 18px rgba(14, 124, 120, 0.22);
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.small-button:hover {
  transform: translateY(-1px);
}

.primary-button:active,
.ghost-button:active,
.danger-button:active,
.small-button:active {
  transform: translateY(1px) scale(0.99);
}

.primary-button:disabled,
.ghost-button:disabled,
.danger-button:disabled,
.small-button:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.ghost-button,
.small-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
}

.danger-button {
  border: 1px solid var(--danger);
  background: #fff;
  color: var(--danger);
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.ripple {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 600ms var(--ease-out);
}

.ghost-button .ripple,
.small-button .ripple,
.danger-button .ripple {
  background: rgba(14, 124, 120, 0.16);
}

@keyframes ripple {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(18);
  }
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.icon-button span,
.icon-button span::before,
.icon-button span::after {
  display: block;
  width: 17px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.icon-button span::before {
  transform: translateY(-6px);
}

.icon-button span::after {
  transform: translateY(4px);
}

.close-button span {
  background: transparent;
}

.close-button span::before {
  transform: translateY(1px) rotate(45deg);
}

.close-button span::after {
  transform: translateY(-1px) rotate(-45deg);
}

.mobile-menu {
  display: none;
}

.drawer {
  position: fixed;
  inset: 0;
  display: grid;
  justify-content: end;
  background: rgba(24, 32, 30, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease-out);
  z-index: 50;
}

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

.drawer-panel {
  width: min(480px, 100vw);
  height: 100vh;
  overflow: auto;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
  transform: translateX(100%);
  transition: transform 260ms var(--ease-out);
}

.drawer.is-open .drawer-panel {
  transform: translateX(0);
}

.close-button {
  float: right;
}

.field-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

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

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

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  padding: 11px 12px;
  color: var(--ink);
  outline: 0;
  transition:
    border-color 160ms var(--ease-out),
    box-shadow 160ms var(--ease-out);
}

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

.field input:focus,
.field select:focus,
.field textarea:focus,
button:focus-visible {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 124, 120, 0.16);
}

.quote-box {
  display: grid;
  gap: 10px;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f7faf7;
}

.quote-box strong {
  font-size: 30px;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 10px;
}

.timeline-item i {
  position: relative;
  margin-top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--teal);
}

.timeline-item i::after {
  position: absolute;
  top: 12px;
  left: 4px;
  width: 1px;
  height: 30px;
  background: var(--line-strong);
  content: "";
}

.timeline-item:last-child i::after {
  display: none;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 60;
}

.toast {
  width: min(360px, calc(100vw - 36px));
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  animation: toastIn 260ms var(--ease-out);
}

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

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

.skeleton-grid span {
  height: 132px;
  border-radius: 8px;
  background: linear-gradient(90deg, #e7ece7, #f8faf8, #e7ece7);
  background-size: 240% 100%;
  animation: shimmer 1.2s var(--ease-in-out) infinite;
}

.auth-mode .app-shell {
  display: block;
}

.auth-mode .sidebar,
.auth-mode .topbar {
  display: none;
}

.auth-mode .main-panel {
  min-height: 100vh;
  padding: 24px;
}

.auth-screen {
  display: grid;
  min-height: calc(100vh - 48px);
  place-items: center;
}

.auth-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: 24px;
  animation: viewIn 300ms var(--ease-out);
}

.auth-brand {
  padding: 0 0 22px;
}

.auth-card h1 {
  margin: 4px 0 18px;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.02;
}

.login-hints {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

@keyframes shimmer {
  to {
    background-position: -240% 0;
  }
}

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

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

  .two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(290px, 86vw);
    transform: translateX(-100%);
    transition: transform 240ms var(--ease-out);
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .mobile-menu {
    display: grid;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 680px) {
  .topbar {
    display: grid;
    grid-template-columns: auto 1fr;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .kpi-grid,
  .catalog-grid,
  .record-grid,
  .skeleton-grid {
    grid-template-columns: 1fr;
  }

  .record-main,
  .row,
  .service-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
