:root {
  --bg: #e7eee9;
  --bg-deep: #d2ddd5;
  --ink: #101a14;
  --muted: #51665b;
  --line: #b7c6bb;
  --panel: rgba(255, 255, 255, 0.86);
  --accent: #0f6b4c;
  --accent-soft: #d7efe4;
  --warn: #b45309;
  --crit: #9f1239;
  --ok: #047857;
  --allegro: #ff5a00;
  --ai: #0e7490;
  --shadow: 0 16px 42px rgba(16, 26, 20, 0.08);
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body, #root { min-height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 8% -8%, #f7fcf6 0%, transparent 55%),
    radial-gradient(900px 480px at 100% 0%, #f8e9df 0%, transparent 42%),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
}

button, input, select, textarea { font: inherit; }
button {
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 0.62rem 1.05rem;
  background: var(--accent);
  color: #f4fff9;
  transition: transform 150ms ease, opacity 150ms ease, background 150ms ease;
}
button:hover { transform: translateY(-1px); background: #0c563d; }
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.ghost { background: var(--accent-soft); color: var(--accent); }
button.allegro { background: var(--allegro); color: #fff; }
button.ai { background: var(--ai); color: #fff; }
button:disabled { opacity: 0.55; cursor: wait; transform: none; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.62rem 0.78rem;
  background: #fff;
  color: var(--ink);
}
label { display: grid; gap: 0.3rem; font-size: 0.84rem; color: var(--muted); }

.app { width: min(1360px, calc(100% - 1.5rem)); margin: 0 auto; padding: 1.1rem 0 3rem; }

.topbar {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: end;
  margin-bottom: 0.75rem; animation: rise 500ms ease both;
}
.brand {
  margin: 0; font-size: clamp(2.1rem, 4.5vw, 3.2rem);
  letter-spacing: -0.04em; line-height: 0.95; font-weight: 700;
}
.brand span { color: var(--accent); }
.tagline { margin: 0.35rem 0 0; color: var(--muted); max-width: 42rem; }
.pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.75rem; border-radius: 999px; background: #fff;
  border: 1px solid var(--line); font-size: 0.82rem; color: var(--muted);
}

.nav { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.85rem 0 1.1rem; }
.nav button { background: transparent; color: var(--muted); border: 1px solid transparent; }
.nav button.active {
  background: #fff; color: var(--ink); border-color: var(--line); box-shadow: var(--shadow);
}

.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.95rem; }

.stats {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.65rem; margin-bottom: 1rem;
}
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .stats { grid-template-columns: 1fr 1fr; } }
.stat {
  background: var(--panel); border: 1px solid rgba(183,198,187,.75);
  border-radius: var(--radius); padding: 0.9rem; box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 0.8rem; }
.stat .value { font-family: var(--mono); font-size: 1.4rem; margin-top: 0.15rem; }
.stat .delta { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 0.9rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; }
.grid-analytics { display: grid; grid-template-columns: 1.5fr 1fr; gap: 0.9rem; }
@media (max-width: 980px) {
  .grid-2, .grid-3, .grid-analytics { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel); border: 1px solid rgba(183,198,187,.75);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  animation: rise 650ms ease both;
}
.panel h2, .panel h3 {
  margin: 0; padding: 0.9rem 1rem; font-size: 0.98rem;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 0.7rem;
}
.panel .body { padding: 0.2rem 0; }
.panel .pad { padding: 1rem; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th, table.data td {
  text-align: left; padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(183,198,187,.45); vertical-align: top;
}
table.data th {
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); background: rgba(255,255,255,.55); position: sticky; top: 0;
}
table.data tr:hover td { background: rgba(15,107,76,.04); }
table.data tr.selected td { background: rgba(15,107,76,.09); }

.sku { font-family: var(--mono); font-size: 0.8rem; color: var(--accent); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.price { font-family: var(--mono); font-weight: 500; }

.badge {
  display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.72rem;
  padding: 0.16rem 0.48rem; border-radius: 999px; background: #dcefe4; color: var(--ok);
  white-space: nowrap;
}
.badge.warn { background: #ffedd5; color: var(--warn); }
.badge.crit { background: #ffe4e6; color: var(--crit); }
.badge.muted { background: #e7ece7; color: var(--muted); }
.badge.allegro { background: #ffe8db; color: #c2410c; }
.badge.ai { background: #cffafe; color: #155e75; }

.searchbar {
  display: grid; grid-template-columns: 1fr auto; gap: 0.55rem;
  padding: 0.95rem 1rem; border-bottom: 1px solid var(--line);
}
.searchbar.triple { grid-template-columns: 1fr 180px auto; }
.searchbar.quad { grid-template-columns: 1.2fr 180px 1fr auto; }
@media (max-width: 800px) {
  .searchbar, .searchbar.triple, .searchbar.quad { grid-template-columns: 1fr; }
}

.form-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; padding: 1rem;
}
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.setting-group h3 {
  border: 0; padding: 0.8rem 1rem 0.15rem; font-size: 0.76rem;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
.setting-row {
  display: grid; grid-template-columns: 1.45fr 0.8fr; gap: 0.7rem; align-items: center;
  padding: 0.7rem 1rem; border-bottom: 1px solid rgba(183,198,187,.4);
}
@media (max-width: 700px) { .setting-row { grid-template-columns: 1fr; } }

.chart {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(16px, 1fr));
  gap: 4px; align-items: end; height: 150px; padding: 1rem 1rem 0.35rem;
}
.bar {
  background: linear-gradient(180deg, #1a8f68, #0f6b4c);
  border-radius: 6px 6px 2px 2px; min-height: 4px;
}
.bar.market { background: linear-gradient(180deg, #f0a06a, #c45c26); opacity: 0.85; }
.bar.blocked { background: linear-gradient(180deg, #fb7185, #9f1239); }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 0.9rem; padding: 0 1rem 1rem;
  font-size: 0.8rem; color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 0.3rem; }
.dot.ours { background: #0f6b4c; }
.dot.mkt { background: #c45c26; }
.dot.blk { background: #9f1239; }

.spark {
  display: flex; align-items: end; gap: 3px; height: 42px; margin-top: 0.45rem;
}
.spark i {
  display: block; flex: 1; border-radius: 3px 3px 1px 1px;
  background: rgba(15,107,76,.55); min-height: 3px;
}

.decision, .alert-item, .insight, .watch-item {
  padding: 0.8rem 1rem; border-bottom: 1px solid rgba(183,198,187,.45);
}
.empty { padding: 1.1rem; color: var(--muted); }

.mode-banner {
  margin: 0 1rem 0.7rem; padding: 0.7rem 0.85rem; border-radius: 10px;
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; font-size: 0.88rem;
}
.mode-banner.live { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.mode-banner.ai { background: #ecfeff; border-color: #a5f3fc; color: #155e75; }
.mode-banner.presentation { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.help-box { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 1rem 1.1rem; line-height: 1.55; font-size: .92rem; }
.help-box h3 { margin: 0 0 .55rem; font-size: 1rem; }
.help-box ul { margin: .35rem 0 .8rem 1.1rem; padding: 0; }
.help-box li { margin: .25rem 0; }
.help-box strong { font-weight: 650; }


.kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.55rem; padding: 0.85rem 1rem;
}
@media (max-width: 900px) { .kpi-row { grid-template-columns: 1fr 1fr; } }
.kpi-mini {
  background: #f4faf6; border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem 0.8rem;
}
.kpi-mini .k { font-size: 0.75rem; color: var(--muted); }
.kpi-mini .v { font-family: var(--mono); font-size: 1.15rem; margin-top: 0.15rem; }

.toast {
  position: fixed; right: 1rem; bottom: 1rem; background: var(--ink); color: #f4fff9;
  padding: 0.85rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow);
  max-width: min(30rem, calc(100vw - 2rem)); z-index: 20; animation: rise 220ms ease both;
}

.login-wrap {
  display: grid; place-items: center; min-height: 55vh; padding: 1rem 0 2rem;
}
.login-card { width: min(420px, 100%); }
.userchip {
  display: flex; align-items: center; gap: 0.75rem; justify-content: flex-end;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 0.55rem 0.7rem; box-shadow: var(--shadow);
}

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