:root {
  color-scheme: dark;
  --bg: #07080a;
  --panel: #101216;
  --panel-2: #171a20;
  --panel-3: #20242c;
  --table-head: #171a20;
  --table-selected: #14282d;
  --table-hover: #171a20;
  --line: #ffffff18;
  --line-strong: #ffffff30;
  --text: #f6f8fb;
  --muted: #aab1bd;
  --soft: #79818e;
  --accent: #d7fb4a;
  --cyan: #34d3e8;
  --green: #52d273;
  --red: #ff6b6b;
  --amber: #ffbf4d;
  --shadow: 0 22px 70px #00000070;
  --radius: 8px;
  --page-pad-x: clamp(14px, 2vw, 28px);
  --table-width: 1680px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --select-arrow: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%23f6f8fb' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  height: 100%;
}

body {
  min-width: 280px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    linear-gradient(90deg, #ffffff08 1px, transparent 1px),
    linear-gradient(#ffffff06 1px, transparent 1px),
    var(--bg);
  background-size: 42px 42px;
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.auth-loading .app-shell,
body.auth-locked .app-shell {
  display: none;
}

body:not(.auth-loading):not(.auth-locked) .login-screen {
  display: none;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 22px;
}

.login-card {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101216ee;
  box-shadow: var(--shadow);
  padding: 24px;
}

body.is-light .login-card {
  background: #f8faf5f2;
  box-shadow: 0 18px 58px #18210f14, inset 0 1px 0 #ffffffd8;
}

.login-card h1 {
  font-size: 24px;
  line-height: 1.1;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-card input {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #050608;
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  width: 100%;
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  display: inline-grid;
  width: 40px;
  height: 40px;
  min-height: 40px;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--soft);
  cursor: pointer;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  background: #ffffff10;
  color: var(--text);
  outline: none;
}

body.is-light .login-card input {
  background: #ffffff;
}

.login-card input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px #34d3e82b;
}

.login-card input[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 3px #ff636326;
}

.login-error {
  min-height: 18px;
  margin: -4px 0 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}

@supports (overflow: clip) {
  body,
  .app-shell {
    overflow-x: clip;
  }
}

body.is-light {
  color-scheme: light;
  --bg: #eef1ea;
  --panel: #f8faf5;
  --panel-2: #e8ede3;
  --panel-3: #ffffff;
  --table-head: #e8ede3;
  --table-selected: #dceae7;
  --table-hover: #eef3eb;
  --line: #1c25101f;
  --line-strong: #1c251038;
  --text: #151915;
  --muted: #4f584f;
  --soft: #717a70;
  --accent: #93af2d;
  --cyan: #2497a7;
  --green: #268d4b;
  --red: #c94848;
  --amber: #9a690f;
  --shadow: 0 18px 58px #18210f24;
  --select-arrow: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%23151915' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background:
    linear-gradient(90deg, #1c251008 1px, transparent 1px),
    linear-gradient(#1c251008 1px, transparent 1px),
    var(--bg);
}

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

button {
  cursor: pointer;
  touch-action: manipulation;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

.sidebar,
.rightbar {
  position: sticky;
  top: 0;
  overflow-y: auto;
  background: #090a0de8;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.sidebar {
  z-index: 20;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto auto auto auto auto auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 68px;
  overflow: visible;
  border-bottom: 1px solid var(--line);
  padding: 10px max(var(--page-pad-x), env(safe-area-inset-right)) 10px max(var(--page-pad-x), env(safe-area-inset-left));
}

body.is-light .sidebar,
body.is-light .rightbar {
  background: #f7f9f2f0;
  box-shadow: 0 1px 0 #ffffffb8;
}

.brand {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 44px;
  min-width: clamp(150px, 14vw, 220px);
}

.brand-icon,
.nav-icon,
.side-head > i {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff0d;
  color: var(--cyan);
}

.nav-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
}

.brand-icon {
  background: var(--accent);
  color: #111;
}

.brand strong {
  display: block;
  font-size: 20px;
  line-height: 1;
}

.brand span,
.side-head span,
.metric-note,
.panel-head p,
.muted {
  color: var(--soft);
}

.brand div span {
  display: none;
}

.theme-switch {
  display: inline-flex;
  width: 80px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 0;
}

.theme-switch-track {
  position: relative;
  display: block;
  width: 76px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #ffffff0b;
  box-shadow: inset 0 1px 0 #ffffff12;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.theme-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 1;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #101216;
  box-shadow: 0 8px 22px #00000042;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}

.theme-switch-glyph {
  position: absolute;
  top: 50%;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: var(--soft);
  opacity: 0.58;
  transform: translateY(-50%);
}

.theme-switch-glyph.start {
  left: 5px;
}

.theme-switch-glyph.end {
  right: 5px;
}

body.is-light .theme-switch-track {
  background: #ffffffa8;
  border-color: #1c251030;
  box-shadow: inset 0 1px 0 #ffffffd8, 0 10px 24px #18210f12;
}

body.is-light .theme-switch-knob {
  transform: translateX(40px);
}

.theme-switch:hover .theme-switch-track,
.theme-switch:focus-visible .theme-switch-track {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #d7fb4a24, inset 0 1px 0 #ffffff12;
}

body.is-light .theme-switch:hover .theme-switch-track,
body.is-light .theme-switch:focus-visible .theme-switch-track {
  box-shadow: 0 0 0 3px #93af2d24, inset 0 1px 0 #ffffffd8;
}

.theme-switch svg {
  width: 15px;
  height: 15px;
}

.nav {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  overflow: visible;
  justify-content: flex-start;
}

.nav button {
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 5px 9px;
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.nav button:hover,
.nav button.active {
  border-color: var(--line-strong);
  background: #ffffff10;
  color: var(--text);
}

body.is-light .nav button:hover,
body.is-light .nav button.active,
body.is-light .ghost,
body.is-light .icon,
body.is-light .tiny,
body.is-light .segments,
body.is-light .count,
body.is-light #alertCount {
  background: #ffffff9c;
}

.nav button:hover {
  transform: translateY(-1px);
}

.nav button.active .nav-icon {
  background: var(--accent);
  color: #101216;
}

.nav-name,
.nav-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-name {
  max-width: clamp(72px, 8vw, 128px);
  font-size: 13px;
  font-weight: 700;
}

.nav-meta {
  display: none;
}

.count,
#alertCount {
  flex: 0 0 auto;
  min-width: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff0c;
  padding: 3px 7px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.sidebar-bottom {
  display: none;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 18px #52d273a0;
}

.workspace {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  padding: 18px var(--page-pad-x) 34px;
}

.topbar {
  display: none;
  align-items: flex-start;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 18px;
  min-width: 0;
}

.topbar > div {
  min-width: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.08;
}

#pageSubtitle {
  margin-top: 8px;
  max-width: 760px;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.45;
}

.page-heading {
  display: none;
}

#panelSubtitle {
  display: none;
}

.top-actions,
.panel-actions,
.row-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.top-actions {
  max-width: 100%;
  min-width: 0;
}

.segments {
  display: none;
  grid-template-columns: repeat(2, minmax(116px, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff08;
}

.segment,
.primary,
.ghost,
.icon,
.tiny {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
  white-space: nowrap;
}

.segment {
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.segment.active {
  background: var(--accent);
  color: #101216;
  font-weight: 750;
}

.primary {
  background: var(--accent);
  color: #101216;
  font-size: 13px;
  font-weight: 750;
}

.save {
  background: var(--cyan);
}

.admin-toggle.active {
  border-color: #52d27366;
  background: #52d27318;
  color: var(--green);
}

.sidebar .admin-toggle {
  justify-self: start;
  width: auto;
  min-height: 38px;
  padding: 8px 11px;
  font-size: 13px;
}

.sidebar .logout-toggle {
  justify-self: start;
  width: auto;
  min-height: 38px;
  padding: 8px 11px;
  font-size: 13px;
}

.user-chip {
  display: inline-flex;
  min-width: 0;
  max-width: 210px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff08;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 750;
}

.user-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.is-light .user-chip {
  background: #ffffff9c;
}

body.is-buyer .admin-toggle,
body.is-buyer .admin-tools {
  display: none;
}

.admin-tools {
  position: relative;
  min-width: 0;
}

.admin-tools:empty {
  display: none;
}

.admin-agent-settings {
  position: relative;
}

.admin-agent-settings summary {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff0d;
  padding: 8px 11px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  list-style: none;
  cursor: pointer;
}

.admin-agent-settings summary::-webkit-details-marker {
  display: none;
}

.admin-agent-settings[open] summary {
  border-color: var(--cyan);
}

.admin-agent-settings .agent-form {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 50;
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 12px;
}

body.is-light .admin-agent-settings summary,
body.is-light .admin-agent-settings .agent-form {
  background: #ffffffed;
}

.compact-action {
  min-height: 40px;
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 700;
}

.panel-actions .icon {
  min-height: 40px;
  width: 40px;
}

.ghost,
.icon,
.tiny {
  border-color: var(--line);
  background: #ffffff09;
}

.icon {
  width: 38px;
  padding: 0;
}

.tiny {
  width: 30px;
  height: 30px;
  padding: 0;
}

.full {
  width: 100%;
}

.primary:hover,
.ghost:hover,
.icon:hover,
.tiny:hover,
.segment:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

svg {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.dashboard-period-bar {
  display: none;
  max-width: 780px;
  grid-template-columns: minmax(180px, 240px) repeat(2, minmax(150px, 180px));
  align-items: end;
  gap: 10px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101216ee;
  padding: 12px;
  box-shadow: var(--shadow);
}

body.is-light .dashboard-period-bar {
  background: #f8faf5f2;
  box-shadow: 0 18px 58px #18210f14, inset 0 1px 0 #ffffffd8;
}

.dashboard-period-bar label {
  min-width: 0;
}

.dashboard-period-bar input,
.dashboard-period-bar select {
  min-height: 40px;
  border-radius: 7px;
}

body[data-view="dashboard"] .dashboard-period-bar {
  display: grid;
}

body[data-period]:not([data-period="custom"]) .dashboard-period-bar .date-range-label {
  display: none;
}

body[data-view="dashboard"] .dashboard-period-bar + .metrics {
  margin-top: 10px;
}

.metrics.metric-count-7 {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.metrics.metric-count-7 .metric {
  grid-column: span 3;
}

.metrics.metric-count-7 .metric:nth-child(-n + 3) {
  grid-column: span 4;
}

.metric {
  min-width: 0;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff10, transparent), var(--panel);
  padding: 14px;
  box-shadow: inset 0 1px 0 #ffffff12;
}

.metric:first-child {
  border-color: #52d27355;
  background: linear-gradient(180deg, #52d2731f, transparent), var(--panel);
}

body.is-light .metric {
  background:
    linear-gradient(180deg, #ffffffd6, transparent 68%),
    var(--panel);
  box-shadow: 0 10px 28px #18210f10, inset 0 1px 0 #ffffffd6;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 20px;
  font-weight: 850;
  line-height: 1;
}

.metric-value.priority {
  font-size: 24px;
}

.metric-note {
  margin-top: 9px;
  font-size: 11px;
}

.good,
.pnl-plus {
  color: var(--green);
}

.bad,
.pnl-minus {
  color: var(--red);
}

.warn {
  color: var(--amber);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.filters,
.work-panel,
.side-card,
.table-wrap,
.drawer,
.campaign,
.alert,
.activity,
.settings-card,
.dashboard-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101216ee;
  box-shadow: var(--shadow);
}

body.is-light .filters,
body.is-light .work-panel,
body.is-light .side-card,
body.is-light .table-wrap,
body.is-light .drawer,
body.is-light .campaign,
body.is-light .alert,
body.is-light .activity,
body.is-light .settings-card,
body.is-light .dashboard-card {
  background: #f8faf5f2;
  box-shadow: 0 18px 58px #18210f14, inset 0 1px 0 #ffffffd8;
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(240px, 0.72fr) minmax(0, 1.28fr);
  gap: 12px;
  padding: 14px 14px 0;
}

.control-strip section {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 12px;
  box-shadow: none;
}

.mini-label {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.control-strip strong {
  font-size: 15px;
}

.control-strip p {
  max-width: 760px;
  color: var(--soft);
  font-size: 12px;
  line-height: 1.4;
}

.agent-form {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(150px, 0.8fr) minmax(110px, 0.5fr) minmax(150px, auto);
  align-items: end;
  gap: 8px;
}

.filters {
  display: block;
  padding: 12px;
}

.filters .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin-bottom: 10px;
}

.filters .panel-head h2 {
  font-size: 14px;
}

.filters .panel-head p {
  display: none;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  align-items: end;
  gap: 8px;
  min-width: 0;
}

.filter-grid label {
  min-width: 0;
  gap: 5px;
}

.filter-grid input,
.filter-grid select {
  min-height: 40px;
  border-radius: 7px;
  padding-top: 7px;
  padding-bottom: 7px;
}

.search-label {
  min-width: 0;
}

.date-range-label input:disabled {
  opacity: 0.42;
}

.filters .automation {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}

.filters .automation b {
  display: none;
}

.filters .check {
  min-height: 32px;
  padding: 7px 10px;
}

.work-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head,
.side-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  min-width: 0;
}

.panel-head > div,
.side-head > div {
  min-width: 0;
}

.panel-head-main {
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  padding: 15px 16px;
}

body.is-light .panel-head-main {
  background: #e8ede3;
}

.panel-head h2,
.side-head h2 {
  font-size: 16px;
  line-height: 1.2;
}

.panel-head p {
  margin-top: 5px;
  font-size: 12px;
}

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

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: #07080a;
  color: var(--text);
  padding: 8px 10px;
}

body.is-light input,
body.is-light select,
body.is-light textarea {
  background: #ffffffbd;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background: #07080a var(--select-arrow) no-repeat right 12px center / 17px 17px;
  padding-right: 38px;
}

body.is-light select {
  background: #ffffffbd var(--select-arrow) no-repeat right 12px center / 17px 17px;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px #34d3e824;
}

body.is-light input:focus,
body.is-light select:focus,
body.is-light textarea:focus {
  box-shadow: 0 0 0 3px #2497a71f;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

.automation {
  display: grid;
  gap: 9px;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.automation b,
.side-head span {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.check {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff08;
  padding: 8px 10px;
  color: var(--text);
}

body.is-light .check,
body.is-light .mini-grid div,
body.is-light .server-fields div,
body.is-light .service-status {
  background: #ffffff9c;
}

.check input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 18px;
  padding: 14px;
}

.dashboard-stack {
  display: grid;
  gap: 18px;
  padding: 14px;
}

.dashboard-stack .dashboard-grid {
  padding: 0;
}

.dashboard-card {
  --card-accent: var(--cyan);
  --card-accent-soft: #34d3e812;
  --card-accent-line: #34d3e84d;
  --card-accent-glow: #34d3e824;
  position: relative;
  overflow: hidden;
  border-color: var(--card-accent-line);
  background:
    linear-gradient(180deg, var(--card-accent-soft), transparent 46%),
    #101216ee;
  padding: 16px;
  box-shadow: inset 0 1px 0 #ffffff12, 0 18px 44px #00000024;
}

.dashboard-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--card-accent), transparent 74%);
}

.dashboard-card.is-buyers {
  --card-accent: #52d273;
  --card-accent-soft: #52d27314;
  --card-accent-line: #52d27352;
  --card-accent-glow: #52d27326;
}

.dashboard-card.is-offers {
  --card-accent: #34d3e8;
  --card-accent-soft: #34d3e812;
  --card-accent-line: #34d3e84d;
  --card-accent-glow: #34d3e824;
}

.dashboard-card.is-advertisers {
  --card-accent: #f5be4a;
  --card-accent-soft: #f5be4a12;
  --card-accent-line: #f5be4a4d;
  --card-accent-glow: #f5be4a24;
}

.dashboard-card.is-spend {
  --card-accent: #8fb3ff;
  --card-accent-soft: #8fb3ff12;
  --card-accent-line: #8fb3ff4d;
  --card-accent-glow: #8fb3ff24;
}

.dashboard-card.is-problems {
  --card-accent: #ff6370;
  --card-accent-soft: #ff637012;
  --card-accent-line: #ff63704d;
  --card-accent-glow: #ff637024;
}

.dashboard-card.is-bills {
  --card-accent: #d7fb4a;
  --card-accent-soft: #d7fb4a12;
  --card-accent-line: #d7fb4a4d;
  --card-accent-glow: #d7fb4a24;
}

body.is-light .dashboard-card {
  border-color: var(--card-accent-line);
  background:
    linear-gradient(180deg, var(--card-accent-soft), transparent 48%),
    #f8faf5f2;
  box-shadow: 0 18px 44px #18210f14, inset 0 1px 0 #ffffffd8;
}

.dashboard-wide {
  min-width: 0;
}

.dashboard-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -2px -2px 12px;
  border-bottom: 1px solid var(--card-accent-line);
  padding: 0 2px 12px;
}

.dashboard-card h3,
.drawer h3 {
  font-size: 14px;
}

.dashboard-card h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
}

.dashboard-card h3::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--card-accent);
  box-shadow: 0 0 18px var(--card-accent-glow);
}

.dashboard-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 750;
}

.dashboard-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.income {
  background: var(--green);
}

.legend-dot.spend {
  background: var(--cyan);
}

.legend-dot.pnl {
  background: var(--amber);
}

.trend-scroll,
.dashboard-table-wrap {
  overflow: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.trend-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(46px, 1fr);
  gap: 8px;
  min-width: max-content;
  min-height: 230px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding: 6px 2px 10px;
}

.trend-point {
  display: grid;
  min-width: 46px;
  gap: 7px;
  align-items: end;
}

.trend-bars {
  display: grid;
  grid-template-columns: repeat(3, minmax(7px, 1fr));
  gap: 4px;
  height: 184px;
  align-items: end;
}

.trend-bar {
  display: block;
  height: var(--h);
  min-height: 2px;
  border-radius: 5px 5px 2px 2px;
}

.trend-bar.income {
  background: var(--green);
}

.trend-bar.spend {
  background: var(--cyan);
}

.trend-bar.pnl {
  background: var(--amber);
}

.trend-bar.pnl.negative {
  background: var(--red);
}

.trend-point > span {
  overflow: hidden;
  color: var(--soft);
  font-size: 10px;
  font-weight: 750;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

.dashboard-table-compact {
  min-width: 520px;
}

.dashboard-table th,
.dashboard-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: middle;
}

.dashboard-table th {
  color: var(--soft);
  font-size: 10px;
  font-weight: 850;
  line-height: 1.2;
  text-transform: uppercase;
}

.dashboard-table td {
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dashboard-table tr:last-child td {
  border-bottom: 0;
}

.dashboard-table tbody tr:hover,
.dashboard-issue:hover {
  background: #ffffff05;
}

.dashboard-name {
  width: 32%;
  min-width: 0;
  white-space: normal !important;
}

.dashboard-name strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.dashboard-name span {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--soft);
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-issues {
  display: grid;
  gap: 8px;
}

.dashboard-subsections {
  display: grid;
  gap: 14px;
}

.dashboard-subtitle {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  line-height: 1.2;
  text-transform: uppercase;
}

.dashboard-issue {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.dashboard-issue:last-child {
  border-bottom: 0;
}

.dashboard-issue strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-issue span {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--soft);
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-issue b {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mini-action {
  min-height: 30px;
  padding: 6px 8px;
  font-size: 10px;
  white-space: nowrap;
}

.bars {
  display: grid;
  grid-template-columns: repeat(8, minmax(18px, 1fr));
  align-items: end;
  gap: 8px;
  min-height: 190px;
  margin-top: 16px;
  border-bottom: 1px solid var(--line);
  padding: 0 2px 10px;
}

.bar {
  display: grid;
  align-items: end;
  gap: 6px;
  min-width: 0;
}

.bar-track {
  display: flex;
  align-items: end;
  height: 150px;
}

.bar-fill {
  width: 100%;
  min-height: 5px;
  border-radius: 6px 6px 2px 2px;
  background: var(--green);
}

.bar-fill.negative {
  background: var(--red);
}

.bar-name {
  overflow: hidden;
  color: var(--soft);
  font-size: 10px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health,
.campaigns,
.activity-list,
.alerts {
  display: grid;
  gap: 8px;
}

.health {
  margin-top: 14px;
}

.health-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.health-row:last-child {
  border-bottom: 0;
}

.health-row strong,
.campaign strong,
.activity strong,
.alert strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.health-row span,
.campaign span,
.activity span,
.alert p {
  display: block;
  margin-top: 4px;
  color: var(--soft);
  font-size: 12px;
  line-height: 1.4;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.good {
  border-color: #52d27355;
  background: #52d27316;
  color: var(--green);
}

.badge.bad {
  border-color: #ff6b6b55;
  background: #ff6b6b16;
  color: var(--red);
}

.badge.warn {
  border-color: #ffbf4d55;
  background: #ffbf4d16;
  color: var(--amber);
}

.badge.neutral {
  color: var(--muted);
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 0;
}

.table-toolbar.solo {
  justify-content: flex-end;
}

.bill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff08;
  color: var(--muted);
  padding: 8px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-transform: lowercase;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.bill-toggle:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.bill-toggle-dot {
  width: 18px;
  height: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: #ffffff0b;
  box-shadow: inset 0 0 0 3px var(--panel);
  flex: 0 0 auto;
}

.bill-toggle.active {
  border-color: #52d27375;
  background: #52d2731c;
  color: var(--text);
}

.bill-toggle.active .bill-toggle-dot {
  border-color: var(--green);
  background: var(--green);
}

body.is-light .bill-toggle {
  background: #ffffff9c;
}

.agent-settings {
  position: relative;
  min-width: min(100%, 220px);
}

.agent-settings summary {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff08;
  padding: 7px 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  list-style: none;
  cursor: pointer;
}

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

body.is-light .agent-settings summary {
  background: #ffffff9c;
}

.agent-settings[open] summary {
  border-color: var(--line-strong);
}

.agent-settings .agent-form {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 10px;
}

body.is-light .agent-settings .agent-form {
  background: #f8faf5;
}

.table-wrap {
  width: calc(100% - 28px);
  max-width: calc(100% - 28px);
  margin: 14px;
  overflow: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  box-shadow: none;
}

.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.table-wrap::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--line-strong);
  background-clip: padding-box;
}

.pnl-table {
  width: max(100%, var(--table-width));
  min-width: var(--table-width);
  max-width: none;
  border-collapse: collapse;
  table-layout: fixed;
}

.pnl-table th,
.pnl-table td {
  border-bottom: 1px solid var(--line);
  height: 50px;
  overflow: hidden;
  padding: 8px 9px;
  text-align: left;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.pnl-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--table-head);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;
  overflow-wrap: anywhere;
  white-space: normal;
}

body.is-light .pnl-table th {
  background: var(--table-head);
}

.pnl-table tr:hover td {
  background: var(--table-hover);
}

.pnl-table tbody tr {
  cursor: default;
}

body.is-light .pnl-table tr:hover td {
  background: var(--table-hover);
}

.pnl-table tr.selected td {
  background: var(--table-selected);
}

body.is-light .pnl-table tr.selected td {
  background: var(--table-selected);
}

.pnl-table .pnl-total-row td {
  border-top: 1px solid #d7fb4a66;
  border-bottom-color: #d7fb4a40;
  background: #d7fb4a0d;
  font-weight: 850;
}

.pnl-table .pnl-total-row:hover td {
  background: #d7fb4a14;
}

.pnl-table .pnl-total-row .cell-text {
  font-weight: 850;
}

body.is-light .pnl-table .pnl-total-row td {
  border-top-color: #6f8a1c73;
  border-bottom-color: #6f8a1c4d;
  background: #93af2d12;
}

body.is-light .pnl-table .pnl-total-row:hover td {
  background: #93af2d1c;
}

.pnl-table th:first-child,
.pnl-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--line);
}

.pnl-table th:first-child {
  z-index: 3;
  background: var(--table-head);
}

.pnl-table tr:hover td:first-child {
  background: var(--table-hover);
}

.pnl-table tr.selected td:first-child {
  background: var(--table-selected);
}

.pnl-table .pnl-total-row td:first-child,
.pnl-table .pnl-total-row:hover td:first-child {
  background: #182016;
  color: var(--accent);
}

body.is-light .pnl-table .pnl-total-row td:first-child,
body.is-light .pnl-table .pnl-total-row:hover td:first-child {
  background: #f0f5df;
}

.pnl-table input,
.pnl-table select {
  min-width: 0;
  max-width: 100%;
  min-height: 32px;
  border-color: transparent;
  background: #ffffff08;
  font-size: 12px;
  line-height: 1.25;
}

.pnl-table .cell-text {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.is-light .pnl-table input,
body.is-light .pnl-table select {
  background: #ffffffb8;
}

.pnl-table tr.locked input:disabled,
.pnl-table tr.locked select:disabled {
  background: transparent;
  color: var(--text);
  opacity: 0.92;
}

body.is-light .pnl-table tr.locked input:disabled,
body.is-light .pnl-table tr.locked select:disabled {
  background: transparent;
}

.pnl-table tr.draft td {
  background: #d7fb4a0d;
}

.pnl-table .project-input {
  min-width: 0;
}

.pnl-table .date-col {
  width: 174px;
}

.pnl-table .short-col {
  width: 56px;
}

.pnl-table .buyer-col {
  width: 78px;
}

.pnl-table .project-col {
  width: 260px;
}

.pnl-table .advertiser-col {
  width: 150px;
}

.pnl-table .agent-spend-col {
  width: 96px;
}

.pnl-table .agent-bill-col {
  width: 122px;
}

.pnl-table .number-col {
  width: 74px;
}

.pnl-table .revenue-k-col {
  width: 112px;
}

.pnl-table .revenue-plus-col {
  width: 104px;
}

.pnl-table .strong-col {
  width: 92px;
  font-weight: 850;
}

.pnl-table .bill-col {
  width: 104px;
}

.pnl-table .bill-input-col {
  width: 128px;
}

.pnl-table .bill-formula-col {
  width: 150px;
  background: #ffffff04;
  color: var(--muted);
}

.pnl-table .pnl-col {
  width: 108px;
}

.pnl-table .clicks-col,
.pnl-table .metric-col,
.pnl-table .roi-col {
  width: 92px;
}

.pnl-table .formula-col {
  width: 132px;
  background: #ffffff04;
  color: var(--muted);
}

.pnl-table .note-col {
  width: 320px;
}

.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
}

.drawer {
  display: grid;
  gap: 12px;
  margin: 0 14px 14px;
  padding: 14px;
  box-shadow: none;
}

.breakdown,
.settings-grid,
.mini-grid {
  display: grid;
  gap: 9px;
}

.breakdown {
  grid-template-columns: repeat(5, minmax(110px, 1fr));
}

.formula-pairs {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.formula-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(116px, auto);
  align-items: end;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff07;
  padding: 10px;
}

body.is-light .formula-pair {
  background: #ffffff9c;
}

.formula-result {
  display: grid;
  min-height: 38px;
  align-content: center;
  gap: 2px;
  border-left: 1px solid var(--line);
  padding-left: 10px;
}

.formula-result span,
.formula-result small {
  overflow: hidden;
  color: var(--soft);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formula-result b {
  font-size: 13px;
  white-space: nowrap;
}

.danger-action {
  color: var(--red);
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.campaigns,
.activity-list,
.settings {
  padding: 14px;
}

.campaign {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  box-shadow: none;
}

.campaign-money {
  min-width: 110px;
  text-align: right;
}

.settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px;
}

.telegram-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 14px;
  padding: 14px;
}

.telegram-main-card {
  align-content: start;
}

.telegram-queue-card {
  grid-column: 1 / -1;
}

.telegram-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.telegram-head p {
  display: none;
}

.switch-setting {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff08;
  padding: 9px 12px;
  color: var(--text);
}

body.is-light .switch-setting {
  background: #ffffff9c;
}

.switch-setting input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-setting span {
  position: relative;
  display: block;
  width: 46px;
  height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #ffffff0b;
  transition: background 160ms ease, border-color 160ms ease;
}

.switch-setting span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
  transition: transform 160ms ease, background 160ms ease;
}

