:root {
  color-scheme: light;
  --bg: #eef1f4;
  --bg-soft: #f7f8fa;
  --ink: #1e2a32;
  --muted: #6b7780;
  --line: #dde3e8;
  --surface: #ffffff;
  --mint: #d9ebe3;
  --mint-deep: #c5dfd4;
  --green: #1a5c48;
  --green-hover: #154d3c;
  --green-soft: #e8f3ee;
  --danger: #9b2c2c;
  --danger-soft: #f8e8e8;
  --shadow: 0 10px 30px rgba(30, 42, 50, 0.06);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-pill: 999px;
  --font: "Manrope", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 8% -5%, rgba(180, 220, 190, 0.45) 0%, transparent 55%),
    radial-gradient(800px 480px at 95% 5%, rgba(190, 210, 230, 0.35) 0%, transparent 50%),
    linear-gradient(180deg, #eef6f0 0%, #e4ece7 45%, #dfe8e3 100%);
  -webkit-font-smoothing: antialiased;
}

.app {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 20px 16px 56px;
  animation: rise 0.45s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.brand-logo {
  display: block;
  height: 56px;
  width: auto;
  max-width: min(240px, 60vw);
  object-fit: cover;
  border-radius: 14px;
}

.brand-logo--compact {
  height: 48px;
  border-radius: 12px;
}

.photo-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 12px;
}

.photo-slot {
  width: 96px;
  border: 1px solid var(--line, #d5e0da);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  position: relative;
}

.photo-slot img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  display: block;
}

.photo-slot button {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line, #d5e0da);
  background: #f7faf8;
  padding: 4px;
  font-size: 12px;
  cursor: pointer;
}

h1, h2 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

h1 { font-size: clamp(28px, 4vw, 34px); line-height: 1.15; }
h2 { font-size: 20px; }

.lede {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.token-form {
  display: flex;
  gap: 10px;
  align-items: end;
  background: var(--surface);
  border-radius: 20px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.token-form[hidden] {
  display: none !important;
}

.token-form label {
  margin: 0;
  min-width: 220px;
}

.btn-primary,
button[type="submit"] {
  border: 0;
  background: var(--green);
  color: #fff;
  border-radius: var(--radius-pill);
  min-height: 44px;
  padding: 8px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(26, 92, 72, 0.18);
  transition: background 0.2s ease, transform 0.15s ease;
}

.btn-primary:hover,
button[type="submit"]:hover {
  background: var(--green-hover);
}

.btn-primary:active,
button[type="submit"]:active {
  transform: translateY(1px);
}

.status {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 14px;
  font-weight: 600;
}

.status:empty { display: none; }

.status.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-pill);
  min-height: 42px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.tabs button:hover { border-color: var(--mint-deep); }

.tabs button.selected {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.workspace {
  display: grid;
  gap: 16px;
  animation: rise 0.35s ease both;
}

.admin-shell[hidden] {
  display: none !important;
}

.panel,
.layout > form,
.layout > .list,
.scenario-card,
.stack-form {
  background: var(--surface);
  border-radius: 24px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: stretch;
}

.list {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: min(70vh, calc(100dvh - 220px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.layout > form {
  max-height: min(70vh, calc(100dvh - 220px));
  overflow-y: auto;
  overscroll-behavior: contain;
  align-content: start;
}

.list-search {
  width: 100%;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  background: var(--bg-soft);
}

.list-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 8px;
}

.list-filter {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #5a6b64);
}

.list-filter select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--bg-soft);
}

.list-filters-reset {
  margin: 0 0 8px;
  justify-self: start;
  font-size: 13px;
  padding: 6px 10px;
}

.list-filters-reset:disabled {
  opacity: 0.45;
  cursor: default;
}

.coverage-panel {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--green-soft);
  border: 1px solid var(--mint-deep);
}
.coverage-panel h3 {
  margin: 0 0 6px;
  font-size: 16px;
}
.coverage-table {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 220px;
  overflow: auto;
}
.coverage-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: baseline;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(26, 92, 72, 0.12);
}
.coverage-row:last-child { border-bottom: 0; }
.coverage-warn { color: var(--danger); }

