:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #dbe3ee;
  --text: #152033;
  --muted: #64748b;
  --navy: #06284a;
  --blue: #0b5f9f;
  --green: #0aa43c;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

a {
  color: inherit;
}

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

.login-card {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.12);
}

.login-card .button {
  margin-top: 16px;
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #071d33;
  color: #ffffff;
}

.brand-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.brand-subtitle {
  margin: 6px 0 28px;
  color: #b7c7d8;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #dbeafe;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.sidebar-footer {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
}

.logout {
  display: block;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.panel {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.subtabs a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.subtabs a.active {
  border-color: var(--navy);
  background: var(--navy);
  color: #ffffff;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  outline: none;
}

textarea {
  min-height: 380px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

textarea.compact-textarea {
  min-height: 82px;
  font-family: inherit;
  font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(11, 95, 159, 0.12);
}

input[readonly],
textarea[readonly] {
  background: #f1f5f9;
  color: #475569;
  cursor: not-allowed;
}

.help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--navy);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.button.secondary {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
}

.button.danger {
  background: var(--danger);
}

.alert {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #f0fdf4;
  color: #166534;
  font-size: 14px;
  font-weight: 700;
}

.error {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 14px;
  font-weight: 700;
}

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

.zone-toolbar {
  margin-bottom: 12px;
}

.zone-toolbar input {
  width: min(520px, 100%);
}

.zone-row {
  display: grid;
  grid-template-columns: 16px minmax(180px, 1fr) minmax(140px, auto) auto;
  gap: 10px;
  align-items: center;
}

.zone-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.zone-row:hover {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.zone-summary-color {
  width: 16px;
  height: 48px;
  border-radius: 999px;
}

.zone-summary-main strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.zone-summary-main span,
.zone-summary-places {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.zone-summary-actions {
  display: flex;
  gap: 8px;
}

.zone-featured-store {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.56);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(820px, 100%);
  max-height: min(860px, calc(100vh - 36px));
  overflow: auto;
  padding: 22px;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
}

.modal-header,
.modal-actions,
.modal-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.modal-header {
  margin-bottom: 18px;
}

.modal-header h2,
.modal-section-header h3 {
  margin: 0;
  color: var(--text);
}

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

.modal-grid .full {
  grid-column: 1 / -1;
}

.modal-checkbox {
  align-self: end;
  min-height: 42px;
}

.modal-section {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.modal-featured-list {
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 20px;
}

.modal-remove-button {
  margin-right: auto;
}

.place-search-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.featured-place-configs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.featured-place-config {
  display: inline-grid;
  grid-template-columns: auto 54px;
  align-items: center;
  gap: 10px;
  justify-self: start;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.featured-place-config.numeric {
  grid-template-columns: auto 76px;
}

.featured-place-config label {
  color: var(--text);
}

.featured-place-config input {
  width: 42px;
  min-height: 34px;
  padding: 2px;
}

.featured-place-config.numeric input {
  width: 72px;
  padding: 6px 8px;
}

.place-search-control {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 130px;
  gap: 10px;
  align-items: start;
}

.admin-place-search-field {
  position: relative;
  min-width: 0;
}

.admin-place-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 12;
  display: none;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.18);
}

.admin-place-suggestion {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
}

.admin-place-suggestion:first-child {
  border-top: 0;
}

.admin-place-suggestion:hover {
  background: #eff6ff;
}

.place-search-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.place-search-status.error-text {
  color: var(--danger);
}

.featured-place-list {
  display: grid;
  gap: 8px;
}

.featured-place-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.highlight-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.highlight-toggle input {
  width: 18px;
  min-height: 18px;
}

.featured-zone-select {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.featured-zone-select select {
  min-height: 34px;
  min-width: 130px;
  padding: 6px 8px;
}

.featured-place-item strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
}

.featured-place-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.icon-button.danger {
  color: var(--danger);
}

.empty-list {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.checkbox-line input {
  width: 18px;
  min-height: 18px;
}

.copy-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

.preview-frame {
  width: 100%;
  min-height: 640px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

#generated-code {
  min-height: 120px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  display: grid;
  gap: 7px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  color: var(--navy);
  font-size: 36px;
  line-height: 1;
}

.metric-card small {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

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

.analytics-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 700;
}

.analytics-row.recent {
  grid-template-columns: 140px 150px minmax(0, 1fr) 170px;
}

.analytics-row-head {
  min-height: 36px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.analytics-row strong {
  color: var(--navy);
  text-align: right;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1120px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .sidebar-footer {
    position: static;
    margin-top: 18px;
  }

  .zone-row {
    grid-template-columns: 16px minmax(180px, 1fr) auto;
  }

  .zone-summary-places {
    grid-column: 2 / -1;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .panel-header,
  .copy-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions .button {
    width: 100%;
  }

  .grid,
  .analytics-grid,
  .zone-row,
  .modal-grid,
  .place-search-control {
    grid-template-columns: 1fr;
  }

  .analytics-row,
  .analytics-row.recent {
    grid-template-columns: 1fr;
  }

  .analytics-row strong {
    text-align: left;
  }

  .zone-summary-color {
    width: 100%;
    height: 8px;
  }

  .zone-summary-places {
    grid-column: auto;
  }

  .zone-summary-actions,
  .modal-actions {
    flex-direction: column;
  }
}
