:root {
  --ink: #172033;
  --muted: #667085;
  --line: #e5e8ef;
  --canvas: #f5f7fa;
  --surface: #ffffff;
  --primary: #2457c5;
  --primary-dark: #17429f;
  --danger: #b42318;
  --success: #087a55;
  --warning: #b54708;
  --radius: 16px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button, select { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h2 { font-size: 21px; }
h3 { font-size: 18px; }
code {
  padding: 2px 6px;
  color: #475467;
  background: #f0f2f5;
  border-radius: 5px;
  font-size: 12px;
}

.login-screen {
  min-height: 100vh;
  padding: 32px 18px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(36, 87, 197, .13), transparent 32%),
    radial-gradient(circle at 85% 80%, rgba(23, 32, 51, .1), transparent 34%),
    var(--canvas);
}
.login-card {
  width: min(430px, 100%);
  padding: 38px;
  background: rgba(255, 255, 255, .98);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(16, 24, 40, .13);
}
.login-brand {
  width: 50px;
  height: 50px;
  margin-bottom: 24px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--ink);
  border-radius: 14px;
  font-size: 18px;
  font-weight: 800;
}
.login-card h1 { margin: 7px 0 10px; font-size: 30px; letter-spacing: -.035em; }
.login-description { margin-bottom: 26px; color: var(--muted); line-height: 1.55; }
.login-form { display: grid; gap: 16px; }
.login-form .button-block { margin: 4px 0 0; }
.login-error {
  margin: 0;
  padding: 11px 13px;
  color: var(--danger);
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 9px;
  font-size: 13px;
  line-height: 1.45;
}
.login-session-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.visually-hidden, .select-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 72px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: var(--ink);
  border-radius: 12px;
  font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 14px; }