.scroll-panel {
  max-height: min(70vh, calc(100dvh - 220px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.list button {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink);
  border-radius: 14px;
  min-height: 44px;
  height: auto;
  overflow: visible;
  padding: 12px 14px;
  font: inherit;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.list button:hover {
  border-color: var(--mint-deep);
  background: var(--green-soft);
}

.list button.add {
  background: var(--mint);
  border-color: transparent;
  color: var(--green);
}

.list button.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

form {
  display: grid;
  gap: 4px;
}

label {
  display: grid;
  gap: 6px;
  margin: 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

input, select, textarea {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  background: var(--surface);
}

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

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(26, 92, 72, 0.12);
}

.checks-block {
  margin: 10px 0;
}

.checks-block > p {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checks label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

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

.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 12px 0 4px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.btn-danger {
  border: 0;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-pill);
  min-height: 44px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn-ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-pill);
  min-height: 40px;
  padding: 6px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#picker,
.mask-picker {
  height: 240px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 10px 0;
  background: #d8e0e6;
}

#picker.picker--place {
  height: 360px;
}

.detail-editor-block {
  margin: 12px 0 18px;
  width: 100%;
  min-width: 0;
}

.detail-editor-title {
  margin: 0 0 4px;
  font-weight: 700;
}

.detail-editor-block .detail-editor,
.detail-editor-block .ql-toolbar.ql-snow,
.detail-editor-block .ql-container.ql-snow {
  width: 100%;
  box-sizing: border-box;
}

.detail-editor-block .ql-toolbar.ql-snow {
  border-radius: 12px 12px 0 0;
  border-color: #c9d5cf;
  background: #f4f7f5;
}

.detail-editor-block .ql-container.ql-snow {
  border-radius: 0 0 12px 12px;
  border-color: #c9d5cf;
  min-height: 220px;
  font-family: inherit;
  font-size: 15px;
}

.detail-editor-block .ql-editor {
  min-height: 200px;
}

.detail-editor-block textarea[name="detailHtml"] {
  width: 100%;
  min-height: 220px;
  box-sizing: border-box;
}

.mask-picker {
  height: 280px;
}

.pin-icon {
  background: transparent;
  border: 0;
}

.pin-icon span {
  display: block;
  width: 28px;
  height: 36px;
  filter: drop-shadow(0 4px 8px rgba(26, 92, 72, 0.35));
}

.leaflet-control-attribution {
  display: none !important;
}

.leaflet-control-zoom {
  border: 0 !important;
  box-shadow: 0 4px 14px rgba(30, 42, 50, 0.12) !important;
  border-radius: 12px !important;
  overflow: hidden;
}

.row-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--bg-soft);
  margin-bottom: 8px;
}

.row-card p {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
}

.places-bulk-import {
  display: grid;
  gap: 12px;
  align-content: start;
}

.places-bulk-import textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
  min-height: 280px;
}

.places-bulk-import .bulk-import-report ul {
  margin: 8px 0 0;
  padding-left: 1.2rem;
}

.places-bulk-import .hint code {
  font-size: 0.92em;
}

.scenario-card {
  display: grid;
  gap: 8px;
}

.scenario-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
}

.scenario-card .steps {
  color: var(--ink);
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--green-soft);
}

.stack {
  display: grid;
  gap: 16px;
}

.guide {
  display: grid;
  gap: 12px;
  max-width: 52rem;
}

.guide h2 {
  margin: 8px 0 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.guide h2:first-child {
  margin-top: 0;
}

.guide h3 {
  margin: 4px 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}

.guide p,
.guide li {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.55;
}

.guide ul,
.guide ol {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 6px;
}

.guide table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-weight: 500;
}

.guide th,
.guide td {
  text-align: left;
  vertical-align: top;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  line-height: 1.45;
}

.guide th {
  color: var(--muted);
  font-weight: 600;
  width: 32%;
}

.guide code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  font-weight: 600;
  padding: 0.1em 0.35em;
  border-radius: 6px;
  background: var(--bg-soft);
}

.guide-formula {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  line-height: 1.6;
}

.guide .coverage-panel {
  margin-top: 4px;
}

.guide .coverage-panel h3 {
  margin: 0 0 8px;
}

.guide .coverage-panel ol {
  gap: 8px;
}

@media (max-width: 800px) {
  .top { align-items: stretch; }
  .token-form { width: 100%; flex-wrap: wrap; }
  .token-form label { min-width: 0; flex: 1; }
  .layout { grid-template-columns: 1fr; }
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  display: grid;
  gap: 6px;
}

.metric-card strong {
  font-size: 22px;
  color: var(--green);
}

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

.metric-card.status-ok {
  border-color: color-mix(in srgb, var(--green) 35%, var(--line));
}

.metric-card.status-ok strong {
  color: var(--green);
}

.metric-card.status-down {
  border-color: color-mix(in srgb, #b42318 40%, var(--line));
}

.metric-card.status-down strong {
  color: #b42318;
}

.status-latency {
  font-size: 12px !important;
}

.status-resources {
  font-size: 12px !important;
  color: var(--ink, #1a2e24) !important;
}

.metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

.metrics-table th { color: var(--muted); font-weight: 600; }
