:root {
  --ig-bg: #fafafa;
  --ig-card: #ffffff;
  --ig-border: #dbdbdb;
  --ig-fg: #262626;
  --ig-muted: #8e8e8e;
  --ig-accent: #0095f6;
  --ig-accent-dark: #00376b;
  --ig-danger: #ed4956;
  --ig-success: #2ecc71;
  --ig-radius: 10px;
  --ig-gradient: linear-gradient(135deg, #f58529 0%, #dd2a7b 50%, #515bd4 100%);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--ig-bg);
  color: var(--ig-fg);
  line-height: 1.4;
}

a { color: var(--ig-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--ig-muted); }
.small { font-size: 12px; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Auth (login) ---------- */

.admin-auth {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(221, 42, 123, 0.18), transparent 55%),
    radial-gradient(circle at 80% 90%, rgba(81, 91, 212, 0.18), transparent 55%),
    linear-gradient(180deg, #fafafa 0%, #efefef 100%);
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--ig-card);
  border: 1px solid var(--ig-border);
  border-radius: var(--ig-radius);
  padding: 32px 32px 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.auth-brand {
  text-align: center;
  margin-bottom: 24px;
}

.auth-brand h1 {
  margin: 12px 0 4px;
  font-size: 26px;
  letter-spacing: 0.5px;
}

.auth-brand .muted { font-size: 13px; }

.auth-logo {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  margin: 0 auto;
  background: var(--ig-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 6px 18px rgba(221, 42, 123, 0.25);
}

.auth-logo .logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.9;
}

.auth-footer {
  margin-top: 20px;
  font-size: 12px;
}

.auth-hint {
  text-align: center;
  font-size: 12px;
  margin: 16px 0 0;
}

.auth-hint code {
  background: #f2f2f2;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ---------- Forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field > span {
  font-size: 12px;
  color: var(--ig-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="url"],
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--ig-border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--ig-accent);
  box-shadow: 0 0 0 3px rgba(0, 149, 246, 0.15);
}

.field input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--ig-border);
  border-radius: 8px;
  background: #fff;
}

.field textarea { resize: vertical; min-height: 84px; }

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 10px 0;
}

.checkbox input { accent-color: var(--ig-accent); }

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 6px;
}

.stack > * + * { margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.05s ease, background-color 0.15s ease,
    box-shadow 0.15s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ig-accent);
  color: #fff;
}
.btn-primary:hover { background: #1877d2; text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--ig-fg);
  border-color: var(--ig-border);
}
.btn-ghost:hover { background: #f2f2f2; text-decoration: none; }

.btn-block { width: 100%; }

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ---------- Alerts ---------- */

.alert {
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  border: 1px solid transparent;
}

.alert-error {
  background: #fdecea;
  border-color: #f5c2c0;
  color: #a8241f;
}

.alert-success {
  background: #e7f8ef;
  border-color: #b7e4c8;
  color: #1c7a45;
}

/* ---------- Admin chrome ---------- */

.admin-header {
  background: #fff;
  border-bottom: 1px solid var(--ig-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-bar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ig-fg);
  font-size: 16px;
}
.admin-brand:hover { text-decoration: none; }
.admin-brand small {
  font-weight: 500;
  color: var(--ig-muted);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.admin-brand .logo-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--ig-gradient);
  display: inline-block;
}

.admin-nav {
  flex: 1;
  display: flex;
  gap: 4px;
  margin-left: 12px;
}

.admin-nav a {
  color: var(--ig-fg);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
}

