:root {
  --bg: #eef4fb;
  --surface: #fbfcfb;
  --surface-2: #edf5ff;
  --ink: #182638;
  --muted: #667386;
  --line: #cfdceb;
  --accent: #1769c2;
  --accent-2: #0b4f99;
  --warn: #a45b00;
  --bad: #9d2c2c;
  --good: #1769c2;
  --button-bg: #ffffff;
  --button-text: #182638;
  --button-active-bg: #182638;
  --button-active-text: #ffffff;
  --item-bg: #ffffff;
  --input-bg: #ffffff;
  --disabled-bg: #eef3f8;
  --notice-bg: #fff7e8;
  --notice-text: #533200;
  --notice-border: #e4c695;
  --topbar-bg: rgba(238, 244, 251, 0.88);
  --tab-bg: rgba(255, 255, 255, 0.58);
  --badge-text: #ffffff;
  --neutral-bg: #f2dfbd;
  --neutral-text: #4a3920;
  --shadow: 0 18px 50px rgba(24, 38, 56, 0.11);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0)),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--button-text);
  background: var(--button-bg);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent-2);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(16px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(128px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--tab-bg);
}

.tab {
  border: 0;
  color: var(--button-text);
  background: transparent;
  font-weight: 700;
}

.tab.is-active {
  color: var(--button-active-text);
  background: var(--button-active-bg);
}

main {
  padding: 26px clamp(16px, 4vw, 42px) 44px;
}

.view {
  display: none;
}

.is-hidden {
  display: none !important;
}

.view.is-active {
  display: block;
}

.loading-panel,
.login-panel {
  max-width: 520px;
  margin: 54px auto;
  padding: 24px;
}

.login-panel p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.login-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 18px;
}

.login-form input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--input-bg);
}

.form-error {
  min-height: 20px;
  color: var(--bad) !important;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 22px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input-panel {
  position: sticky;
  top: 118px;
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.input-panel .panel-head {
  padding: 0 0 16px;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.form-grid {
  display: grid;
  gap: 14px;
  padding-top: 16px;
}

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

.field input,
.field select,
.filters select,
.filters input,
td input,
td select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--input-bg);
}

.field input:focus,
.field select:focus,
.filters select:focus,
.filters input:focus,
td input:focus,
td select:focus {
  outline: 2px solid rgba(23, 105, 194, 0.22);
  border-color: var(--accent);
}

.field input:disabled,
.field select:disabled {
  color: #6b7482;
  background: var(--disabled-bg);
  cursor: not-allowed;
}

.result-stack {
  display: grid;
  gap: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

.metric {
  min-height: 118px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.35;
}

.notice {
  display: none;
  padding: 14px 16px;
  border: 1px solid var(--notice-border);
  border-radius: 8px;
  color: var(--notice-text);
  background: var(--notice-bg);
}

.notice.is-visible {
  display: block;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.counter {
  min-width: 38px;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--badge-text);
  background: var(--accent);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.cards {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow: auto;
  padding: 14px;
}

.promo-cards {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  max-height: none;
}

.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 78px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--item-bg);
}

.item h3 {
  margin: 0 0 5px;
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: 0;
}

.item p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.badge {
  align-self: start;
  min-width: 104px;
  padding: 6px 9px;
  border-radius: 999px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.badge.good {
  color: var(--badge-text);
  background: var(--good);
}

.badge.bad {
  color: var(--badge-text);
  background: var(--bad);
}

.badge.neutral {
  color: var(--neutral-text);
  background: var(--neutral-bg);
}

.admin-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 22px;
  align-items: start;
}

.admin-menu {
  position: sticky;
  top: 118px;
  display: grid;
  gap: 8px;
  padding: 18px;
}

.admin-tab {
  justify-content: flex-start;
  width: 100%;
  padding: 0 12px;
  text-align: left;
}

.admin-tab.is-active {
  color: var(--button-active-text);
  border-color: var(--ink);
  background: var(--button-active-bg);
}

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

.file-button {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  cursor: pointer;
}

.file-button input {
  display: none;
}

.danger {
  color: var(--badge-text);
  border-color: var(--bad);
  background: var(--bad);
}

.admin-content {
  min-width: 0;
}

.admin-title p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.save-status {
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--good);
  font-size: 13px;
  font-weight: 800;
}

.save-status.is-error {
  color: var(--bad);
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.table-wrap {
  max-height: 680px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--item-bg);
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  min-width: 130px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

td:last-child,
th:last-child {
  width: 64px;
  min-width: 64px;
}

.delete-row {
  width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--bad);
}

.empty {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.info-slot {
  display: grid;
  gap: 10px;
}

.info-slot:empty {
  display: none;
}

.input-panel .info-slot {
  margin-top: 14px;
}

.info-block {
  padding: 14px 16px;
  border: 1px solid var(--notice-border);
  border-radius: 8px;
  color: var(--notice-text);
  background: var(--notice-bg);
  line-height: 1.45;
  white-space: pre-wrap;
}

.color-cell,
.textarea-cell {
  min-width: 240px;
}

.color-edit {
  display: grid;
  grid-template-columns: 46px minmax(110px, 1fr);
  gap: 8px;
  align-items: center;
}

.color-edit input[type="color"] {
  min-height: 38px;
  padding: 3px;
}

td textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--input-bg);
  font: inherit;
}

@media (max-width: 1120px) {
  .layout,
  .admin-shell,
  .split {
    grid-template-columns: 1fr;
  }

  .input-panel,
  .admin-menu {
    position: static;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    width: 100%;
  }

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

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

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

  .promo-cards {
    grid-template-columns: 1fr;
  }

  .badge {
    justify-self: start;
  }
}
