:root {
  --bg: #f8fafc;
  --bg-soft: #ffffff;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: #ffffff;
  --panel-border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #06b6d4;
  --accent-strong: #0891b2;
  --accent-dark: #0f172a;
  --accent-dark-soft: #1e293b;
  --success: #39ff88;
  --success-strong: #16a34a;
  --success-soft: #dcfce7;
  --warning: #f59e0b;
  --danger: #ef4444;
  --violet: #8b5cf6;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 20px rgba(15, 23, 42, 0.06);
  --radius: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(6, 182, 212, 0.08), transparent 22%),
    radial-gradient(circle at 86% 10%, rgba(15, 23, 42, 0.06), transparent 22%),
    linear-gradient(180deg, #f8fafc 0%, #eef4fb 100%);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 18% 22%, rgba(239, 68, 68, 0.16), transparent 24%),
    radial-gradient(circle at 82% 14%, rgba(245, 158, 11, 0.16), transparent 22%),
    linear-gradient(180deg, #181c20 0%, #0f1318 100%);
}

.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top left, rgba(245, 158, 11, 0.1), transparent 24%),
    linear-gradient(180deg, rgba(39, 44, 50, 0.98), rgba(26, 30, 35, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.24),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

.login-logo {
  width: min(260px, 100%);
  justify-self: center;
}

.login-copy {
  display: grid;
  gap: 8px;
  text-align: center;
}

.login-copy h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: -0.04em;
  color: #f8fafc;
}

.login-copy p,
.login-status {
  margin: 0;
  color: #cbd5e1;
}

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

.login-form .field span {
  color: #e2e8f0;
}

.login-form input {
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  box-shadow: none;
}

.login-form input::placeholder {
  color: #94a3b8;
}