.connection { color: var(--muted); font-size: 13px; }
.connection::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 7px;
  display: inline-block;
  background: #f79009;
  border-radius: 50%;
}
.connection-ready::before { background: #12b76a; }
.connection-error::before { background: #f04438; }

.layout {
  width: min(1440px, 100%);
  min-height: calc(100vh - 72px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 72px;
  align-self: start;
  height: calc(100vh - 72px);
  padding: 28px 20px;
  overflow: auto;
  border-right: 1px solid var(--line);
}
.workspace { min-width: 0; padding: 44px 46px 100px; display: grid; gap: 22px; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary) !important;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
}
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-description { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.title-with-count { display: flex; align-items: center; gap: 9px; }
.count-badge {
  min-width: 24px;
  min-height: 24px;
  padding: 3px 7px;
  display: inline-grid;
  place-items: center;
  color: #475467;
  background: #f2f4f7;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: background .15s, border .15s, transform .15s;
}
.button { min-height: 42px; padding: 0 16px; }
.button:hover, .icon-button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.button-primary { color: white; background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { color: var(--primary-dark); background: #eef3ff; border-color: #cddafe; }
.button-quiet, .button-ghost { color: var(--ink); background: transparent; border-color: var(--line); }
.button-quiet:hover, .button-ghost:hover { background: #f8fafc; }
.button-danger { color: var(--danger); background: white; border-color: #fecdca; }
.button-danger:hover { background: #fef3f2; }
.button-block { width: 100%; margin: 20px 0 14px; }
.icon-button { width: 38px; height: 38px; background: white; border-color: var(--line); font-size: 20px; }
.icon-button:hover { color: var(--primary); background: #eef3ff; }

button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(36, 87, 197, .16);
  outline-offset: 2px;
}

label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 700; }
label small, .hint { color: var(--muted); font-size: 11px; font-weight: 500; }
input, select, textarea {
  width: 100%;
  color: var(--ink);
  background: white;
  border: 1px solid #d0d5dd;
  border-radius: 9px;
  outline: none;
}
input, select { min-height: 42px; padding: 9px 11px; }
textarea {
  min-height: 320px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  tab-size: 2;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 87, 197, .12);
}
input:disabled, select:disabled, textarea:disabled {
  cursor: not-allowed;
  color: #7a8494;
  background: #f2f4f7;
}
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); }

.search-label { position: relative; margin-bottom: 13px; }
.search-label input { padding-left: 39px; }
.search-icon {
  position: absolute;
  top: 13px;
  left: 14px;
  z-index: 1;
  width: 13px;
  height: 13px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
}
.search-icon::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -2px;
  width: 6px;
  height: 2px;
  background: var(--muted);
  border-radius: 2px;
  transform: rotate(45deg);
}
.brand-list { display: grid; gap: 4px; }
.brand-item {
  width: 100%;
  min-height: 58px;
  padding: 9px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 8px;
  align-items: center;
  gap: 10px;
  color: #475467;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  text-align: left;
}
.brand-item:hover { color: var(--primary); background: #edf2ff; }
.brand-item.active { color: var(--primary); background: #edf2ff; border-color: #d8e1fb; }
.brand-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: #eef3ff;
  border: 1px solid #dce5fc;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}
.brand-item-copy { min-width: 0; }
.brand-item-copy strong, .brand-item-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-item-copy small { margin-top: 3px; color: var(--muted); }
.brand-state { width: 7px; height: 7px; background: #d0d5dd; border-radius: 50%; }
.brand-state.active { background: #12b76a; }
.search-empty { margin: 18px 8px; color: var(--muted); font-size: 13px; text-align: center; }

.overview-grid { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 14px; }
.metric-card {
  min-width: 0;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 12px rgba(16, 24, 40, .03);
}
.metric-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--primary);
  background: #eef3ff;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 800;
}
.metric-card-primary .metric-icon { color: white; background: var(--primary); }
.metric-card div { min-width: 0; display: grid; gap: 3px; }
.metric-label { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.metric-card strong { overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }

.card {
  padding: 28px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.brand-form {
  margin-top: 24px;
  padding-top: 20px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  align-items: end;
  gap: 16px;
  border-top: 1px solid var(--line);
}
.check-row { min-height: 42px; display: flex; align-items: center; gap: 9px; }
.code-line { margin: 5px 0 0; color: var(--muted); font-family: monospace; }
.muted { color: var(--muted); }

.heading-actions, .action-row, .revision-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.heading-actions select { width: auto; min-width: 185px; }
.revision-meta {
  margin: 20px 0;
  padding: 10px 12px;
  justify-content: space-between;
  background: #f8fafc;
  border-radius: 10px;
}
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.action-row { margin-top: 18px; justify-content: flex-end; }

.status {
  width: fit-content;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: #475467;
  background: #f2f4f7;
  font-size: 11px;
  font-weight: 800;
}
.status-ready, .status-published, .status-active { color: #067647; background: #ecfdf3; }
.status-draft, .status-waiting, .status-pending { color: var(--warning); background: #fffaeb; }
.status-rejected, .status-archived, .status-inactive { color: var(--danger); background: #fef3f2; }

.inline-empty { margin-top: 18px; padding: 28px; color: var(--muted); background: #f8fafc; border-radius: 10px; text-align: center; }
.validation { margin-top: 16px; padding: 14px 16px; color: #067647; background: #ecfdf3; border: 1px solid #abefc6; border-radius: 12px; }
.validation.error { color: var(--danger); background: #fef3f2; border-color: #fecdca; }
.validation ul { margin: 8px 0 0; padding-left: 20px; }

.local-apply-section {
  margin-top: 22px;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 13px;
}
.local-apply-section h3 { margin: 0; }
.local-apply-actions { display: flex; gap: 10px; }
.local-apply-result {
  grid-column: 1 / -1;
  padding: 14px 16px;
  color: #067647;
  background: #ecfdf3;
  border: 1px solid #abefc6;
  border-radius: 10px;
  font-size: 13px;
}
.local-apply-result.error { color: var(--danger); background: #fef3f2; border-color: #fecdca; }
.local-apply-result p { margin: 6px 0 0; }
.local-apply-result ul { max-height: 190px; margin: 10px 0 0; padding-left: 20px; overflow: auto; }
.local-apply-result pre { margin: 10px 0 0; overflow: auto; color: #344054; white-space: pre-wrap; }

.assets-section { margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--line); }
.upload-form {
  margin-top: 18px;
  padding: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr minmax(220px, 1.4fr) auto;
  align-items: end;
  gap: 12px;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 13px;
}
.file-label input { padding: 7px; font-size: 12px; }
.selected-file {
  margin-top: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.selected-file img { width: 58px; height: 44px; object-fit: contain; background: #f7f8fa; border-radius: 7px; }
.selected-file div { min-width: 0; display: grid; gap: 4px; }
.selected-file strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.selected-file span { font-size: 12px; }
.hint { margin: 10px 0 0; }

.asset-list { margin-top: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.asset-card {
  min-width: 0;
  overflow: hidden;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 12px rgba(16, 24, 40, .03);
  transition: border .15s, box-shadow .15s, transform .15s;
}
.asset-card:hover { border-color: #bdc9e9; box-shadow: 0 10px 28px rgba(16, 24, 40, .07); transform: translateY(-1px); }
.asset-preview {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #f7f8fa;
  border-bottom: 1px solid var(--line);
}
.asset-preview img { width: 100%; height: 100%; padding: 12px; object-fit: contain; }
.asset-placeholder { color: var(--muted); font-size: 12px; font-weight: 700; }
.asset-placeholder-error { color: var(--danger); }
.asset-details { padding: 15px; display: grid; gap: 11px; }
.asset-heading, .asset-footer, .asset-metadata { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.asset-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.environment-chip { padding: 3px 6px; color: #344eb2; background: #eef3ff; border-radius: 5px; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.asset-metadata { justify-content: flex-start; color: var(--muted); font-size: 12px; }
.asset-metadata span + span::before { content: "·"; margin-right: 10px; color: #d0d5dd; }
.asset-footer code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-footer .status { flex: 0 0 auto; }
.asset-empty {
  grid-column: 1 / -1;
  min-height: 112px;
  padding: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  background: #fafbfc;
  border: 1px dashed #d0d5dd;
  border-radius: 12px;
}
.asset-empty > span { color: #98a2b3; font-size: 28px; }
.asset-empty strong { color: #344054; }
.asset-empty p { margin: 5px 0 0; font-size: 12px; }

.empty-state {
  min-height: 480px;
  margin: 44px 46px;
  padding: 50px 30px;
  display: grid;
  align-content: center;
  justify-items: center;
  color: var(--muted);
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}
.empty-state h2 { margin: 4px 0 0; color: var(--ink); font-size: 28px; letter-spacing: -.03em; }
.empty-state p:not(.eyebrow) { max-width: 470px; margin: 10px 0 22px; line-height: 1.6; }
.empty-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--ink);
  border-radius: 16px;
  font-size: 24px;
}

.notice {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: 440px;
  padding: 14px 18px;
  color: white;
  background: var(--ink);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(16, 24, 40, .25);
}
.notice.error { background: #7a271a; }
.notice.warning { background: #7a2e0e; }

dialog {
  width: min(520px, calc(100% - 30px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 22px 70px rgba(16, 24, 40, .28);
}
dialog::backdrop { background: rgba(16, 24, 40, .55); }
.dialog-form { padding: 25px; display: grid; gap: 16px; }
.dialog-heading, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-heading h2 { margin: 0; }
.dialog-actions { justify-content: flex-end; margin-top: 6px; }

.busy {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  background: var(--ink);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(16, 24, 40, .25);
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1000px) {
  .layout { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-list { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
  .workspace { margin: auto; padding-inline: 24px; }
  .editor-grid, .upload-form { grid-template-columns: 1fr; }
  .brand-form { grid-template-columns: 1fr; align-items: stretch; }
}

@media (max-width: 680px) {
  .login-card { padding: 28px 22px; }
  .login-card h1 { font-size: 26px; }
  .topbar { padding: 0 16px; }
  .connection { display: none; }
  .button-ghost { padding-inline: 11px; font-size: 12px; }
  .brand small { display: none; }
  .sidebar { padding: 22px 16px; }
  .brand-list { grid-template-columns: 1fr; }
  .workspace { padding: 30px 14px 70px; }
  .overview-grid { grid-template-columns: 1fr; }
  .card { padding: 20px 16px; }
  .revision-heading { display: grid; }
  .heading-actions { margin-top: 14px; display: grid; align-items: stretch; }
  .heading-actions select { width: 100%; min-width: 0; }
  .action-row { display: grid; grid-template-columns: 1fr; }
  .action-row .button { width: 100%; }
  .local-apply-section { grid-template-columns: 1fr; }
  .local-apply-actions { display: grid; grid-template-columns: 1fr; }
  .asset-list { grid-template-columns: 1fr; }
  .empty-state { min-height: 420px; margin: 30px 14px; }
  .notice { right: 16px; bottom: 16px; left: 16px; max-width: none; }
}