.switch-setting input:checked + span {
  border-color: #52d27375;
  background: #52d27324;
}

.switch-setting input:checked + span::after {
  background: var(--green);
  transform: translateX(20px);
}

.switch-setting b {
  font-size: 13px;
}

.settings-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  box-shadow: none;
}

.settings-card h3 {
  font-size: 14px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rightbar {
  grid-column: 2;
  grid-row: 2;
  display: none;
  flex-direction: column;
  gap: 14px;
  top: 16px;
  max-height: calc(100vh - 32px);
  border-left: 1px solid var(--line);
  padding: 20px 14px;
}

.product-footer {
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
  border-top: 1px solid var(--line);
  background: #090a0dcf;
  color: var(--soft);
  padding: 22px max(var(--page-pad-x), env(safe-area-inset-right)) 22px max(var(--page-pad-x), env(safe-area-inset-left));
}

body.is-light .product-footer {
  background: #f7f9f2e8;
  box-shadow: 0 -1px 0 #ffffffb8;
}

.footer-contact,
.footer-links {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.footer-contact {
  font-size: 13px;
  font-weight: 700;
}

.footer-contact span {
  white-space: nowrap;
}

.footer-contact a,
.footer-links a {
  color: var(--soft);
  text-decoration: none;
  transition: color 150ms ease;
}

.footer-contact a:hover,
.footer-links a:hover {
  color: var(--text);
}

.footer-contact a:not(.footer-icon) {
  border-left: 1px solid var(--line-strong);
  padding-left: 14px;
}

.footer-icon {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: var(--radius);
}

.footer-links {
  justify-content: flex-end;
  font-size: 12px;
  font-weight: 750;
}

.side-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  box-shadow: none;
}

.side-head {
  align-items: flex-start;
}

.side-head h2 {
  margin-top: 4px;
}

.row-buttons {
  justify-content: stretch;
}

.row-buttons button {
  flex: 1;
}

.alert,
.activity {
  padding: 10px;
  box-shadow: none;
}

.alert.critical {
  border-color: #ff6b6b65;
}

body.is-light .alert.critical {
  background: #fff8f6;
}

.alert.warning {
  border-color: #ffbf4d65;
}

body.is-light .alert.warning {
  background: #fff9eb;
}

.mini-grid {
  grid-template-columns: 1fr 1fr;
}

.service-status {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff08;
  padding: 10px;
}

.service-status.ready {
  border-color: #52d27355;
  background: #52d27314;
}

body.is-light .service-status.ready {
  background: #eaf7ed;
}

.service-status.warn {
  border-color: #ffbf4d55;
  background: #ffbf4d12;
}

body.is-light .service-status.warn {
  background: #f5f2df;
}

.service-status b {
  font-size: 13px;
}

.service-status span {
  color: var(--soft);
  font-size: 12px;
  line-height: 1.35;
}

.server-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.server-fields div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff08;
  padding: 9px;
}

