:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --card: rgba(255, 255, 255, 0.82);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(29, 29, 31, 0.11);
  --blue: #2f6fe4;
  --green: #0b7a55;
  --red: #c83731;
  --orange: #ff7a59;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.07);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(47, 111, 228, 0.11), transparent 26rem),
    linear-gradient(135deg, #fbfbfd 0%, var(--bg) 52%, #fff 100%);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(251, 251, 253, 0.84);
  backdrop-filter: blur(24px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
}

.brand > span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: #1d1d1f;
  color: #fff;
  font-size: 12px;
  font-weight: 850;
}

.brand strong,
.brand small,
.nav-item strong,
.nav-item small {
  display: block;
}

.brand small,
.nav-item small,
.metric-tile p,
.quick-card span,
.toolbar p,
label,
.result-main span,
.mini-kpis span,
.insight span {
  color: var(--muted);
}

.module-nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 16px;
  background: transparent;
  padding: 10px;
  text-align: left;
}

.nav-item i {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 11px;
  background: #f0f1f4;
  color: var(--blue);
  font-style: normal;
  font-weight: 850;
}

.nav-item.active,
.nav-item:hover {
  background: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.06);
}

.nav-item.active i {
  background: var(--blue);
  color: #fff;
}

.nav-item small {
  margin-top: 2px;
  font-size: 12px;
}

.content {
  min-width: 0;
  padding: 16px clamp(12px, 2vw, 28px) 30px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 14px;
  background: linear-gradient(180deg, rgba(245, 245, 247, 0.96), rgba(245, 245, 247, 0));
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

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

h2 {
  margin: 2px 0 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.12;
}

.help-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  vertical-align: middle;
  cursor: help;
}

.tip-bubble {
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  z-index: 50;
  width: min(320px, calc(100vw - 32px));
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(29, 29, 31, 0.94);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.55;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.help-tip:hover .tip-bubble,
.help-tip:focus .tip-bubble {
  opacity: 1;
  transform: translate(-50%, 0);
}

h3 {
  margin: 0;
  font-size: 17px;
}

.top-actions,
.toolbar,
.toolbar-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 12px;
}

.toolbar p {
  margin: 4px 0 0;
}

.ghost-button,
.dark-button {
  min-height: 38px;
  border-radius: 999px;
  padding: 0 15px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  color: var(--text);
  font-weight: 760;
  white-space: nowrap;
}

.ghost-button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.dark-button {
  border-color: #1d1d1f;
  background: #1d1d1f;
  color: #fff;
}

.full {
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.workspace,
.compact-stack {
  display: grid;
  gap: 12px;
}

.panel,
.metric-tile,
.quick-card {
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.metric-tile,
.quick-card,
.panel {
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.quick-card:hover,
.metric-tile:hover {
  transform: translateY(-1px);
  border-color: rgba(47, 111, 228, 0.18);
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.09);
}

.panel {
  min-width: 0;
  padding: clamp(14px, 1.8vw, 22px);
}

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

.metric-tile {
  min-height: 126px;
  padding: 16px;
}

.hero-metric {
  background: #1d1d1f;
  color: #fff;
}

.hero-metric span,
.hero-metric p {
  color: rgba(255, 255, 255, 0.72);
}

.metric-tile span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-tile strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(24px, 3.2vw, 36px);
}

.metric-tile p {
  margin: 8px 0 0;
  line-height: 1.45;
}

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

.quick-card {
  min-height: 104px;
  padding: 16px;
  text-align: left;
}

.quick-card strong {
  display: block;
  font-size: 18px;
}

.quick-card span {
  display: block;
  margin-top: 8px;
  line-height: 1.5;
}

.calculator-layout {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  align-items: start;
}

.calc-form {
  display: grid;
  gap: 14px;
}

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

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

.section-head > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.input-groups {
  display: grid;
  gap: 12px;
}

fieldset {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  font-size: 16px;
  font-weight: 850;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
  align-items: end;
}

.competitor-fields {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
  font-weight: 760;
}

.field,
input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 11px;
}

.field b {
  color: var(--muted);
  font-weight: 760;
  white-space: nowrap;
}

input,
textarea {
  min-height: 42px;
  outline: none;
  padding: 0 11px;
}

.field input {
  min-height: auto;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

textarea {
  min-height: 46px;
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus,
.field:focus-within {
  border-color: rgba(47, 111, 228, 0.5);
  box-shadow: 0 0 0 4px rgba(47, 111, 228, 0.12);
}

.result-panel {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 10px;
}

.alert {
  display: grid;
  gap: 2px;
  padding: 12px 13px;
  border-radius: 16px;
  line-height: 1.4;
}

.alert span {
  color: var(--muted);
  font-size: 13px;
}

.alert.ok {
  background: #edf9f4;
  color: var(--green);
}

.alert.warn {
  background: #fff0ef;
  color: var(--red);
}

.result-main {
  padding: 14px;
  border-radius: 17px;
  background: #fff;
}

.result-main strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1;
}

.result-main p {
  margin: 10px 0 0;
  color: var(--muted);
}

.mini-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mini-kpis div,
.insight {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
  padding: 12px;
}

.mini-kpis strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.breakdown {
  display: grid;
  gap: 0;
}

.breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

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

.insight p {
  margin: 7px 0 0;
  line-height: 1.55;
}

.chart-panel {
  min-height: 410px;
}

canvas {
  display: block;
  width: 100%;
  height: 318px;
  border-radius: 16px;
  background: #fff;
}

.drawer-form[hidden] {
  display: none;
}

.drawer-form {
  display: grid;
  gap: 12px;
}

.data-panel {
  min-height: 0;
  min-width: 0;
}

.data-tools {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(300px, 1fr);
  gap: 8px;
  width: min(760px, 100%);
}

.search-field {
  display: block;
}

.search-field input {
  min-height: 38px;
}

.csv-inline {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 8px;
  width: 100%;
}

.csv-inline textarea {
  min-height: 38px;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

.product-link {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.product-link:hover {
  text-decoration: underline;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

td button {
  border: 0;
  background: transparent;
  color: var(--red);
  font-weight: 850;
}

.empty-row {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.calendar-layout {
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  align-items: start;
}

.event-form {
  display: grid;
  gap: 10px;
}

.timeline-panel {
  min-height: 360px;
}

.event-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.event-item {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
}

.event-date {
  color: var(--blue);
  font-weight: 850;
}

.event-item strong {
  display: block;
  margin-bottom: 3px;
}

.event-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

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

  .sidebar {
    position: sticky;
    z-index: 30;
    height: auto;
    max-width: 100vw;
    overflow: hidden;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.78);
  }

  .brand {
    display: none;
  }

  .module-nav {
    display: flex;
    gap: 8px;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-item {
    flex: 0 0 152px;
    grid-template-columns: 28px 1fr;
    padding: 8px;
  }

  .nav-item i {
    width: 28px;
    height: 28px;
  }

  .content {
    padding: 10px 12px 24px;
  }

  .topbar {
    position: static;
    padding-top: 4px;
  }

  .calculator-layout,
  .calendar-layout {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }

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

@media (max-width: 720px) {
  .topbar,
  .toolbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .toolbar-actions,
  .inline-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .overview-grid,
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .metric-tile,
  .quick-card {
    min-height: auto;
  }

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

  table {
    min-width: 860px;
  }

  .data-tools,
  .csv-inline,
  .event-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .field-grid,
  .mini-kpis {
    grid-template-columns: 1fr;
  }
}
