:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --surface-strong: #eef2f6;
  --line: #d9dee7;
  --line-strong: #bfc8d4;
  --text: #141820;
  --muted: #657080;
  --accent: #2f9fba;
  --accent-soft: #e7f7fb;
  --accent-strong: #17212b;
  --good: #16764f;
  --good-soft: #e8f6ef;
  --warn: #a05a00;
  --warn-soft: #fff4df;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --shadow: 0 18px 44px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #fbfcfd 0, var(--bg) 360px);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 22px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(47, 159, 186, 0.34);
  border-radius: 8px;
  background: var(--accent-soft);
  color: #0d5968;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(47, 159, 186, 0.16);
}

.brand strong {
  display: block;
  font-size: 17px;
}

.brand span,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.nav-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 800;
}

.nav-button[aria-current="page"] {
  border-color: rgba(47, 159, 186, 0.28);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.07);
}

.nav-button:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.nav-count {
  color: var(--muted);
  font-size: 12px;
}

.main {
  min-width: 0;
  padding: 30px clamp(22px, 4vw, 54px) 56px;
}

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

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.02;
}

h2 {
  font-size: 24px;
  line-height: 1.15;
}

h3 {
  font-size: 16px;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.session {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-pill.is-ok {
  background: var(--good-soft);
  border-color: rgba(22, 118, 79, 0.28);
  color: var(--good);
}

.status-pill.is-blocked {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.25);
  color: var(--danger);
}

.notice {
  min-height: 42px;
  margin: 0 0 18px;
}

.notice:not(:empty) {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.notice[data-type="error"]:not(:empty) {
  border-color: rgba(180, 35, 24, 0.25);
  color: var(--danger);
}

.login-panel,
.panel,
.publish-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(280px, 1.1fr);
  gap: 26px;
  padding: 28px;
}

.login-copy {
  display: grid;
  align-content: start;
  gap: 10px;
}

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

.resource-layout {
  display: grid;
  grid-template-columns: minmax(300px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.form-panel,
.table-panel,
.dashboard-panel,
.publish-panel {
  padding: 20px;
}

.form-panel {
  overflow: visible;
}

.form-header,
.table-header,
.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.form-actions,
.table-actions,
.publish-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.field {
  min-width: 0;
}

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

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--accent);
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(47, 159, 186, 0.16);
}

.field-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.checkbox-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
}

.checkbox-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 48px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 750;
}

.checkbox-option span {
  display: grid;
  gap: 2px;
}

.checkbox-option small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.policy-note {
  display: grid;
  gap: 4px;
  margin: -2px 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.policy-note strong {
  color: var(--text);
}

.locked-field {
  background: #f6f8fb;
  color: var(--muted);
}

.content-field {
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.content-field-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.slot-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.content-list-field textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

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

.content-slot-row {
  display: grid;
  grid-template-columns: 82px 62px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.content-slot-row.is-empty {
  background: #fff;
  border-style: dashed;
}

.slot-number {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.slot-preview {
  width: 62px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  object-fit: cover;
  background: #fff;
}

.slot-preview-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.slot-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.slot-meta strong {
  font-size: 12px;
}

.slot-meta span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-upload {
  display: grid;
  gap: 7px;
  margin-top: 2px;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.media-upload span,
.upload-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.media-upload input[type="file"] {
  min-height: 40px;
  padding: 8px;
  border-style: solid;
  background: #fff;
}

.upload-status {
  min-height: 17px;
  line-height: 1.35;
}

.error-text {
  color: var(--danger);
  font-weight: 750;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 900;
  border: 1px solid transparent;
}

.primary-button {
  background: var(--accent-strong);
  color: #fff;
  box-shadow: 0 10px 22px rgba(20, 24, 32, 0.12);
}

.secondary-button {
  background: #fff;
  color: var(--text);
  border-color: var(--line-strong);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  border-color: var(--line);
}

.danger-button {
  background: #fff;
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.3);
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 92px;
  align-content: space-between;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.05);
}

.metric strong {
  font-size: 28px;
  line-height: 1;
}

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

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

.dashboard-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.version-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(21, 127, 79, 0.24);
  border-radius: 8px;
  background: var(--good-soft);
  color: var(--good);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.4;
}

.version-banner.is-warning {
  border-color: rgba(180, 83, 9, 0.28);
  background: #fff7ed;
  color: #9a3412;
}

.analytics-panel {
  display: grid;
  gap: 18px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
}

.analytics-card {
  display: grid;
  gap: 8px;
  min-height: 126px;
  align-content: space-between;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.05);
}

.analytics-card strong {
  font-size: 34px;
  line-height: 1;
}

.analytics-card span {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.analytics-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.analytics-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.8fr);
  gap: 16px;
  align-items: start;
}

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

.event-breakdown {
  display: grid;
  gap: 10px;
}

.event-row {
  display: grid;
  grid-template-columns: 34px minmax(160px, 1fr) minmax(110px, 0.65fr) minmax(48px, auto);
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.event-rank {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.event-copy {
  min-width: 0;
}

.event-copy strong,
.event-copy span {
  display: block;
}

.event-copy strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.event-meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f5;
}

.event-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-strong);
}

.event-value {
  text-align: right;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.dashboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.dashboard-row:first-child {
  border-top: 0;
}

.legacy-diagnostics {
  display: grid;
  gap: 12px;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.legacy-diagnostics h3 {
  margin: 0;
  font-size: 22px;
}

.cleanup-panel {
  display: grid;
  gap: 14px;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.cleanup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

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

.cleanup-card {
  display: grid;
  min-height: 190px;
  align-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.cleanup-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.cleanup-card p {
  font-size: 12px;
}

.cleanup-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.cleanup-target {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.panel:not(.form-panel) {
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

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

tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover {
  background: #fbfcfd;
}

.row-title {
  color: var(--text);
  font-weight: 900;
}

.row-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

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

.mini-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.mini-button.danger {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.20);
  color: var(--danger);
}

.empty {
  padding: 34px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
}

.empty h2 {
  margin-bottom: 6px;
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

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

  .nav {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .resource-layout,
  .login-panel,
  .dashboard-grid,
  .cleanup-grid {
    grid-template-columns: 1fr;
  }

  .form-panel {
    position: static;
  }
}

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

  .topbar {
    display: grid;
  }

  .session {
    justify-content: flex-start;
  }

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

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

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

  .event-row {
    grid-template-columns: 30px 1fr minmax(44px, auto);
    gap: 10px;
  }

  .event-meter {
    grid-column: 2 / -1;
  }

  .login-panel,
  .form-panel,
  .table-panel,
  .dashboard-panel,
  .publish-panel {
    padding: 16px;
  }
}
