:root {
  --bg: #f5f8fc;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --border: #dfe7f2;
  --line: #edf2f7;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eaf1ff;
  --green: #16a34a;
  --green-soft: #e8f8ef;
  --orange: #f59e0b;
  --orange-soft: #fff6df;
  --red: #ef4444;
  --red-soft: #fff1f2;
  --purple: #7c3aed;
  --purple-soft: #f3eefe;
  --cyan: #06b6d4;
  --cyan-soft: #ecfeff;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.07);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.05);
  --radius: 22px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

body.has-modal {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  padding: 11px 13px;
  outline: 0;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #bfdbfe;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.11);
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-weight: 750;
}

hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

.guest-page {
  background: var(--bg);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
}

.auth-panel-wide {
  width: min(720px, 100%);
}

.auth-heading {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.auth-heading h1 {
  margin-bottom: 0;
  letter-spacing: -0.04em;
}

.muted,
.auth-heading p {
  color: var(--muted);
}

.block {
  display: block;
  margin-top: 5px;
}

.mt {
  margin-top: 24px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  transition: grid-template-columns 0.2s ease;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
  padding: 24px 20px;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 12px;
  color: var(--text);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--blue), #60a5fa);
  color: #fff;
  font-weight: 950;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
}

.brand-mark .icon {
  width: 21px;
  height: 21px;
}

.brand strong {
  font-size: 20px;
  letter-spacing: 0;
}

.brand-label,
.nav-label,
.sidebar-user-copy {
  transition: opacity 0.12s ease;
}

.sidebar-toggle {
  position: absolute;
  top: 27px;
  right: -16px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 0;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
  border-color: #bfdbfe;
  color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.11);
  outline: 0;
}

.sidebar-toggle .icon {
  width: 17px;
  height: 17px;
}

.sidebar-toggle-expand {
  display: none;
}

.nav-section-label {
  margin: 10px 10px 0;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav a {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 14px;
  padding: 0 13px;
  color: #334155;
  font-weight: 700;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav a:hover {
  background: #f1f5f9;
  color: var(--blue);
}

.nav a.is-active {
  background: var(--blue-soft);
  color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--muted);
}

.nav a.is-active .nav-icon {
  color: var(--blue);
}

.sidebar-bottom {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, var(--surface-soft));
  padding: 16px;
  box-shadow: var(--shadow-soft);
  min-width: 0;
}

.sidebar-user-icon {
  display: none;
  color: var(--blue);
}

.sidebar-user-copy {
  min-width: 0;
}

.sidebar-bottom strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.plan-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

@media (min-width: 861px) {
  html.sidebar-collapsed .app-shell {
    grid-template-columns: 80px minmax(0, 1fr);
  }

  html.sidebar-collapsed .sidebar {
    gap: 18px;
    padding-left: 15px;
    padding-right: 15px;
  }

  html.sidebar-collapsed .brand {
    justify-content: center;
    gap: 0;
    padding-left: 0;
    padding-right: 0;
  }

  html.sidebar-collapsed .brand-label,
  html.sidebar-collapsed .nav-label,
  html.sidebar-collapsed .nav-section-label,
  html.sidebar-collapsed .sidebar-user-copy {
    width: 0;
    overflow: hidden;
    opacity: 0;
    white-space: nowrap;
  }

  html.sidebar-collapsed .nav-section-label {
    height: 11px;
    margin-left: 0;
    margin-right: 0;
  }

  html.sidebar-collapsed .nav a {
    justify-content: center;
    gap: 0;
    padding-left: 0;
    padding-right: 0;
  }

  html.sidebar-collapsed .sidebar-bottom {
    justify-content: center;
    gap: 0;
    padding: 12px;
  }

  html.sidebar-collapsed .sidebar-user-icon {
    display: block;
  }

  html.sidebar-collapsed .sidebar-toggle-collapse {
    display: none;
  }

  html.sidebar-collapsed .sidebar-toggle-expand {
    display: block;
  }
}

.main-column {
  min-width: 0;
  padding-bottom: 46px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
  padding: 0 36px;
}

