:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, .92);
  --surface-strong: #fff;
  --line: rgba(15, 23, 42, .08);
  --text: #101114;
  --muted: #747780;
  --blue: #0877e8;
  --orange: #ff5a00;
  --green: #138a4b;
  --red: #d92d3a;
  --purple: #6d4ce8;
  --shadow: 0 12px 40px rgba(18, 24, 40, .06);
  --radius: 20px;
  --sidebar: 236px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar);
  display: flex; flex-direction: column; padding: 24px 18px 16px;
  background: rgba(255,255,255,.82); border-right: 1px solid var(--line);
  backdrop-filter: saturate(160%) blur(28px);
}
.brand { display: flex; align-items: center; gap: 11px; margin: 0 8px 28px; color: inherit; text-decoration: none; }
.brand img { width: 37px; height: 37px; filter: drop-shadow(0 7px 14px rgba(20,35,60,.12)); }
.brand span { display: grid; gap: 2px; }
.brand strong { font-size: 15px; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: 10px; }
.navigation { display: flex; min-height: 0; flex: 1; flex-direction: column; gap: 4px; }
.navigation button, .logout-button {
  border: 0; background: transparent; width: 100%; min-height: 43px; border-radius: 13px;
  padding: 0 12px; display: grid; grid-template-columns: 22px 1fr auto; align-items: center;
  gap: 8px; text-align: left; cursor: pointer; color: #51545c; transition: .18s ease;
}
.navigation button:hover, .logout-button:hover { background: rgba(15,23,42,.045); color: #15171b; }
.navigation button.active { background: #ececef; color: #111318; font-weight: 650; }
.navigation button span, .logout-button span { color: #9799a1; text-align: center; font-size: 16px; }
.navigation button.active span { color: var(--orange); }
.navigation button small {
  border-radius: 999px; padding: 3px 7px; background: #fff2e9; color: #b74300;
  font-size: 9px; font-weight: 700;
}
.navigation .nav-spacer { margin-top: auto; }
.sidebar-footer { display: grid; gap: 4px; margin-top: 6px; }
.logout-form { margin: 0; }
.language-control {
  min-height: 38px; padding: 0 12px; display: grid; grid-template-columns: 22px 1fr;
  align-items: center; gap: 8px; color: #73767e;
}
.language-control span { color: #9799a1; text-align: center; font-size: 14px; }
.language-control select {
  width: 100%; border: 0; outline: 0; background: transparent; color: #51545c;
  cursor: pointer; font-size: 11px; font-weight: 700;
}
.main { grid-column: 2; min-width: 0; padding: 32px clamp(24px, 4vw, 64px) 48px; }
.topbar { min-height: 74px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; max-width: 1500px; margin: 0 auto; }
.topbar small { display: block; margin-bottom: 4px; color: #989aa2; font-weight: 700; font-size: 10px; letter-spacing: .13em; }
.topbar h1 { margin: 0; font-size: clamp(28px, 3vw, 38px); letter-spacing: -.045em; line-height: 1; }
.content { max-width: 1500px; margin: 22px auto 0; display: grid; gap: 14px; }

.button {
  border: 1px solid var(--line); background: rgba(255,255,255,.85); min-height: 40px;
  padding: 0 16px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; cursor: pointer; font-weight: 650; text-decoration: none; transition: .16s ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(15,23,42,.08); }
.button[hidden] { display: none; }
.button:disabled { opacity: .5; cursor: wait; transform: none; box-shadow: none; }
.button.primary { color: #fff; border-color: #111318; background: #111318; }
.button.compact { min-height: 34px; padding: 0 12px; font-size: 12px; }
.button.subtle { background: #f2f2f4; border-color: transparent; }
.button.wide { width: 100%; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi-grid.compact { grid-template-columns: repeat(8, minmax(112px, 1fr)); gap: 8px; }
.kpi-grid.marketplace-summary { grid-template-columns: repeat(7, minmax(112px, 1fr)); }
.kpi {
  position: relative; min-width: 0; min-height: 120px; padding: 18px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.kpi-grid.compact .kpi { min-height: 86px; padding: 13px 14px; border-radius: 16px; box-shadow: none; }
.kpi-label { color: #676a73; font-size: 12px; display: flex; align-items: center; gap: 5px; min-width: 0; }
.kpi-label span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-value { margin-top: 16px; font-size: clamp(23px, 2.2vw, 32px); font-weight: 750; letter-spacing: -.045em; white-space: nowrap; }
.kpi-grid.compact .kpi-value { margin-top: 9px; font-size: 20px; }
.change {
  margin-left: auto; flex: 0 0 auto; border-radius: 999px; padding: 3px 7px;
  font-size: 10px; font-weight: 700; background: #f0f1f3; color: #676a73;
}
.change.good { color: #08783f; background: #e9f8ef; }
.change.bad { color: #bd2630; background: #ffedef; }
.info {
  position: relative; flex: 0 0 15px; width: 15px; height: 15px; display: inline-grid; place-items: center;
  border: 1px solid #bec1c9; border-radius: 50%; color: #7c7f88; font-size: 9px; font-style: normal; cursor: help;
}
.info::after {
  content: attr(data-tip); pointer-events: none; opacity: 0; position: fixed; z-index: 100;
  transform: translate(-50%, 9px); width: max-content; max-width: 260px; padding: 8px 10px;
  border-radius: 9px; background: rgba(20,22,27,.96); color: white; font-size: 11px; line-height: 1.35;
  box-shadow: 0 8px 25px rgba(0,0,0,.18); transition: opacity .12s ease;
}
.info:hover::after { opacity: 1; }

.panel {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow); overflow: hidden;
}
.panel-header { min-height: 64px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 15px; letter-spacing: -.015em; }
.panel-body { padding: 18px 20px; }
.panel-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 14px; }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; }

.cash-chart { height: 210px; display: flex; align-items: flex-end; gap: clamp(10px, 2vw, 26px); padding: 14px 6px 0; }
.bar-group { flex: 1; min-width: 34px; height: 100%; display: grid; grid-template-rows: 1fr 22px; gap: 7px; }
.bars { display: flex; align-items: flex-end; justify-content: center; gap: 5px; min-height: 0; border-bottom: 1px solid var(--line); }
.bar { width: min(19px, 35%); min-height: 2px; border-radius: 6px 6px 2px 2px; }
.bar.in { background: #45b97c; }
.bar.out { background: #ff9b66; }
.bar-group label { color: #8c8f97; font-size: 10px; text-align: center; }
.chart-legend { display: flex; gap: 15px; color: var(--muted); font-size: 11px; }
.chart-legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #45b97c; }
.chart-legend span:last-child::before { background: #ff9b66; }

.table-wrap { width: 100%; overflow: auto; scrollbar-width: thin; }
.table-wrap.scroll-body { max-height: 510px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th {
  position: sticky; top: 0; z-index: 2; padding: 11px 14px; background: #fafafb;
  border-bottom: 1px solid var(--line); color: #8b8e97; text-align: right; font-size: 9px;
  letter-spacing: .06em; text-transform: uppercase;
}
th:first-child, td:first-child { text-align: left; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: right; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(245,245,247,.68); }
.cell-title { font-weight: 680; color: #1b1d22; }
.cell-sub { margin-top: 3px; color: #92949b; font-size: 10px; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; background: #f1f2f4; color: #666a73; font-size: 10px; font-weight: 650; }
.status.paid, .status.active { background: #eaf8f0; color: #087740; }
.status.flex { padding: 3px 6px; background: #edf3ff; color: #245cbb; }
.freight-cell { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; }
.row-action { border: 0; background: transparent; color: var(--blue); padding: 4px; cursor: pointer; font-size: 12px; font-weight: 650; }

.section-toolbar {
  min-height: 54px; padding: 7px 10px 7px 16px; border: 1px solid var(--line);
  border-radius: 16px; background: rgba(255,255,255,.85); display: flex; align-items: center;
  justify-content: space-between; gap: 14px;
}
.section-toolbar strong { font-size: 12px; }
.periods { display: flex; gap: 3px; padding: 3px; border-radius: 11px; background: #f0f0f2; }
.periods button { border: 0; background: transparent; min-height: 29px; padding: 0 11px; border-radius: 8px; color: #6f727a; font-size: 10px; font-weight: 700; cursor: pointer; }
.periods button.active { background: white; color: #14161a; box-shadow: 0 2px 8px rgba(20,25,35,.09); }

.campaign-table { min-width: 1220px; }
.campaign-table td { vertical-align: top; }
.metric { display: grid; justify-items: end; gap: 5px; }
.metric strong { font-size: 12px; }
.metric .change { margin: 0; }
.campaign-name { display: flex; align-items: center; gap: 8px; }
.campaign-toggle { width: 22px; height: 22px; border: 0; border-radius: 7px; background: #f0f1f3; cursor: pointer; }
.campaign-detail td { padding: 0; background: #fbfbfc; }
.campaign-detail:hover td { background: #fbfbfc; }
.campaign-expand { padding: 18px 24px 22px; display: grid; gap: 16px; }
.campaign-chart { width: 100%; height: 210px; overflow: visible; }
.campaign-chart .grid { stroke: #e7e8eb; stroke-width: 1; stroke-dasharray: 4 6; }
.campaign-chart .revenue { fill: none; stroke: #1684ee; stroke-width: 2.2; }
.campaign-chart .organic { fill: none; stroke: #68b8ff; stroke-width: 2.2; }
.campaign-chart .roas { fill: none; stroke: #6d4ce8; stroke-width: 2.2; }
.campaign-chart .previous { stroke-dasharray: 5 5; opacity: .78; }
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.share { padding: 14px 18px 0; border-right: 1px solid var(--line); }
.share:last-child { border-right: 0; }
.share label { display: block; color: #777a83; font-size: 10px; }
.share strong { display: inline-block; margin-top: 7px; font-size: 20px; letter-spacing: -.03em; }

.catalog-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(290px, .75fr); gap: 14px; }
.list { display: grid; }
.list-row { min-height: 59px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border: 0; }
.list-row strong { display: block; font-size: 12px; }
.list-row small { color: var(--muted); font-size: 10px; }
.access-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.access-card { padding: 18px; border-radius: 18px; background: white; border: 1px solid var(--line); }
.access-card h3 { margin: 0 0 5px; font-size: 15px; }
.access-card p { margin: 0; color: var(--muted); font-size: 11px; }
.access-card footer { margin-top: 19px; display: flex; align-items: center; justify-content: space-between; }

.modal[hidden], .toast[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,17,22,.28); backdrop-filter: blur(10px); }
.modal-card {
  position: relative; z-index: 1; width: min(480px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  padding: 25px; border: 1px solid rgba(255,255,255,.75); border-radius: 24px; background: rgba(255,255,255,.98);
  box-shadow: 0 30px 80px rgba(18,25,40,.2);
}
.modal-close {
  position: absolute; top: 13px; right: 13px; width: 31px; height: 31px; border: 0;
  border-radius: 50%; background: #eff0f2; color: #696c74; font-size: 20px; cursor: pointer;
}
.modal h2 { margin: 0 40px 20px 0; font-size: 22px; letter-spacing: -.035em; }
.form { display: grid; gap: 13px; }
.form label { display: grid; gap: 6px; color: #656870; font-size: 11px; font-weight: 650; }
.form input, .form select {
  width: 100%; height: 44px; padding: 0 12px; border: 1px solid #dfe0e4; border-radius: 12px;
  background: #fafafb; color: #17191d; outline: none; transition: border .15s, box-shadow .15s;
}
.form input:focus, .form select:focus { border-color: #6ba9ed; box-shadow: 0 0 0 3px rgba(8,119,232,.12); background: white; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-grid button {
  min-height: 105px; border: 1px solid var(--line); border-radius: 17px; background: #fafafb;
  cursor: pointer; font-weight: 700; transition: .15s;
}
.choice-grid button:hover { border-color: #cfd0d5; background: white; transform: translateY(-1px); }
.choice-grid button:last-child { grid-column: 1 / -1; min-height: 70px; }
.check { display: flex !important; grid-template-columns: 20px 1fr; align-items: center; }
.check input { width: 17px; height: 17px; }
.form-error { color: var(--red); font-size: 12px; text-align: center; }
.form-success { color: var(--green); font-size: 12px; text-align: center; }

.toast {
  position: fixed; z-index: 120; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 11px 15px; border-radius: 12px; background: rgba(21,23,28,.94);
  color: white; box-shadow: 0 12px 35px rgba(0,0,0,.22); font-size: 12px; font-weight: 600;
}
.toast.error { background: rgba(181,35,47,.96); }
.loading-state { min-height: 360px; display: grid; place-items: center; }
.loading-state span { width: 24px; height: 24px; border: 2px solid #dadbe0; border-top-color: #17191d; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 5%, #fff 0, #f5f5f7 42%, #eceef2 100%); }
.login-card {
  width: min(410px, 100%); padding: 36px; border: 1px solid rgba(255,255,255,.82); border-radius: 28px;
  background: rgba(255,255,255,.86); box-shadow: 0 30px 85px rgba(20,30,50,.12); backdrop-filter: blur(24px);
}
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 28px; }
.auth-brand img { width: 46px; height: 46px; filter: drop-shadow(0 9px 18px rgba(20,35,60,.14)); }
.auth-brand strong { font-size: 23px; letter-spacing: -.04em; }
.auth-language {
  display: flex; justify-content: center; gap: 3px; width: max-content; margin: -12px auto 22px;
  padding: 3px; border-radius: 10px; background: #f0f0f2;
}
.auth-language a {
  min-width: 42px; padding: 6px 9px; border-radius: 8px; color: #7b7e86;
  text-align: center; text-decoration: none; font-size: 10px; font-weight: 750;
}
.auth-language a.active { background: white; color: #15171b; box-shadow: 0 2px 8px rgba(20,25,35,.08); }
.auth-secondary {
  display: block; margin-top: 18px; color: #63666e; text-align: center;
  text-decoration: none; font-size: 12px; font-weight: 650;
}
.auth-secondary:hover { color: #111318; }
.login-form { display: grid; gap: 15px; }
.login-form label { display: grid; gap: 7px; color: #5e6169; font-size: 11px; font-weight: 650; }
.login-form input { width: 100%; height: 47px; padding: 0 13px; border: 1px solid #dfe1e6; border-radius: 13px; background: rgba(248,248,250,.9); outline: none; }
.login-form input:focus { background: white; border-color: #6ba9ed; box-shadow: 0 0 0 3px rgba(8,119,232,.12); }

@media (max-width: 1180px) {
  :root { --sidebar: 205px; }
  .main { padding-inline: 24px; }
  .kpi-grid.compact { grid-template-columns: repeat(4, 1fr); }
  .panel-grid, .catalog-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { inset: auto 0 0; width: auto; height: 70px; padding: 7px 9px calc(7px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--line); }
  .brand, .sidebar-footer, .navigation button.nav-spacer, #access-nav { display: none; }
  .navigation { flex-direction: row; justify-content: space-around; gap: 1px; }
  .navigation button { min-width: 0; min-height: 53px; grid-template-columns: 1fr; grid-template-rows: 20px 16px; justify-items: center; gap: 2px; padding: 4px; font-size: 9px; }
  .navigation button small { display: none; }
  .main { padding: 22px 14px 92px; }
  .topbar { min-height: 62px; }
  .topbar h1 { font-size: 28px; }
  .button.primary { min-height: 38px; padding: 0 13px; }
  .content { margin-top: 14px; }
  .kpi-grid, .kpi-grid.compact { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kpi { min-height: 97px; padding: 14px; border-radius: 17px; }
  .kpi-value { margin-top: 12px; font-size: 21px; }
  .kpi-grid.compact .kpi { min-height: 80px; }
  .panel { border-radius: 17px; }
  .panel-header { min-height: 55px; padding: 0 14px; }
  .panel-body { padding: 14px; }
  .section-toolbar { align-items: flex-start; flex-direction: column; }
  .periods { width: 100%; }
  .periods button { flex: 1; }
  .access-grid { grid-template-columns: 1fr; }
  .share-grid { grid-template-columns: 1fr; }
  .share { border-right: 0; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
  .share:last-child { border-bottom: 0; }
}
@media (max-width: 440px) {
  .topbar small { display: none; }
  .topbar { align-items: center; }
  .kpi-label { font-size: 10px; }
  .kpi-value { font-size: 18px; }
  .form-grid, .choice-grid { grid-template-columns: 1fr; }
  .choice-grid button:last-child { grid-column: auto; min-height: 84px; }
  .modal-card { padding: 22px 18px; border-radius: 22px; }
}
