:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --positive: #f99f0b;
  --negative: #dbdbdb;
  --negative-text: #8c8c8c;
  --axis: #374151;
  --tick: #6b7280;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.no-scroll {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  padding: 16px;
  overflow-x: hidden;
}

.layout {
  display: grid;
  gap: 24px;
}

.layout > * {
  min-width: 0;
}

.card,
.panel,
.timeline-frame,
.chart-wrap {
  max-width: 100%;
  min-width: 0;
}

@media (min-width: 1100px) {
  .layout {
    grid-template-columns: 340px minmax(0, 1fr);
    align-items: start;
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.eyebrow {
  margin: 0 0 6px 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2,
p {
  margin: 0;
}

.title {
  font-size: 28px;
  line-height: 1.1;
  margin-bottom: 10px;
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

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

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

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

.field-label {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
}

.input,
.select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  background: #fff;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input:focus,
.select:focus {
  border-color: #64748b;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.12);
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.actions-inline {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.btn {
  border: 0;
  border-radius: 18px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.04s ease, opacity 0.2s ease, background 0.2s ease;
}

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

.btn-primary {
  background: #0f172a;
  color: #fff;
}

.btn-primary:hover {
  background: #1f2937;
}

.btn-soft {
  background: #e5e7eb;
  color: #111827;
}

.btn-soft:hover {
  background: #d1d5db;
}

.btn-outline {
  background: #fff;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.btn-outline:hover {
  background: #f8fafc;
}

.status {
  margin-top: 16px;
  padding: 14px;
  border-radius: 18px;
  font-size: 14px;
}

.status-info {
  background: #f8fafc;
  color: #334155;
}

.status-success {
  background: #ecfdf5;
  color: #166534;
}

.status-error {
  background: #fef2f2;
  color: #991b1b;
}

.stat-grid {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, 1fr);
}

.stat {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
}

.timeline-frame {
  padding: 16px;
  position: relative;
}

.timeline-frame.is-enlarged {
  position: fixed;
  inset: 0;
  z-index: 9999;
  border-radius: 0;
  padding: 24px;
  overflow: auto;
}

.timeline-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 14px;
  line-height: 1;
}

.chip-neutral {
  background: #f1f5f9;
  color: #334155;
}

.chip-positive {
  background: #fff2da;
  color: var(--positive);
}

.chip-negative {
  background: #f3f4f6;
  color: var(--negative-text);
}

.chip-warning {
  background: #fffbeb;
  color: #b45309;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  background: #fffbeb;
  color: #b45309;
  font-size: 12px;
  border-radius: 999px;
  padding: 6px 10px;
}

.chart-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.chart-wrap.is-enlarged {
  overflow: visible;
}

.chart-wrap svg {
  display: block;
}

.placeholder {
  min-height: 420px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 24px;
  color: var(--muted);
  background: #fff;
}

.hidden-summary {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hidden-summary .chip {
  background: #fff;
  border: 1px solid #fde68a;
  color: #92400e;
}

.hidden-summary-box {
  margin-top: 12px;
  background: #fffbeb;
  border-radius: 18px;
  padding: 12px;
}

.section-title {
  font-size: 22px;
  margin-bottom: 4px;
}

.section-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 14px;
}

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

.segment-row {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 20px;
  padding: 14px;
}

@media (min-width: 960px) {
  .segment-row {
    grid-template-columns: 1.2fr repeat(6, minmax(0, 1fr)) auto;
    align-items: center;
  }
}

.segment-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.segment-pos {
  font-size: 12px;
  color: var(--muted);
}

.mini-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.mini-value {
  font-size: 14px;
  font-weight: 600;
}

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

.empty-list {
  border: 1px dashed #cbd5e1;
  border-radius: 20px;
  background: #f8fafc;
  padding: 18px;
  color: var(--muted);
}

@media (max-width: 1099px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .app-shell {
    padding: 10px;
  }

  .panel {
    padding: 14px;
  }

  .title {
    font-size: 24px;
  }

  .form-row-2,
  .actions-inline,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .timeline-frame {
    padding: 12px;
  }

  .timeline-toolbar {
    align-items: stretch;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions .btn {
    width: 100%;
  }

  .chip {
    font-size: 12px;
    padding: 6px 10px;
  }

  .section-title {
    font-size: 20px;
  }
}