.topbar-title strong {
  display: block;
  color: var(--text);
  font-size: 18px;
  letter-spacing: 0;
}

.topbar-title span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.user-chip {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 0 12px;
  color: #1e293b;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #f97316);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 30px 36px 40px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 0;
}

.page-header h1 {
  margin: 0;
  color: var(--text);
  font-size: 36px;
  line-height: 1.05;
  letter-spacing: 0;
}

.page-header p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
}

.panel,
.stat {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.panel {
  padding: 22px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  letter-spacing: 0;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.template-layout {
  display: grid;
  grid-template-columns: minmax(380px, 0.95fr) minmax(0, 1.05fr);
  gap: 22px;
  align-items: start;
}

.template-builder-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1.15fr) minmax(380px, 0.85fr);
  gap: 22px;
  align-items: start;
}

.builder-editor,
.builder-preview-panel {
  min-width: 0;
}

.builder-editor {
  overflow: hidden;
  padding: 0;
}

.builder-preview-panel {
  position: sticky;
  top: 110px;
  max-height: calc(100vh - 134px);
  overflow-y: auto;
}

.builder-main-header {
  align-items: center;
  margin: 0;
  border-bottom: 1px solid var(--border);
  padding: 18px 22px;
}

.builder-main-header .segmented-control .icon {
  width: 17px;
  height: 17px;
}

.builder-basics {
  padding: 22px;
}

.builder-section {
  display: grid;
  gap: 14px;
  margin: 0;
  border-top: 1px solid var(--border);
  padding: 20px 22px;
}

.builder-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.builder-section-header h3 {
  margin: 0;
  font-size: 15px;
}