.admin-nav a:hover { background: #f2f2f2; text-decoration: none; }
.admin-nav a.active {
  background: #e9f5ff;
  color: var(--ig-accent-dark);
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.inline { display: inline; }

.admin-main { padding: 28px 20px 64px; }

/* ---------- Panels ---------- */

.panel { display: flex; flex-direction: column; gap: 18px; }

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

.panel-head h1 {
  margin: 0 0 4px;
  font-size: 24px;
}
.panel-head p { margin: 0; }

.stat-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid var(--ig-border);
  border-radius: 10px;
}

.stat-pill .stat-label {
  font-size: 11px;
  color: var(--ig-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-pill strong { font-size: 22px; }

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.panel-grid.two-col {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.panel-card {
  background: #fff;
  border: 1px solid var(--ig-border);
  border-radius: var(--ig-radius);
  padding: 20px;
}

.panel-card h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.panel-card h3 {
  margin: 16px 0 8px;
  font-size: 14px;
  color: var(--ig-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recent-list li {
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recent-list a {
  color: var(--ig-fg);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.code {
  background: #0b1021;
  color: #e3e8ff;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: auto;
  white-space: pre;
}

.kv {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kv li {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  border-bottom: 1px solid #f2f2f2;
  padding: 6px 0;
}

.kv span { color: var(--ig-muted); }

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--ig-border);
  vertical-align: middle;
  margin-right: 6px;
}

/* ---------- Layout picker ---------- */

.layout-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin: 4px 0 16px;
}

.layout-option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--ig-border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.layout-option:hover { border-color: var(--ig-accent); }
.layout-option.is-active,
.layout-option:has(input:checked) {
  border-color: var(--ig-accent);
  box-shadow: 0 0 0 3px rgba(0, 149, 246, 0.15);
}
.layout-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }

.layout-body { display: flex; flex-direction: column; gap: 2px; }
.layout-body strong { font-size: 13px; }
.layout-body em {
  font-style: normal;
  color: var(--ig-muted);
  font-size: 12px;
  line-height: 1.3;
}

.layout-preview {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  background: #f4f4f6;
  position: relative;
  overflow: hidden;
}

.layout-preview::before,
.layout-preview::after {
  content: '';
  position: absolute;
  inset: 0;
}

/* Grid preview */
.layout-preview--grid::before {
  background:
    linear-gradient(#cbd5e1 0 0) 0 0 / 30% 45%,
    linear-gradient(#cbd5e1 0 0) 35% 0 / 30% 45%,
    linear-gradient(#cbd5e1 0 0) 70% 0 / 30% 45%,
    linear-gradient(#cbd5e1 0 0) 0 55% / 30% 45%,
    linear-gradient(#cbd5e1 0 0) 35% 55% / 30% 45%,
    linear-gradient(#cbd5e1 0 0) 70% 55% / 30% 45%;
  background-repeat: no-repeat;
  inset: 10%;
}

/* Masonry preview */
.layout-preview--masonry::before {
  background:
    linear-gradient(#cbd5e1 0 0) 0 0 / 30% 65%,
    linear-gradient(#cbd5e1 0 0) 35% 0 / 30% 45%,
    linear-gradient(#cbd5e1 0 0) 70% 0 / 30% 80%,
    linear-gradient(#cbd5e1 0 0) 0 70% / 30% 30%,
    linear-gradient(#cbd5e1 0 0) 35% 50% / 30% 50%;
  background-repeat: no-repeat;
  inset: 8%;
}

/* Carousel preview */
.layout-preview--carousel::before {
  background:
    linear-gradient(#cbd5e1 0 0) 0 50% / 22% 70%,
    linear-gradient(#cbd5e1 0 0) 25% 50% / 22% 70%,
    linear-gradient(#cbd5e1 0 0) 50% 50% / 22% 70%,
    linear-gradient(#cbd5e1 0 0) 75% 50% / 22% 70%;
  background-repeat: no-repeat;
  background-position-y: center;
  inset: 15% 0;
}

/* Slider preview */
.layout-preview--slider::before {
  background: #cbd5e1;
  inset: 18% 18%;
  border-radius: 4px;
}
.layout-preview--slider::after {
  background:
    radial-gradient(circle at 8% 50%, #94a3b8 0 4px, transparent 5px),
    radial-gradient(circle at 92% 50%, #94a3b8 0 4px, transparent 5px);
  inset: 0;
}

/* Social wall preview */
.layout-preview--social-wall::before {
  background:
    linear-gradient(#f472b6 0 0) 0 0 / 45% 60%,
    linear-gradient(#60a5fa 0 0) 48% 0 / 25% 45%,
    linear-gradient(#fbbf24 0 0) 76% 0 / 24% 60%,
    linear-gradient(#34d399 0 0) 48% 48% / 25% 40%,
    linear-gradient(#a78bfa 0 0) 0 65% / 45% 35%,
    linear-gradient(#f87171 0 0) 76% 65% / 24% 35%;
  background-repeat: no-repeat;
  inset: 8%;
  border-radius: 4px;
}

/* Single preview */
.layout-preview--single::before {
  background: linear-gradient(135deg, #94a3b8, #cbd5e1);
  inset: 10% 22%;
  border-radius: 6px;
}
.layout-preview--single::after {
  background:
    linear-gradient(#e2e8f0 0 0) 28% 82% / 44% 4px,
    linear-gradient(#e2e8f0 0 0) 28% 90% / 30% 4px;
  background-repeat: no-repeat;
  inset: 0;
}

/* List preview */
.layout-preview--list::before {
  background:
    linear-gradient(#cbd5e1 0 0) 0 0 / 100% 28%,
    linear-gradient(#cbd5e1 0 0) 0 36% / 100% 28%,
    linear-gradient(#cbd5e1 0 0) 0 72% / 100% 28%;
  background-repeat: no-repeat;
  inset: 10%;
}

/* ---------- Widgets table ---------- */

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

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

.widget-table th,
.widget-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #f2f2f2;
  vertical-align: middle;
}

.widget-table th {
  font-size: 12px;
  color: var(--ig-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: #fafafa;
}

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

.widget-table code {
  background: #f2f2f2;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

.tag-stack {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.btn.danger { color: var(--ig-danger); border-color: transparent; }
.btn.danger:hover { background: #fdecea; }

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th,
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ig-border, #eee);
  text-align: left;
  vertical-align: top;
}
.admin-table thead th {
  background: #fafafa;
  font-weight: 600;
  color: var(--muted, #666);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-table code {
  font-size: 12px;
  background: #f5f5f7;
  padding: 1px 6px;
  border-radius: 4px;
}
.admin-table .nowrap,
.nowrap { white-space: nowrap; }

.panel-card.no-pad { padding: 0; overflow: hidden; }

.btn-sm {
  font-size: 12px;
  padding: 4px 10px;
}

.badge-success {
  background: #d8f5de;
  color: #1a7f37;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-muted {
  background: #eef0f3;
  color: #666;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.post-modal__tag {
  background: #f1f5ff;
  color: var(--ig-accent);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

@media (max-width: 800px) {
  .panel-grid.two-col { grid-template-columns: 1fr; }
  .admin-nav { overflow-x: auto; }
  .admin-bar { flex-wrap: wrap; }
}