.login-submit {
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 52%, #f59e0b 100%);
  border: none;
  box-shadow:
    0 14px 28px rgba(220, 38, 38, 0.22),
    0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

.vendor-shell {
  width: min(1180px, calc(100% - 28px));
}

.vendor-header {
  margin-bottom: 18px;
}

.vendor-analysis-bar {
  margin-bottom: 18px;
}

.vendor-query-panel,
.vendor-result-panel {
  margin-bottom: 18px;
}

.app-shell {
  width: min(1480px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.hero,
.panel,
.stat-card,
.legend-card,
.glow-card,
.mode-bar,
.brand-header {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero,
.panel,
.stat-card,
.legend-card,
.glow-card,
.mode-bar,
.brand-header {
  border-radius: var(--radius);
}

.brand-header {
  padding: 14px 18px;
  margin-bottom: 22px;
  position: static;
  top: auto;
  z-index: auto;
}

.brand-header-topway {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  min-height: 92px;
  background:
    radial-gradient(circle at 18% 50%, rgba(255, 255, 255, 0.04), transparent 20%),
    radial-gradient(circle at 82% 50%, rgba(255, 255, 255, 0.04), transparent 20%),
    linear-gradient(180deg, #2c3134 0%, #2a2e31 42%, #25292c 100%);
  border-color: rgba(255, 255, 255, 0.05);
  padding: 10px 18px;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.14);
}

.brand-topway-side {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: start;
  padding-left: 10px;
}

.brand-topway-side-actions {
  justify-self: start;
  visibility: visible;
}

.brand-topway-side-placeholder {
  visibility: hidden;
}

.brand-topway-logo {
  display: block;
  width: min(420px, 70vw);
  max-height: 54px;
  object-fit: contain;
  justify-self: center;
  filter:
    drop-shadow(0 0 8px rgba(255, 255, 255, 0.12))
    drop-shadow(0 0 18px rgba(245, 158, 11, 0.08));
}

.brand-header-logout {
  border: 1px solid rgba(34, 197, 94, 0.24);
  color: #ffffff;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 52%, #0f9f6e 100%);
  box-shadow:
    0 10px 18px rgba(22, 163, 74, 0.22),
    0 1px 0 rgba(255, 255, 255, 0.14) inset;
  border-radius: 999px;
  min-height: 36px;
  padding: 0 14px;
  white-space: nowrap;
}

.brand-header-logout:hover {
  filter: brightness(1.03);
}

.hero {
  overflow: hidden;
  position: relative;
  padding: 30px;
  margin-bottom: 20px;
}

.hero::before {
  content: "";
  position: absolute;
  inset: auto -10% -45% 35%;
  height: 300px;
  background: radial-gradient(circle, rgba(15, 108, 189, 0.14), transparent 60%);
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.5fr 0.7fr;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
}

.hero h1,
.section-header h2 {
  margin: 0;
}

.hero h1 {
  max-width: 15ch;
  font-size: clamp(1.7rem, 3.8vw, 2.7rem);
  line-height: 1.04;
}

.section-header h2 {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-copy,
.section-header p,
.hint,
.status-message,
#tableSummary,
.glow-card p,
.legend-card span,
.ranking-item small,
.priority-card p {
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.hero-copy {
  max-width: 72ch;
  margin: 14px 0 0;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.meta-pill,
.status-chip,
.mode-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 700;
}

.meta-pill {
  padding: 10px 14px;
  background: rgba(15, 108, 189, 0.08);
  color: var(--accent);
}

.hero-side {
  display: flex;
  align-items: stretch;
}

.glow-card {
  width: 100%;
  padding: 22px;
  background:
    linear-gradient(145deg, rgba(15, 108, 189, 0.08), rgba(15, 157, 138, 0.1)),
    var(--panel-strong);
}

.glow-label {
  display: inline-block;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(15, 108, 189, 0.1);
}

.glow-card strong {
  display: block;
  font-size: 1.5rem;
  line-height: 1.2;
}

.panel {
  padding: 22px 22px 20px;
  margin-bottom: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
}

.section-header {
  margin-bottom: 18px;
}

.section-header p,
.hint,
.status-message,
#tableSummary,
.glow-card p,
.legend-card span {
  margin: 6px 0 0;
}

.control-grid,
.mapping-grid,
.analysis-meta-grid,
.cards-grid,
.filters-grid,
.executive-grid {
  display: grid;
  gap: 14px;
}

.control-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.mapping-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.analysis-meta-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 18px;
}

.cards-grid {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  margin-bottom: 20px;
}

.filters-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.executive-grid {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-span-2 {
  grid-column: span 2;
}

.field-compact {
  gap: 6px;
}

.config-filters-shell {
  display: grid;
  gap: 14px;
}

.config-meta-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.config-meta-chip {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid #dbe4ef;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  box-shadow: var(--shadow-soft);
}

.config-meta-chip strong {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-dark-soft);
}

.config-meta-chip span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.field span {
  font-size: 0.86rem;
  font-weight: 700;
}

.field-help {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.3;
}

.multi-filter {
  border: 1px solid #dbe4ef;
  border-radius: var(--radius-sm);
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.multi-filter summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 13px;
  min-height: 46px;
  display: flex;
  align-items: center;
  color: var(--text);
}

.multi-filter summary::-webkit-details-marker {
  display: none;
}

.multi-filter[open] summary {
  border-bottom: 1px solid rgba(122, 90, 55, 0.1);
}

.multi-filter[data-disabled="true"] {
  opacity: 0.55;
  pointer-events: none;
}

.table-filter-head {
  position: relative;
  min-width: 186px;
  overflow: visible;
}

.table-filter-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: relative;
  overflow: visible;
}

.table-filter-shell-stack {
  align-items: flex-start;
}

.table-filter-title-block {
  display: grid;
  gap: 6px;
}

.table-sort-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(56, 189, 248, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #e0f2fe;
  font-size: 0.66rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.table-sort-trigger:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(103, 232, 249, 0.44);
}

.table-filter-panel {
  position: relative;
  min-width: 0;
  margin-left: auto;
  border: none;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.table-filter-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px !important;
  padding: 6px 10px !important;
  border-radius: 999px;
  border: 1px solid rgba(6, 182, 212, 0.32);
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #39ff88;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1;
  text-shadow: 0 0 10px rgba(57, 255, 136, 0.28);
}

.table-filter-trigger,
.table-filter-trigger span,
#tableStatusFilterSummary {
  color: #39ff88 !important;
}

.table-filter-panel[open] .table-filter-trigger {
  border-color: rgba(34, 211, 238, 0.58);
  box-shadow: 0 8px 18px rgba(6, 182, 212, 0.2);
}

.table-filter-caret {
  font-size: 0.63rem;
  color: #67e8f9;
  opacity: 1;
}

.table-filter-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 290px;
  padding: 12px;
  border: 1px solid #dbe4ef;
  border-radius: 14px;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.16);
  z-index: 30;
}

.table-filter-dropdown *,
.table-filter-panel .multi-filter-option,
.table-filter-panel .multi-filter-option span,
.table-filter-panel .multi-filter-empty,
.table-filter-panel .multi-filter-actions,
.table-filter-panel .btn-tertiary {
  color: var(--text) !important;
}

.table-filter-dropdown-head {
  display: grid;
  gap: 3px;
  padding-bottom: 10px;
}

.table-filter-dropdown-head strong {
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.2;
}

.table-filter-dropdown-head span {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.multi-filter-actions {
  display: flex;
  gap: 8px;
  padding: 0 0 10px;
}

.multi-filter-list {
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  padding: 0;
}

.multi-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 10px;
  background: #f8fbff;
}

.table-filter-panel .btn-tertiary {
  border-color: #d7e2ee;
  background: #ffffff;
}

.table-filter-panel .btn-tertiary:hover:not(:disabled) {
  background: #f8fafc;
}

.multi-filter-option input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.multi-filter-empty {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 4px 0;
}

.period-inline-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  width: min(100%, 620px);
  margin-bottom: 18px;
  border: 1px solid #dbe4ef;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(6, 182, 212, 0.07), rgba(255, 255, 255, 0.98));
  box-shadow: var(--shadow-soft);
}

