:root {
  --bg: #f4f6f4;
  --panel: #ffffff;
  --ink: #16212a;
  --muted: #64717d;
  --line: #dfe5e2;
  --blue: #254b5a;
  --orange: #ee7623;
  --red: #7a1830;
  --green: #0f9f6e;
  --shadow: 0 12px 28px rgba(22, 33, 42, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

select,
input {
  min-height: 42px;
}

textarea {
  resize: vertical;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.shell {
  min-height: 100vh;
  display: block;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 260px;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--blue);
  color: #fff;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 28px;
  padding: 10px 11px 16px;
  border-bottom: 1px solid rgba(255,255,255,.14);
}

.brand-logo {
  display: block;
  width: 142px;
  max-width: 100%;
}

.brand-logo img {
  display: block;
  width: 100%;
  height: auto;
}

.brand strong {
  display: block;
  color: #fff;
  font-size: 13px;
  font-weight: 640;
  line-height: 1.25;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: rgba(255,255,255,.68);
}

.sidebar nav {
  display: grid;
  gap: 18px;
  flex: 1;
  align-content: start;
}

.nav-section {
  display: grid;
  gap: 6px;
}

.nav-section p {
  margin: 0 0 2px;
  padding: 0 12px;
  color: rgba(255,255,255,.38);
  font-size: 10px;
  font-weight: 620;
  letter-spacing: .08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.nav-link {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.70);
  font-size: 13px;
  font-weight: 520;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: inline-grid;
  place-items: center;
  color: rgba(255,255,255,.54);
}

.nav-icon svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
  display: block;
}

.nav-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-badge {
  min-width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  background: var(--orange);
  box-shadow: 0 8px 18px rgba(238,118,35,.25);
  font-size: 10px;
  font-weight: 720;
  line-height: 1;
}

.nav-badge.is-hidden {
  display: none;
}

.nav-link.active,
.nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.10);
}

.nav-link.active .nav-icon,
.nav-link:hover .nav-icon {
  color: var(--orange);
}

.sidebar-logout {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  color: rgba(255,255,255,.78);
  font-size: 13px;
  font-weight: 560;
}

.sidebar-logout:hover {
  background: rgba(122,24,48,.24);
  border-color: rgba(255,255,255,.22);
  color: #fff;
}

.sidebar-logout:hover .nav-icon {
  color: #fff;
}

.main {
  margin-left: 260px;
  padding: 28px;
  min-width: 0;
}

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

.topbar h1,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 23px;
  line-height: 1.18;
  font-weight: 720;
}

.panel h2 {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 720;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--orange);
  font-weight: 720;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.userbox {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}

.userbox a {
  color: var(--red);
  font-weight: 680;
}

