:root {
  --bg: #07080b;
  --bg-2: #10141b;
  --line: #2a3342;
  --text: #e8edf4;
  --muted: #8b97a8;
  --accent: #c9daf8;
  --accent-deep: #1c4587;
  --sheet: #f4f6f8;
  --sheet-text: #111827;
  --header: #c9daf8;
  --calc: #e8e8e8;
  --pos: #d9ead3;
  --neg: #f4cccc;
  --input: #ffffff;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  font-family: "IBM Plex Sans", sans-serif;
}

* { box-sizing: border-box; }

html, body, #app {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(28, 69, 135, 0.45), transparent 60%),
    radial-gradient(800px 400px at 100% 100%, rgba(201, 218, 248, 0.08), transparent 50%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.login-mark, .brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--accent-deep);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 10px;
  flex-shrink: 0;
}

.login-kicker, .kicker {
  margin: 18px 0 6px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.login-panel h1, .modal h2, .empty-board h2, .analytics h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.login-copy, .empty-board p, .hint, .store-list span, .analytics-sub {
  color: var(--muted);
}

.login-form, .store-form { display: grid; gap: 14px; margin-top: 22px; }

label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

input, select {
  height: 42px;
  border: 1px solid var(--line);
  background: #0c1016;
  color: var(--text);
  border-radius: 10px;
  padding: 0 12px;
}

.login-form input:focus, .store-form input:focus, select:focus, .brand-name:focus, .date-filter:focus {
  outline: 2px solid #6d9ee0;
  border-color: transparent;
}

.login-error { margin: 0; color: #f4cccc; font-size: 14px; }

.btn, .login-form button {
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #10203a;
  font-weight: 700;
  cursor: pointer;
  padding: 0 14px;
}

.btn.ghost, .icon-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn.danger {
  background: transparent;
  color: #ffd7d3;
  border: 1px solid #7a271a;
}

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

.app-shell {
  min-height: 100vh;
  background: linear-gradient(180deg, #0d1522 0%, var(--bg) 180px);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(7, 8, 11, 0.92);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}

.brand-name {
  height: 32px;
  width: 240px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  padding: 0 8px;
  border-radius: 8px;
}

.brand-name:hover { border-color: var(--line); }
.brand span { color: var(--muted); font-size: 12px; display: block; }

.filters { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
.filters label { min-width: 150px; }
.filter-wide { flex: 1; min-width: 200px; }
.date-filter { color-scheme: dark; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
  padding: 16px 20px 8px;
}

.kpi {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}

.kpi span { color: var(--muted); font-size: 12px; }
.kpi strong {
  display: block;
  margin-top: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 22px;
  letter-spacing: -0.03em;
}
.kpi.good strong { color: #b7e0b0; }
.kpi.bad strong { color: #ffb4ab; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.85fr);
  gap: 16px;
  padding: 12px 20px 28px;
  align-items: start;
}

.sheet {
  background: #0a0a0a;
  border: 1px solid #222;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.sheet-scroll { overflow: auto; }

.grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--sheet);
  color: var(--sheet-text);
  font-size: 12px;
}

.grid th, .grid td {
  border: 1px solid #111;
  padding: 0;
  height: 30px;
  text-align: right;
  white-space: nowrap;
}

.grid th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--header);
  color: #111;
  font-weight: 700;
  text-align: center;
  padding: 8px;
}

.date-cell, .row-label {
  background: var(--header);
  text-align: right;
  padding: 0 8px;
  font-weight: 500;
}

.input-cell { background: var(--input); }

.input-cell input, .offer-name {
  width: 100%;
  height: 30px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--sheet-text);
  text-align: right;
  padding: 0 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.offer-name {
  text-align: center;
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 700;
  height: 34px;
}

.calc {
  background: var(--calc);
  padding: 0 8px;
  font-family: "IBM Plex Mono", monospace;
}

.grid tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--accent-deep);
  color: #fff;
  font-weight: 700;
  padding: 6px 8px;
  font-family: "IBM Plex Mono", monospace;
}

.grid tfoot td:first-child {
  font-family: "IBM Plex Sans", sans-serif;
  text-align: left;
}

.pos { background: var(--pos) !important; color: #1d3b1a !important; }
.neg { background: var(--neg) !important; color: #7a271a !important; }

.side-panels { display: grid; gap: 14px; }
.offers { table-layout: fixed; }
.offers td:first-child { text-align: left; }

.costos {
  background: var(--sheet);
  color: var(--sheet-text);
  padding: 14px;
}

.costos h3, .store-form h3, .modal h2 { margin: 0 0 10px; }
.costos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.costos input { background: #fff; color: #111; border-color: #bbb; }
.hint { margin: 12px 0 0; font-size: 12px; }

.empty-board { margin: 80px auto; text-align: center; max-width: 420px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 30;
}

.modal {
  width: min(640px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  max-height: 90vh;
  overflow: auto;
}

.modal-head { display: flex; justify-content: space-between; align-items: start; }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; font-size: 22px; cursor: pointer; }

.store-list { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 8px; }
.store-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.store-list strong, .store-list span { display: block; }
.row-actions, .form-actions, .form-row { display: flex; gap: 8px; }
.form-row label { flex: 1; }
.form-actions { justify-content: flex-end; }

.analytics { padding: 16px 20px 40px; }
.analytics-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.analytics-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}
.analytics-toggle input { width: auto; height: auto; }
.chart-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-top: 14px;
}
.chart-card h3 { margin: 0 0 12px; font-size: 15px; }
.bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  gap: 10px;
  align-items: center;
  margin: 7px 0;
  font-size: 12px;
  color: var(--muted);
}
.bar-track {
  height: 10px;
  background: #1a2230;
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: #8bb4e8;
}
.bar-fill.ads { background: #f0b429; }
.bar-fill.res { background: #6fbf73; }
.bar-fill.bad { background: #e07070; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.muted-note { color: var(--muted); font-size: 13px; }

@media (max-width: 1100px) {
  .workspace, .kpis { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}

@media (max-width: 720px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .brand { min-width: 0; }
  .brand-name { width: 150px; }
}