.period-inline-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.period-inline-header strong {
  font-size: 0.94rem;
}

.period-inline-header span {
  color: var(--muted);
  font-size: 0.76rem;
}

.period-inline-grid {
  display: grid;
  grid-template-columns: 110px minmax(140px, 1fr) minmax(140px, 1fr);
  gap: 10px;
}

.field-compact input,
.field-compact select {
  min-height: 40px;
  padding: 8px 10px;
}

#monthsWithoutPurchaseInput {
  max-width: 88px;
  text-align: center;
  font-weight: 700;
}

.mapping-details {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px dashed #cbd5e1;
  border-radius: 18px;
  background: rgba(248, 250, 252, 0.9);
}

.mapping-details summary {
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  color: var(--text);
}

.mapping-details summary::-webkit-details-marker {
  display: none;
}

.mapping-details summary::after {
  content: "+";
  float: right;
  color: var(--accent);
  font-size: 1rem;
}

.mapping-details[open] summary::after {
  content: "-";
}

.mapping-copy {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

.mapping-details .mapping-grid {
  padding-top: 2px;
}

.filters-grid-embedded {
  margin-top: 2px;
}

.action-row-compact {
  margin-top: 4px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  color: var(--text);
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

textarea {
  min-height: 145px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 3px solid rgba(6, 182, 212, 0.18);
  outline-offset: 1px;
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.action-row,
.mode-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.mode-actions[hidden] {
  display: none !important;
}

.btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.btn-tertiary {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #d7e2ee;
  border-radius: 10px;
  background: #ffffff;
  color: var(--accent-dark-soft);
}

.btn:hover:not(:disabled),
.mode-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #0891b2 100%);
  box-shadow: 0 12px 26px rgba(6, 182, 212, 0.24);
}

.btn-secondary {
  color: var(--accent-dark-soft);
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: var(--shadow-soft);
}

.loading-state {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-strong);
  font-weight: 700;
}

.legend-card,
.mini-panel {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.legend-card,
.stat-card {
  padding: 18px;
}

.legend-card strong {
  display: block;
  margin-bottom: 8px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  border-color: #e2e8f0;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: var(--shadow);
}

.stat-card::after {
  content: "";
  position: absolute;
  top: -30px;
  right: -10px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: var(--accent);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.82rem;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.1rem, 2vw, 1.8rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  white-space: normal;
  overflow-wrap: anywhere;
}

.stat-card-primary {
  --stat-accent: #0ea5e9;
}

.stat-card-success {
  --stat-accent: #39ff88;
}

.stat-card-warning {
  --stat-accent: #f59e0b;
}

.stat-card-accent {
  --stat-accent: #06b6d4;
}

.stat-card-accent-soft {
  --stat-accent: #8b5cf6;
}

.stat-card::before { background: var(--stat-accent, var(--accent)); }
.stat-card-primary strong { color: #0284c7; }
.stat-card-success strong { color: var(--success-strong); }
.stat-card-warning strong { color: var(--warning); }
.stat-card-danger strong { color: var(--danger); }
.stat-card-accent strong { color: var(--accent-strong); }
.stat-card-accent-soft strong { color: var(--violet); }

.filters-grid .field:not(.field-span-2) {
  min-width: 0;
}

.mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #dbe4ef;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}

.analysis-bar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 14% 50%, rgba(107, 33, 168, 0.08), transparent 20%),
    radial-gradient(circle at 86% 50%, rgba(220, 38, 38, 0.06), transparent 18%),
    linear-gradient(135deg, #495058 0%, #40474f 50%, #4a525b 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    0 12px 24px rgba(15, 23, 42, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  backdrop-filter: none;
}

.analysis-bar::before {
  content: "";
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 52%;
  border-radius: 28px 28px 22px 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.01));
  pointer-events: none;
}