.builder-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.builder-presets button {
  min-width: 0;
  min-height: 70px;
  display: grid;
  place-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: #334155;
  padding: 10px 6px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.builder-presets button:hover,
.builder-presets button:focus-visible {
  border-color: #93c5fd;
  background: var(--blue-soft);
  color: var(--blue);
  outline: 0;
}

.builder-presets .icon {
  width: 22px;
  height: 22px;
}

.builder-settings {
  background: var(--surface-soft);
}

.color-field > span {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 8px;
}

.color-field input[type="color"] {
  width: 46px;
  height: 42px;
  padding: 4px;
  cursor: pointer;
}

.builder-options {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.builder-options summary {
  color: #334155;
  font-weight: 800;
  cursor: pointer;
}

.builder-options[open] summary {
  margin-bottom: 14px;
}

.builder-workspace {
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 0;
  padding: 0;
}

.builder-library {
  display: grid;
  align-content: start;
  gap: 12px;
  border-right: 1px solid var(--border);
  background: var(--surface-soft);
  padding: 18px 14px;
}

.builder-library h3,
.builder-canvas h3,
.builder-test-form h3 {
  margin: 0;
  font-size: 14px;
}

.builder-library h3:not(:first-child) {
  margin-top: 8px;
}

.builder-library-items {
  display: grid;
  gap: 7px;
}

.builder-library-items > button {
  min-height: 42px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: #334155;
  padding: 8px 9px;
  text-align: left;
  font-size: 12px;
  font-weight: 800;
  cursor: grab;
}

.builder-library-items > button:hover,
.builder-library-items > button:focus-visible {
  border-color: #93c5fd;
  color: var(--blue);
  outline: 0;
}

.builder-library-items .icon {
  width: 18px;
  height: 18px;
}

.builder-library-items .builder-add-icon {
  width: 15px;
  height: 15px;
  color: var(--muted-2);
}

.builder-media-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.builder-media-items button {
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 3px;
  cursor: pointer;
}

.builder-media-items button:hover {
  border-color: var(--blue);
}

.builder-media-items img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 5px;
  object-fit: cover;
}

.builder-canvas {
  min-width: 0;
  padding: 18px;
}

.builder-canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.builder-canvas-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.builder-blocks {
  display: grid;
  gap: 10px;
  min-height: 80px;
}

.builder-block {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.04);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.builder-block:focus-within {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.builder-sortable-ghost {
  border: 1px dashed var(--blue);
  background: var(--blue-soft);
  opacity: 0.45;
}

.builder-sortable-chosen,
.builder-sortable-drag {
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

.builder-block-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.builder-drag-handle {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-2);
  padding: 0;
  cursor: grab;
}

.builder-drag-handle:hover,
.builder-drag-handle:focus-visible {
  background: var(--surface-soft);
  color: var(--blue);
  outline: 0;
}

.builder-drag-handle:active {
  cursor: grabbing;
}

.builder-block-type {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #334155;
  font-size: 14px;
}

.builder-block-type .icon {
  width: 17px;
  height: 17px;
  color: var(--blue);
}

.builder-block-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.builder-block-actions .icon-button {
  width: 30px;
  height: 30px;
  border-radius: 6px;
}

.builder-block-actions .icon {
  width: 15px;
  height: 15px;
}

.builder-remove-button:hover {
  border-color: #fecdd3;
  background: var(--red-soft);
  color: var(--red);
}

.builder-divider-preview {
  margin: 8px 0;
}

.builder-code-input {
  min-height: 150px;
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  tab-size: 2;
}

.builder-empty-state {
  margin-top: 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  font-weight: 750;
}

.builder-html-editor {
  gap: 16px;
}

.notice-inline {
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: var(--orange-soft);
  color: #92400e;
  padding: 11px 13px;
  font-weight: 750;
}

.builder-form-actions {
  margin: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 16px 22px;
}

.builder-form-actions .icon,
.template-builder-header .icon {
  width: 18px;
  height: 18px;
}

.email-preview-shell {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #e8eef7;
  padding: 16px;
  transition: padding 0.18s ease;
}

.email-preview-shell iframe {
  width: 100%;
  min-height: 680px;
  border: 0;
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  transition: width 0.18s ease;
}

.email-preview-shell[data-preview-shell="mobile"] {
  display: flex;
  justify-content: center;
  padding: 12px;
}

.email-preview-shell[data-preview-shell="mobile"] iframe {
  width: min(375px, 100%);
}

.preview-size-control button {
  width: 34px;
  padding: 7px;
}

.preview-size-control .icon {
  width: 17px;
  height: 17px;
}

.builder-test-form,
.builder-server-preview {
  display: grid;
  gap: 14px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.builder-test-form .button-row {
  justify-content: flex-end;
}

.builder-server-preview iframe {
  width: 100%;
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.list-summary,
.stats-grid,
.quota-grid {
  display: grid;
  gap: 18px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.list-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quota-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-grid-small {
  margin-bottom: 0;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.status-card {
  min-height: 98px;
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
  padding: 16px;
}

.status-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-card strong {
  color: var(--text);
  font-size: 28px;
  font-weight: 950;
}

.status-card-pending {
  border-color: #fde68a;
  background: var(--orange-soft);
}

.status-card-processing {
  border-color: #bae6fd;
  background: var(--cyan-soft);
}

.status-card-failed {
  border-color: #fecdd3;
  background: var(--red-soft);
}

.status-card-sent {
  border-color: #bbf7d0;
  background: var(--green-soft);
}

.queue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.queue-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 800;
}

.queue-meta strong {
  color: var(--text);
}

.queue-error {
  max-width: 340px;
  color: var(--red);
}

.stat {
  min-height: 112px;
  padding: 22px;
}

.stat span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  color: var(--text);
  font-size: 30px;
  font-weight: 950;
  letter-spacing: 0;
}

.stat-text {
  font-size: 20px !important;
}

.quota-item {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
  padding: 16px;
}

.quota-item div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quota-item span {
  color: var(--muted);
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef7;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #60a5fa);
}

.import-progress-panel {
  display: grid;
  gap: 20px;
}

.import-progress-bar {
  height: 14px;
}

.import-progress-percentage {
  margin: -10px 0 0;
  text-align: right;
}

.import-progress-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--border);
}

.import-progress-stats div {
  background: var(--surface);
  padding: 18px;
}

.import-progress-stats dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.import-progress-stats dd {
  margin: 6px 0 0;
  font-size: 24px;
  font-weight: 850;
}

.usage-stack {
  display: grid;
  gap: 10px;
}

.usage-stack-compact {
  min-width: 220px;
}

.usage-row {
  display: grid;
  gap: 7px;
}

.usage-row > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.usage-row strong {
  color: var(--text);
  font-size: 13px;
}

.usage-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 750;
}

.checkbox input {
  width: auto;
  accent-color: var(--blue);
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--blue);
  border-radius: 13px;
  background: var(--blue);
  color: #fff;
  padding: 9px 16px;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 14px 26px rgba(37, 99, 235, 0.22);
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
  white-space: nowrap;
}