.server-fields span {
  display: block;
  color: var(--soft);
  font-size: 12px;
}

.server-fields b {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  color: var(--soft);
  opacity: 0.76;
}

.mini-grid div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff08;
  padding: 9px;
}

.mini-grid span {
  display: block;
  color: var(--soft);
  font-size: 12px;
}

.mini-grid b {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  display: grid;
  min-height: 160px;
  place-items: center;
  padding: 24px;
  color: var(--soft);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  transform: translateY(16px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #101216f2;
  box-shadow: var(--shadow);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  padding: 12px 14px;
  transition: opacity 160ms ease, transform 160ms ease;
}

body.is-light .toast {
  background: #f8faf5f2;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .rightbar {
    grid-column: 1;
    grid-row: 3;
    position: static;
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    height: auto;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

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

body .rightbar {
  display: none !important;
}

body[data-view="telegram"] .metrics,
body[data-view="telegram"] .dashboard-period-bar,
body[data-view="telegram"] .filters,
body[data-view="activity"] .metrics,
body[data-view="activity"] .dashboard-period-bar,
body[data-view="activity"] .filters,
body[data-view="dashboard"] .filters {
  display: none;
}

body[data-view="telegram"] #addRowBtn,
body[data-view="activity"] #addRowBtn {
  display: none;
}

@media (max-width: 1180px) {
  .topbar {
    flex-direction: row;
    justify-content: flex-end;
  }

  .top-actions {
    justify-content: flex-end;
  }

  .agent-form {
    grid-template-columns: 1fr;
  }

  .filters .automation {
    grid-column: auto;
  }

  .filter-grid input,
  .filter-grid select,
  .compact-action,
  .panel-actions .icon {
    min-height: 44px;
  }

  .filter-grid input,
  .filter-grid select {
    font-size: 16px;
  }
}

@media (max-width: 980px) {
  .app-shell,
  .layout,
  .dashboard-grid,
  .settings,
  .telegram-layout {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .filters .automation {
    grid-column: auto;
  }

  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-period-bar {
    max-width: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .search-label {
    grid-column: 1 / -1;
  }

  .sidebar,
  .rightbar {
    position: static;
    height: auto;
  }

  .sidebar {
    grid-template-columns: auto auto auto minmax(0, 1fr);
    align-items: stretch;
  }

  .theme-switch {
    justify-self: end;
  }

  .nav {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .nav button {
    min-width: 0;
  }

  .nav-name {
    max-width: none;
  }

  .sidebar-bottom {
    grid-column: 1 / -1;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    border-left: 0;
    padding-top: 12px;
    padding-left: 0;
  }

  .topbar {
    flex-direction: row;
    justify-content: flex-end;
  }

  .top-actions {
    justify-content: flex-end;
  }

  .rightbar {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .product-footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px max(14px, env(safe-area-inset-right)) 18px max(14px, env(safe-area-inset-left));
  }

  .footer-links {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding-top: 14px;
  }

  .sidebar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
  }

  .brand {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .sidebar .admin-toggle {
    justify-self: stretch;
    min-height: 44px;
  }

  .theme-switch {
    justify-self: end;
  }

  .admin-tools {
    grid-column: 1 / -1;
  }

  .admin-agent-settings summary {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  .admin-agent-settings .agent-form {
    position: static;
    width: 100%;
    margin-top: 10px;
  }

  .nav {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .nav button,
  .primary,
  .ghost,
  .icon,
  .compact-action {
    min-height: 44px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .metrics.metric-count-7 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics.metric-count-7 .metric {
    grid-column: auto;
  }

  .metric {
    min-height: 72px;
    padding: 12px;
  }

  .metric-value {
    font-size: 18px;
  }

  .metric-value.priority {
    font-size: 20px;
  }

  .filters {
    padding: 12px;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .dashboard-period-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
    padding: 12px;
  }

  .search-label,
  .filter-grid label:first-child,
  .dashboard-period-bar label:first-child {
    grid-column: 1 / -1;
  }

  .filter-grid input,
  .filter-grid select,
  .dashboard-period-bar input,
  .dashboard-period-bar select {
    min-height: 44px;
    font-size: 16px;
  }

  .work-panel {
    overflow: visible;
  }

  .dashboard-stack {
    gap: 10px;
    padding: 10px;
  }

  .dashboard-card {
    padding: 12px;
  }

  .dashboard-card-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .trend-chart {
    grid-auto-columns: minmax(42px, 52px);
    min-height: 196px;
  }

  .trend-bars {
    height: 150px;
  }

  .dashboard-issue {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .dashboard-issue strong,
  .dashboard-issue span {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .dashboard-table {
    display: block;
    min-width: 0;
  }

  .dashboard-table thead {
    display: none;
  }

  .dashboard-table tbody {
    display: grid;
    gap: 8px;
  }

  .dashboard-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }

  .dashboard-table td {
    display: grid;
    min-height: 50px;
    align-content: center;
    gap: 5px;
    border-bottom: 1px solid var(--line);
    padding: 8px 10px;
    white-space: normal;
  }

  .dashboard-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 9px;
    font-weight: 850;
    line-height: 1.15;
    text-transform: uppercase;
  }

  .dashboard-table .dashboard-name {
    grid-column: 1 / -1;
    width: auto;
  }

  .dashboard-name strong,
  .dashboard-name span {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .table-wrap {
    width: auto;
    max-width: none;
    margin: 10px;
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .pnl-table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .pnl-table thead {
    display: none;
  }

  .pnl-table tbody {
    display: grid;
    gap: 10px;
  }

  .pnl-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
  }

  body.is-light .pnl-table tr {
    background: var(--panel);
  }

  .pnl-table .pnl-total-row {
    border-color: #d7fb4a66;
  }

  body.is-light .pnl-table .pnl-total-row {
    border-color: #6f8a1c73;
  }

  .pnl-table th,
  .pnl-table td,
  .pnl-table th:first-child,
  .pnl-table td:first-child {
    position: static;
    display: grid;
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 58px;
    align-content: center;
    gap: 6px;
    overflow: visible;
    border-bottom: 1px solid var(--line);
    background: transparent;
    box-shadow: none;
    padding: 9px 10px;
    text-overflow: clip;
    white-space: normal;
  }

  .pnl-table td::before {
    content: attr(data-label);
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    font-weight: 850;
    line-height: 1.15;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: normal;
  }

  .pnl-table .project-col,
  .pnl-table .advertiser-col,
  .pnl-table .note-col {
    grid-column: 1 / -1;
  }

  .pnl-table input,
  .pnl-table select {
    min-height: 44px;
    padding: 10px;
    font-size: 16px;
  }

  .pnl-table .cell-text {
    min-height: 22px;
    overflow: visible;
    font-size: 15px;
    line-height: 1.35;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .pnl-table .number-col,
  .pnl-table .strong-col,
  .pnl-table .bill-col,
  .pnl-table .bill-input-col,
  .pnl-table .bill-formula-col,
  .pnl-table .pnl-col,
  .pnl-table .clicks-col,
  .pnl-table .metric-col,
  .pnl-table .roi-col,
  .pnl-table .date-col,
  .pnl-table .short-col,
  .pnl-table .buyer-col,
  .pnl-table .project-col,
  .pnl-table .advertiser-col,
  .pnl-table .agent-spend-col,
  .pnl-table .agent-bill-col,
  .pnl-table .note-col {
    width: auto;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 18px max(12px, env(safe-area-inset-right)) 26px max(12px, env(safe-area-inset-left));
  }

  .sidebar {
    gap: 12px;
    padding-top: 9px;
    padding-bottom: 9px;
  }

  .brand {
    min-width: 0;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
  }

  .brand strong {
    font-size: 18px;
  }

  h1 {
    font-size: 26px;
  }

  .breakdown,
  .agent-form,
  .settings-grid,
  .mini-grid,
  .server-fields {
    grid-template-columns: 1fr;
  }

  .segments,
  .top-actions,
  .row-buttons {
    width: 100%;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .primary,
  .ghost {
    width: 100%;
    min-width: 0;
    flex: 1 1 130px;
  }

  .theme-switch {
    width: 70px;
  }

  .theme-switch-track {
    width: 68px;
  }

  body.is-light .theme-switch-knob {
    transform: translateX(32px);
  }

  .panel-head-main {
    align-items: flex-start;
    padding: 14px;
  }

  .panel-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .table-toolbar {
    justify-content: flex-start;
    padding: 12px 10px 0;
  }

  .table-wrap {
    width: calc(100% - 20px);
    max-width: calc(100% - 20px);
    margin: 10px;
  }

  .dashboard-grid,
  .settings,
  .telegram-layout,
  .campaigns,
  .activity-list {
    padding: 10px;
  }

  .dashboard-stack .dashboard-grid {
    padding: 0;
  }

  .footer-contact,
  .footer-links {
    gap: 10px 12px;
  }

  .campaign {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .campaign-money {
    text-align: left;
  }
}

@media (max-width: 420px) {
  .top-actions,
  .footer-contact,
  .footer-links {
    grid-template-columns: 1fr;
  }

  .nav button {
    padding: 6px 8px;
  }

  .panel-head,
  .side-head {
    gap: 10px;
  }

  .primary,
  .ghost,
  .compact-action {
    white-space: normal;
  }
}

@media (max-width: 360px) {
  .metrics,
  .filter-grid,
  .pnl-table tr,
  .dashboard-table tr {
    grid-template-columns: 1fr;
  }
}