.analysis-bar-left-block,
.analysis-bar-center-block {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0;
  position: relative;
  z-index: 1;
}

.analysis-bar-left-block {
  justify-content: flex-start;
}

.analysis-bar-center-block {
  justify-content: center;
}

.analysis-bar-left-title {
  color: #f8fafc;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.analysis-bar-logo {
  display: block;
  width: min(124px, 100%);
  max-width: 100%;
  object-fit: contain;
  filter:
    drop-shadow(0 0 4px rgba(255, 255, 255, 0.1));
}

.analysis-bar-actions {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  justify-self: end;
  gap: 8px;
}

.mode-button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid #dbe4ef;
  color: var(--accent-dark-soft);
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
  cursor: pointer;
}

.mode-button-active {
  color: #fff;
  border-color: rgba(6, 182, 212, 0.32);
  background: linear-gradient(135deg, #0891b2 0%, #06b6d4 55%, #22d3ee 100%);
  box-shadow:
    0 14px 30px rgba(6, 182, 212, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.18) inset;
}

.mode-actions {
  margin-top: 0;
}

.mode-actions .btn-secondary {
  border: 1px solid #d7e2ee;
  color: var(--accent-dark-soft);
  background: #ffffff;
  box-shadow: var(--shadow-soft);
  border-radius: 999px;
  min-height: 36px;
  padding: 0 14px;
  white-space: nowrap;
}

.analysis-bar-actions .btn-secondary {
  border: 1px solid rgba(34, 197, 94, 0.24);
  color: #ffffff;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 52%, #0f9f6e 100%);
  box-shadow:
    0 10px 18px rgba(22, 163, 74, 0.22),
    0 1px 0 rgba(255, 255, 255, 0.14) inset;
}

.analysis-bar-actions .btn-secondary:hover {
  filter: brightness(1.03);
}

.mode-section {
  display: none;
}

.mode-section-active {
  display: block;
}

.ranking-list,
.priority-list {
  display: grid;
  gap: 12px;
}

.ranking-item,
.priority-card {
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-soft);
}

.ranking-row,
.priority-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bar-track {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0891b2 0%, #06b6d4 100%);
}

.priority-card p {
  margin: 8px 0 0;
}

.empty-state {
  color: var(--muted);
}

.table-wrapper {
  overflow: auto;
  max-height: 68vh;
  border-radius: var(--radius-sm);
  border: 1px solid #dbe4ef;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.pdf-export-host {
  position: absolute;
  left: -20000px;
  top: 0;
  z-index: -1;
  overflow: visible;
  padding: 0;
  background: #f7f3ec;
}

.pdf-capture-root {
  margin: 0;
  padding: 18px 0 0;
  background: #f7f3ec;
}

.pdf-capture-analytic {
  padding-top: 0;
  background: transparent;
}

.pdf-export-wrapper {
  overflow: visible !important;
  max-height: none !important;
  height: auto !important;
}