.notice {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.notice.success {
  background: #e8f8f1;
  border-color: #bfe9d8;
  color: #086646;
}

.notice.danger {
  background: #fff0f2;
  border-color: #f3c7cf;
  color: #83172d;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

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

.stat-card {
  padding: 20px;
  display: grid;
  gap: 10px;
}

.stat-card span {
  color: var(--muted);
}

.stat-card strong {
  font-size: 30px;
  color: var(--blue);
}

.panel {
  padding: 20px;
  margin-bottom: 16px;
  overflow: hidden;
}

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

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.btn,
button.btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 680;
  line-height: 1.15;
  white-space: nowrap;
}

.btn.primary {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
  box-shadow: 0 8px 18px rgba(238, 118, 35, .16);
}

.btn.danger,
.icon-danger {
  background: #fff0f2;
  color: var(--red);
  border-color: #f3c7cf;
}

.full {
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
}

.table-link {
  color: var(--blue);
  font-weight: 680;
}

.empty-table {
  color: var(--muted);
  text-align: center;
}

.member-search {
  width: min(320px, 100%);
}

.table-note {
  margin: 14px 0 0;
}

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

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

.wide,
.form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.inline-form {
  min-width: 220px;
}

.sync-form {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.sync-form .muted {
  margin: 0;
  font-size: 13px;
}

.content-list {
  display: grid;
  gap: 10px;
}

.content-row {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 64px;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.content-meta {
  display: grid;
  gap: 6px;
  align-content: start;
}

.content-meta strong {
  font-size: 14px;
}

.content-meta small {
  color: var(--muted);
  line-height: 1.4;
}

.content-meta code {
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid #e7ece9;
  border-radius: 6px;
  padding: 4px 6px;
  background: #f7faf8;
  color: #52636d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  white-space: nowrap;
}

.content-row textarea {
  min-height: 76px;
}

.icon-danger {
  align-self: start;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 680;
  font-size: 12px;
}

.image-editor {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

.image-preview {
  width: 180px;
  height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf2ef;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview span {
  color: var(--muted);
  font-size: 12px;
}

.image-fields {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.image-fields label {
  font-size: 12px;
}

.image-fields input[type="file"] {
  padding: 8px;
  background: #f8faf9;
}

.upload-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.upload-box .muted {
  grid-column: 1 / -1;
  margin: 0;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.media-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.media-preview {
  height: 140px;
  border-radius: 8px;
  background: #edf2ef;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.media-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-card small {
  color: var(--muted);
}

.visual-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.visual-toolbar form {
  margin: 0;
}

.visual-page-select {
  min-width: 260px;
}

.visual-page-select select {
  font-weight: 650;
  color: #13212a;
}

.visual-hint {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.visual-toolbar-save {
  min-width: 92px;
}

.visual-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 16px;
  align-items: start;
}

.site-preview,
.visual-editor-panel,
.visual-add-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.visual-side {
  display: grid;
  gap: 14px;
  align-content: start;
}

.preview-head {
  height: 42px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.preview-head span {
  color: var(--muted);
  font-size: 11px;
}

.site-preview iframe {
  width: 100%;
  height: calc(100vh - 190px);
  min-height: 640px;
  border: 0;
  display: block;
  background: #fff;
}

.visual-editor-panel {
  max-height: calc(100vh - 142px);
  overflow: auto;
}

.visual-add-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
}

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

.visual-add-panel h2 {
  margin: -4px 0 2px;
  font-size: 16px;
}

.visual-add-close {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.sticky-save {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
}

.sticky-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sticky-save h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 720;
}

.preview-status {
  display: none;
  width: fit-content;
  margin-top: 6px;
  border: 1px solid #f4bf94;
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff7ef;
  color: #9c4a11;
  font-size: 10px;
  font-weight: 700;
}

.visual-editor-panel.has-unsaved-preview .preview-status {
  display: inline-flex;
}

.visual-section {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.visual-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -2px 0 0;
  cursor: pointer;
  list-style: none;
}

.visual-section summary::-webkit-details-marker {
  display: none;
}

.visual-section summary span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.visual-section summary strong {
  font-size: 13px;
  color: var(--blue);
  font-weight: 720;
}

.visual-section summary small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.visual-section summary em {
  flex: 0 0 auto;
  border: 1px solid #e7ece9;
  border-radius: 999px;
  padding: 4px 8px;
  background: #f7faf8;
  color: #52636d;
  font-size: 10px;
  font-style: normal;
  font-weight: 680;
}

.visual-section[open] summary {
  margin-bottom: 12px;
}

.visual-fields {
  display: grid;
  gap: 12px;
}

.visual-field {
  display: grid;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px;
  margin: -8px;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.visual-field.is-active {
  border-color: rgba(238, 118, 35, .55);
  background: #fff8f2;
  box-shadow: 0 0 0 3px rgba(238, 118, 35, .10);
}

.visual-field.is-hidden-block {
  opacity: .68;
}

.field-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.field-label strong {
  font-size: 12px;
  font-weight: 720;
}

.field-label code {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid #e7ece9;
  border-radius: 6px;
  padding: 3px 6px;
  color: #52636d;
  background: #f7faf8;
  font-size: 10px;
  white-space: nowrap;
}

.visual-image-edit {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 10px;
  align-items: start;
}

.visual-thumb {
  width: 128px;
  height: 88px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf2ef;
}

.visual-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.visual-thumb span {
  padding: 8px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.visual-image-controls {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.visual-image-controls input[type="file"] {
  padding: 7px;
  background: #f8faf9;
  font-size: 12px;
}

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

.visual-style-grid label,
.visual-image-controls label {
  gap: 5px;
  font-size: 11px;
}

.visual-field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 3px;
}

.toggle-row {
  width: auto;
  min-height: 38px;
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.toggle-row input {
  width: auto;
  min-height: 0;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
}

.install-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #254b5a 0%, #7a1830 100%);
}

.install-card {
  width: min(720px, 100%);
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.22);
}

.install-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.install-head h1 {
  margin: 0;
}

.visual-menu-toggle {
  display: none;
}

body.visual-mode {
  overflow: hidden;
}

.visual-mode .shell {
  grid-template-columns: 1fr;
  min-height: 100vh;
}

.visual-mode .sidebar {
  display: none;
}

.visual-mode.visual-sidebar-open .sidebar {
  display: block;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 70;
  width: 260px;
  box-shadow: 18px 0 42px rgba(22, 33, 42, .22);
}

.visual-mode .main {
  margin-left: 0;
  height: 100vh;
  padding: 14px 16px 12px;
  overflow: hidden;
}

.visual-mode .topbar {
  align-items: center;
  margin-bottom: 8px;
  position: relative;
  z-index: 40;
}

.visual-mode .visual-menu-toggle {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  background: #fff;
  color: var(--blue);
  cursor: pointer;
  font-size: 12px;
  font-weight: 680;
  line-height: 1;
}

.visual-mode.visual-sidebar-open .visual-menu-toggle {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.visual-mode .topbar h1 {
  font-size: 22px;
  font-weight: 720;
}

.visual-mode .visual-toolbar {
  align-items: flex-end;
  margin-bottom: 10px;
}

.visual-mode .visual-toolbar .btn {
  min-height: 40px;
  padding-inline: 14px;
}

.visual-mode .visual-toolbar-save {
  min-width: 92px;
}

.visual-mode .visual-hint {
  max-width: 720px;
  font-size: 12px;
  color: #687887;
}

.visual-mode .visual-workspace {
  grid-template-columns: minmax(0, 1fr);
  height: calc(100vh - 132px);
  gap: 0;
}

.visual-mode .site-preview {
  height: 100%;
}

.visual-mode .site-preview iframe {
  height: calc(100% - 42px);
  min-height: 0;
}

.visual-mode .visual-editor-panel {
  position: fixed;
  top: 86px;
  right: 16px;
  z-index: 30;
  width: min(420px, calc(100vw - 32px));
  max-height: none;
  height: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 24px));
  transition: transform .22s ease, opacity .22s ease;
}

.visual-mode .visual-side {
  display: contents;
}

.visual-mode .visual-editor-panel.is-open {
  max-height: calc(100vh - 102px);
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.visual-mode .visual-add-panel {
  position: fixed;
  right: 16px;
  bottom: 14px;
  z-index: 25;
  width: min(420px, calc(100vw - 32px));
  max-height: 42vh;
  overflow: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px);
  transition: transform .2s ease, opacity .2s ease;
}

.visual-mode .visual-add-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.visual-mode .visual-editor-panel .visual-section,
.visual-mode .visual-editor-panel .empty-state {
  display: none;
}

.visual-mode .visual-editor-panel .visual-section.has-active-field {
  display: block;
  border-bottom: 0;
}

.visual-mode .visual-editor-panel .visual-section.has-active-field summary {
  display: none;
}

.visual-mode .visual-editor-panel .visual-field {
  display: none;
  margin: 0;
  padding: 0;
  border-color: transparent;
  box-shadow: none;
}

.visual-mode .visual-editor-panel .visual-field.is-active {
  display: grid;
  background: transparent;
}

.visual-mode .notice {
  margin-bottom: 10px;
}

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

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
  }

  .sidebar nav {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  }

  .main {
    margin-left: 0;
    padding: 18px;
  }

  .stats-grid,
  .form-grid.two,
  .content-row,
  .upload-box,
  .image-editor {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-head,
  .visual-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .visual-workspace {
    grid-template-columns: 1fr;
  }

  .visual-editor-panel {
    max-height: none;
  }

  .visual-style-grid,
  .visual-image-edit {
    grid-template-columns: 1fr;
  }

  .site-preview iframe {
    height: 540px;
    min-height: 540px;
  }
}