.button:hover {
  transform: translateY(-1px);
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: #fff;
}

.button-muted {
  border-color: var(--border);
  background: var(--surface);
  color: #334155;
  box-shadow: var(--shadow-soft);
}

.button-muted:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #1e293b;
}

.button-danger {
  border-color: #fecdd3;
  background: var(--red-soft);
  color: #be123c;
  box-shadow: none;
}

.button-danger:hover {
  border-color: #fb7185;
  background: #ffe4e6;
  color: #9f1239;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 950;
  cursor: pointer;
}

.icon-button:hover {
  color: var(--text);
  border-color: #cbd5e1;
  background: #f8fafc;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.media-upload-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
  gap: 14px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.media-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.media-card__thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  background:
    linear-gradient(45deg, rgba(148, 163, 184, 0.14) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(148, 163, 184, 0.14) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(148, 163, 184, 0.14) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(148, 163, 184, 0.14) 75%),
    #f8fafc;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.media-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.media-card__body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.media-card__body strong {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.media-url-row input {
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.media-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.media-picker button {
  display: grid;
  gap: 7px;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
  padding: 8px;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  box-shadow: none;
  white-space: normal;
}

.media-picker button:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.media-picker img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
}

.media-picker span {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-picker-compact {
  grid-template-columns: repeat(auto-fill, minmax(110px, 150px));
  margin: 8px 0 4px;
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 4px;
}

.segmented-control button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  font-weight: 850;
  cursor: pointer;
}

.segmented-control button.is-active {
  background: var(--surface);
  color: var(--blue);
  box-shadow: var(--shadow-soft);
}

[data-template-raw-html] {
  min-height: 520px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.notice {
  margin: 18px 36px 0;
  border-radius: 16px;
  padding: 13px 16px;
  font-weight: 800;
}

.auth-panel .notice {
  margin: 0 0 16px;
}

.notice-success {
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #bbf7d0;
}

.notice-error {
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid #fecdd3;
}

.notice-impersonation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #b45309;
  background: var(--orange-soft);
  border: 1px solid #fcd34d;
}

.notice-impersonation form {
  margin: 0;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(6px);
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(86vh, 860px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.25);
  padding: 22px;
}