.pdf-export-table {
  min-width: 100% !important;
  width: 100% !important;
}

.pdf-capture-header {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
  padding: 18px 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, #0f9d8a 0%, #11b5c9 48%, #1f78d1 100%);
  color: #fff;
  box-shadow: 0 16px 32px rgba(15, 108, 189, 0.18);
}

.pdf-capture-header strong {
  font-size: 1.15rem;
}

.pdf-capture-header span {
  font-size: 0.88rem;
  opacity: 0.96;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: separate;
  border-spacing: 0;
}

thead {
  position: sticky;
  top: 0;
  z-index: 3;
  background:
    linear-gradient(135deg, #4a3a32 0%, #3d302a 48%, #332823 100%);
}

thead::before {
  content: "";
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 48%;
  border-radius: 16px 16px 10px 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.01));
  pointer-events: none;
}

thead th {
  position: static;
  text-align: center;
  vertical-align: middle;
  background: transparent;
  color: #fff;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.12);
}

thead tr:first-child th:first-child {
  border-top-left-radius: 16px;
}

thead tr:first-child th:last-child {
  border-top-right-radius: 16px;
}

.table-brand-cell {
  width: 220px;
  padding: 6px 10px;
  vertical-align: middle;
}

.table-brand-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 132px;
  height: 34px;
  min-height: 34px;
  margin: 0 auto;
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.table-wrapper {
  border-radius: 18px;
}

.table-brand-logo {
  display: block;
  width: min(124px, 100%);
  max-width: 100%;
  object-fit: contain;
  filter:
    drop-shadow(0 0 4px rgba(255, 255, 255, 0.1));
}

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
  font-size: 0.76rem;
  white-space: normal;
}

thead th {
  padding-top: 6px;
  padding-bottom: 6px;
}

thead th:not(:last-child),
tbody td:not(:last-child) {
  border-right: 1px solid rgba(203, 213, 225, 0.72);
}

tbody td {
  background-clip: padding-box;
}

tbody tr:nth-child(even) {
  background: #f1f5f9;
}

tbody tr:hover {
  background: #e0f2fe;
}

.status-chip {
  padding: 6px 10px;
  font-size: 0.72rem;
  white-space: normal;
}

.status-chip-success {
  color: #14532d;
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  border: 1px solid rgba(57, 255, 136, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.status-chip-warning {
  color: #854d0e;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid rgba(245, 158, 11, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.status-chip-info {
  color: #9a3412;
  background: #ffedd5;
}

.status-chip-danger {
  color: #b91c1c;
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  border: 1px solid rgba(239, 68, 68, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.status-chip-neutral {
  color: #475569;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  border: 1px solid rgba(148, 163, 184, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.money-stack {
  display: grid;
  gap: 3px;
  min-width: 205px;
  white-space: normal;
}

.money-stack-shell {
  padding: 7px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(241, 245, 249, 0.98));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.82) inset,
    0 6px 14px rgba(15, 23, 42, 0.05);
}

.money-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.money-line-empty {
  background: #e2e8f0;
}

.money-line-purchased {
  border-color: rgba(148, 163, 184, 0.24);
}

.money-line-last {
  box-shadow:
    0 8px 18px rgba(15, 23, 42, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

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

.stack-cell {
  min-width: 158px;
  padding-left: 14px;
  padding-right: 14px;
}

.stack-cell-client {
  min-width: 220px;
}

.stack-primary {
  font-size: 0.77rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.18;
}

.stack-secondary {
  margin-top: 2px;
  color: var(--muted);
  line-height: 1.15;
  font-size: 0.72rem;
}

.meta-inline,
.stack-note {
  display: inline-flex;
  margin-top: 6px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0f172a;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.2;
}

.meta-inline,
.stack-note-total {
  color: #0f4c5c;
  background: linear-gradient(135deg, #dff7f7 0%, #bfeeee 100%);
  border: 1px solid rgba(15, 76, 92, 0.16);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.78) inset,
    0 10px 20px rgba(34, 211, 238, 0.14);
}

.stack-note-glow {
  border: 1px solid transparent;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.65) inset,
    0 8px 18px rgba(15, 23, 42, 0.08);
}

.stack-note-success {
  color: #14532d;
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  border-color: rgba(22, 163, 74, 0.18);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.75) inset,
    0 10px 20px rgba(34, 197, 94, 0.15);
}

.stack-note-info {
  color: #9a3412;
  background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%);
  border-color: rgba(234, 88, 12, 0.18);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.75) inset,
    0 10px 20px rgba(234, 88, 12, 0.14);
}

.stack-note-warning {
  color: #854d0e;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: rgba(245, 158, 11, 0.2);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.75) inset,
    0 10px 20px rgba(245, 158, 11, 0.16);
}

.stack-note-danger {
  color: #b91c1c;
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border-color: rgba(239, 68, 68, 0.18);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.75) inset,
    0 10px 20px rgba(239, 68, 68, 0.14);
}

.stack-note-neutral {
  color: #475569;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.78) inset,
    0 10px 20px rgba(148, 163, 184, 0.14);
}


.values-cell {
  min-width: 236px;
  padding-left: 14px;
  padding-right: 14px;
}

.status-cell {
  min-width: 154px;
  padding-left: 14px;
  padding-right: 14px;
}

.status-details {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.money-line-label {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.69rem;
  min-width: 0;
}

.money-line-label-active {
  color: inherit;
  font-weight: 800;
}

.money-line-value {
  color: var(--text);
  font-size: 0.72rem;
  white-space: nowrap;
  text-align: right;
}

.money-line-success {
  color: #14532d;
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  border-color: rgba(22, 163, 74, 0.24);
}

.money-line-info {
  color: #9a3412;
  background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%);
  border-color: rgba(234, 88, 12, 0.2);
}

.money-line-warning {
  color: #854d0e;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: rgba(245, 158, 11, 0.22);
}

.money-line-danger {
  color: #b91c1c;
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border-color: rgba(239, 68, 68, 0.24);
}

.money-line-neutral {
  color: #475569;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-color: rgba(148, 163, 184, 0.2);
}

.money-line-last.money-line-success {
  box-shadow:
    0 10px 20px rgba(34, 197, 94, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.money-line-last.money-line-info {
  box-shadow:
    0 10px 20px rgba(234, 88, 12, 0.16),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.money-line-last.money-line-warning {
  box-shadow:
    0 10px 20px rgba(245, 158, 11, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.money-line-last.money-line-danger {
  box-shadow:
    0 10px 20px rgba(239, 68, 68, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.money-line-last.money-line-neutral {
  box-shadow:
    0 10px 20px rgba(148, 163, 184, 0.16),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.money-line-success .money-line-label,
.money-line-success .money-line-value,
.money-line-success .money-line-label-active,
.money-line-info .money-line-label,
.money-line-info .money-line-value,
.money-line-info .money-line-label-active,
.money-line-warning .money-line-label,
.money-line-warning .money-line-value,
.money-line-warning .money-line-label-active,
.money-line-danger .money-line-label,
.money-line-danger .money-line-value,
.money-line-danger .money-line-label-active,
.money-line-neutral .money-line-label,
.money-line-neutral .money-line-value,
.money-line-neutral .money-line-label-active {
  color: inherit;
  font-weight: 700;
}

body[data-view="analytic"] .mode-bar {
  border-color: rgba(148, 163, 184, 0.16);
  box-shadow:
    0 12px 24px rgba(15, 23, 42, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

body[data-view="analytic"] .table-panel {
  border-color: rgba(148, 163, 184, 0.18);
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.08),
    0 0 0 1px rgba(148, 163, 184, 0.06);
}

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

  .field-span-2 {
    grid-column: span 1;
  }

  .period-inline-grid {
    grid-template-columns: 1fr;
  }

  .period-inline-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .mode-bar {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .analysis-bar-actions {
    justify-self: stretch;
    justify-content: flex-end;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 16px, 1480px);
    padding-top: 16px;
  }

  .hero {
    padding: 24px;
  }

  .hero h1 {
    max-width: none;
  }

  .brand-header-topway {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 8px;
    min-height: auto;
    padding: 14px 16px;
  }

  .brand-topway-side,
  .brand-topway-side-placeholder {
    display: none;
  }

  .brand-topway-logo {
    width: min(340px, 80vw);
  }
}