.modal__panel--wide {
  width: min(980px, 100%);
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal__header h2 {
  margin: 0;
  font-size: 22px;
}

.modal__header p {
  margin: 7px 0 0;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.modal__section {
  display: grid;
  gap: 14px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  color: #334155;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  color: #334155;
  vertical-align: middle;
}

tbody tr {
  transition: background 0.16s ease;
}

tbody tr:hover {
  background: #fbfdff;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.badge-success {
  border-color: #bbf7d0;
  background: var(--green-soft);
  color: var(--green);
}

.badge-warning {
  border-color: #fde68a;
  background: var(--orange-soft);
  color: #b45309;
}

.badge-info {
  border-color: #bae6fd;
  background: var(--cyan-soft);
  color: #0e7490;
}

.badge-danger {
  border-color: #fecdd3;
  background: var(--red-soft);
  color: #be123c;
}

.badge-muted {
  border-color: var(--border);
  background: #f8fafc;
  color: var(--muted);
}

.inline-search {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: min(100%, 420px);
}

.inline-search input {
  min-width: 190px;
}

.inline-search input,
.inline-search select {
  width: auto;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.actions form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.actions input,
.actions select {
  width: auto;
  min-width: 140px;
}

.resource-title {
  color: var(--blue);
  font-weight: 900;
}

.resource-title:hover {
  color: var(--blue-dark);
}

.empty-state {
  color: var(--muted);
  padding: 18px 16px;
}

.settings-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.settings-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
  padding: 16px;
}

.instruction-box {
  display: grid;
  gap: 10px;
  border: 1px solid #bbf7d0;
  border-radius: 18px;
  background: var(--green-soft);
  color: #14532d;
  padding: 16px;
  margin-bottom: 16px;
}

.instruction-box p {
  margin-bottom: 0;
}

.instruction-box code {
  border-radius: 8px;
  background: #fff;
  padding: 3px 6px;
}

.api-secret-panel {
  border-color: #fbbf24;
  background: #fffbeb;
}

.api-secret-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.api-secret-row code {
  flex: 1 1 420px;
  overflow-x: auto;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  white-space: nowrap;
}

.api-code-block {
  display: grid;
  gap: 10px;
  justify-items: start;
}

.api-code-block pre {
  width: 100%;
  overflow-x: auto;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  white-space: pre-wrap;
}

.dns-record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.dns-record {
  display: grid;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
  padding: 14px;
}

.dns-record span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dns-record code {
  display: block;
  overflow-x: auto;
  border: 1px solid #d6e2f2;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  color: #1d2939;
  white-space: nowrap;
}

.dns-record-highlight {
  background: #fff;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.variable-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.variable-pills button {
  min-height: 34px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 850;
  cursor: pointer;
}

.variable-pills button:hover {
  border-color: var(--blue);
}

.preview-box {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.preview-box iframe {
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}

.pagination__summary,
.pagination__limit {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pagination__links,
.pagination__limit {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pagination__link,
.pagination__limit-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  min-width: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  padding: 6px 10px;
  text-decoration: none;
}

.pagination__link:hover,
.pagination__limit-link:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.pagination__link.is-active,
.pagination__limit-link.is-active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.pagination__link.is-disabled {
  background: var(--surface-soft);
  color: var(--muted);
  cursor: not-allowed;
}

.pagination__ellipsis {
  color: var(--muted);
  font-weight: 900;
  padding: 0 2px;
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-grid,
  .template-layout,
  .template-builder-layout {
    grid-template-columns: 1fr;
  }

  .builder-preview-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 860px) {
  .app-shell,
  .stats-grid,
  .status-grid,
  .list-summary,
  .import-progress-stats,
  .dns-record-grid,
  .quota-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar-toggle {
    display: none;
  }

  .topbar,
  .page-header,
  .panel-header,
  .builder-section-header,
  .builder-block-header {
    align-items: stretch;
    flex-direction: column;
  }

  .builder-workspace {
    grid-template-columns: 1fr;
  }

  .builder-library {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .builder-library-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .builder-media-items {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .builder-block-header {
    align-items: center;
    flex-direction: row;
  }

  .builder-block-actions {
    flex-wrap: wrap;
  }

  .topbar,
  .content {
    padding-left: 18px;
    padding-right: 18px;
  }

  .page-header h1 {
    font-size: 30px;
  }

  .inline-search,
  .top-actions,
  .actions,
  .actions form {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-search input,
  .inline-search select,
  .actions input,
  .actions select,
  .button {
    width: 100%;
  }

  .segmented-control button,
  .builder-block-actions .icon-button {
    width: auto;
  }

  .builder-form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .media-upload-form,
  .media-url-row {
    grid-template-columns: 1fr;
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination__links,
  .pagination__limit {
    justify-content: flex-start;
  }

  .modal {
    align-items: start;
    padding: 10px;
  }

  .modal__panel {
    max-height: calc(100vh - 20px);
    border-radius: 18px;
    padding: 18px;
  }

  .modal__footer {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .builder-presets,
  .builder-library-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .builder-media-items {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .builder-main-header {
    align-items: stretch;
  }

  .builder-block-type {
    flex: 1;
  }

}
