:root {
  --studio-navy: #425c81;
  --studio-navy-dark: #304663;
  --studio-gold: #aa9658;
  --studio-bg: #f5f7fa;
  --studio-ink: #1f2937;
}

body { background: var(--studio-bg); color: var(--studio-ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif; }
.studio-nav { background: linear-gradient(135deg, var(--studio-navy-dark), var(--studio-navy)); color: #fff; box-shadow: 0 4px 20px rgba(31, 41, 55, .13); }
.studio-nav .navbar-brand { color: #fff; font-weight: 800; }
.nav-logo { width: 38px; height: 38px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.page-title { margin: 0; font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 800; color: var(--studio-navy-dark); }
.eyebrow { display: block; color: var(--studio-gold); font-weight: 800; margin-bottom: .35rem; }
.studio-primary { background: var(--studio-navy); border-color: var(--studio-navy); color: #fff; }
.studio-primary:hover, .studio-primary:focus { background: var(--studio-navy-dark); border-color: var(--studio-navy-dark); color: #fff; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.stat-card, .panel { background: #fff; border: 1px solid #e8edf3; border-radius: 18px; box-shadow: 0 8px 30px rgba(31, 41, 55, .06); }
.stat-card { padding: 1.25rem; }
.stat-card span { display: block; color: #6b7280; }
.stat-card strong { display: block; color: var(--studio-navy); font-size: 2rem; margin-top: .25rem; }
.panel { overflow: hidden; }
.panel-heading { padding: 1.1rem 1.25rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #edf0f4; }
.panel-heading h2 { margin: 0; font-size: 1.1rem; font-weight: 800; }
.panel-heading span { color: #6b7280; }
.table > :not(caption) > * > * { padding: .9rem 1.1rem; }
.table thead th { color: #64748b; font-size: .9rem; font-weight: 700; background: #fafbfd; }
.guest-bulk-toolbar { padding: .75rem 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid #edf0f4; }
.guest-select-column { width: 3.25rem; text-align: center; }
.status-pill { display: inline-block; padding: .3rem .65rem; border-radius: 999px; background: #eaf0f8; color: var(--studio-navy); font-size: .85rem; font-weight: 700; }
.whatsapp-status-success { color: #166534; background: #dcfce7; }
.whatsapp-status-failed { color: #991b1b; background: #fee2e2; }
.whatsapp-status-queued, .whatsapp-status-sending { color: #854d0e; background: #fef3c7; }
.empty-state { padding: 3rem 1rem; text-align: center; color: #6b7280; }
.form-shell { max-width: 760px; margin-inline: auto; }
.form-shell-wide { max-width: 980px; }
.form-panel { padding: clamp(1.25rem, 4vw, 2rem); }
.form-label { font-weight: 700; color: var(--studio-navy-dark); }
.form-control, .form-select { min-height: 48px; border-radius: 10px; border-color: #dce2ea; }
.back-link { color: var(--studio-navy); text-decoration: none; font-weight: 700; }
.campaign-action-button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; padding-inline: 1rem; }
.job-list { padding: .4rem 1.2rem; }
.job-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid #edf0f4; }
.job-row:last-child { border-bottom: 0; }
.job-row small { display: block; color: #6b7280; margin-top: .25rem; }
.template-preview-body { padding: 1.25rem; }
.template-preview-image { display: block; width: 100%; max-height: 440px; object-fit: contain; border: 1px solid #e3e8ef; border-radius: 12px; background: #f8fafc; }
.template-preview-empty { min-height: 280px; display: grid; place-content: center; gap: .35rem; padding: 1rem; text-align: center; color: #64748b; border: 1px dashed #cbd5e1; border-radius: 12px; background: #f8fafc; }
.template-preview-empty small { color: #94a3b8; }
.template-name-link { color: var(--studio-navy-dark); font-weight: 800; text-decoration: none; }
.template-name-link:hover { color: var(--studio-navy); text-decoration: underline; }
.template-list-thumbnail { width: 72px; height: 92px; object-fit: contain; border: 1px solid #e3e8ef; border-radius: 8px; background: #f8fafc; }
.template-thumbnail-wrap { position: relative; display: inline-block; line-height: 0; }
.template-page-count-badge { position: absolute; top: 4px; right: 4px; min-width: 25px; padding: .22rem .32rem; border-radius: 999px; color: #fff; background: rgba(48, 70, 99, .92); font-size: .68rem; font-weight: 800; line-height: 1; text-align: center; box-shadow: 0 2px 7px rgba(15, 23, 42, .22); }
.template-thumbnail-empty { display: inline-grid; place-items: center; width: 72px; height: 92px; padding: .4rem; border: 1px dashed #cbd5e1; border-radius: 8px; color: #94a3b8; font-size: .72rem; text-align: center; background: #f8fafc; }
.template-dimensions { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.template-dimensions div { padding: .75rem; border-radius: 10px; background: #f8fafc; }
.template-dimensions dt { color: #64748b; font-size: .8rem; }
.template-dimensions dd { margin: .2rem 0 0; color: var(--studio-navy-dark); font-weight: 800; }
.overlay-formset { padding: 1.25rem; background: #f8fafc; }
.overlay-forms { display: grid; gap: 1rem; }
.overlay-form-card { padding: 1.1rem; border: 1px solid #dfe6ef; border-radius: 14px; background: #fff; box-shadow: 0 4px 16px rgba(31, 41, 55, .05); }
.overlay-form-card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding-bottom: .8rem; border-bottom: 1px solid #edf0f4; color: var(--studio-navy-dark); }
.overlay-form-card.is-pending-delete { border-color: #e9c46a; background: #fffcf2; }
.overlay-form-card.is-pending-delete .overlay-form-card-body { opacity: .42; pointer-events: none; }
.overlay-delete-notice { margin-bottom: 1rem; }
.overlay-empty-state { padding: 2rem 1rem; border: 1px dashed #cbd5e1; border-radius: 12px; color: #64748b; text-align: center; background: #fff; }
.overlay-formset-actions { display: flex; justify-content: center; margin-top: 1rem; }
.qr-style-controls[hidden] { display: none !important; }
.qr-style-panel { padding: 1rem; border: 1px solid #dbe4ef; border-radius: 12px; background: #f8fafc; }
.qr-style-panel .form-control-color { width: 100%; padding: .35rem; cursor: pointer; }
.template-pages-list { display: grid; gap: 1rem; padding: 1.25rem; max-height: 75vh; overflow-y: auto; }
.template-page-preview { padding: .75rem; border: 1px solid #e3e8ef; border-radius: 12px; background: #f8fafc; }
.template-page-heading { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .65rem; color: var(--studio-navy-dark); }
.template-page-heading span { color: #64748b; font-size: .76rem; direction: ltr; }
.template-order-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; padding: 1.25rem; }
.template-order-card { position: relative; display: grid; gap: .65rem; padding: .75rem; border: 2px solid #e3e8ef; border-radius: 14px; background: #fff; cursor: grab; transition: border-color .15s, opacity .15s, transform .15s; }
.template-order-card:hover { border-color: #b8c5d6; transform: translateY(-2px); }
.template-order-card.is-dragging { opacity: .45; border-color: var(--studio-gold); }
.template-order-card img { width: 100%; height: 240px; object-fit: contain; border-radius: 9px; background: #f8fafc; }
.template-order-number { color: var(--studio-navy); font-weight: 800; }
.template-order-meta { min-width: 0; }
.template-order-meta strong, .template-order-meta small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-order-meta small { color: #64748b; direction: ltr; text-align: right; }
.template-order-actions { display: flex; gap: .5rem; }
.region-editor-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.region-editor-save-area { display: flex; align-items: center; gap: .85rem; }
.region-save-status { color: #64748b; font-size: .86rem; font-weight: 700; }
.region-save-status.is-dirty { color: #9a6700; }
.region-editor-toolbar { position: sticky; top: .75rem; z-index: 30; display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; padding: .65rem; margin-bottom: 1rem; border: 1px solid #dfe6ef; border-radius: 14px; background: rgba(255, 255, 255, .96); box-shadow: 0 8px 30px rgba(31, 41, 55, .09); backdrop-filter: blur(12px); }
.region-editor-toolbar .btn { min-height: 42px; }
.region-toolbar-divider { align-self: stretch; width: 1px; background: #dfe6ef; }
.region-draw-hint { margin-left: auto; color: var(--studio-navy-dark); font-size: .88rem; font-weight: 700; }
.region-editor-layout { display: grid; grid-template-columns: minmax(170px, 220px) minmax(380px, 1fr) minmax(280px, 340px); min-height: 690px; border: 1px solid #dfe6ef; border-radius: 20px; overflow: hidden; background: #fff; box-shadow: 0 12px 40px rgba(31, 41, 55, .08); }
.region-pages-panel, .region-properties-panel { min-width: 0; background: #fff; }
.region-pages-panel { border-right: 1px solid #e5eaf0; }
.region-properties-panel { border-left: 1px solid #e5eaf0; }
.region-panel-title { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1rem; border-bottom: 1px solid #e9edf2; color: var(--studio-navy-dark); }
.region-panel-title > div { min-width: 0; }
.region-panel-title strong, .region-panel-title span { display: block; }
.region-panel-title span { color: #64748b; font-size: .78rem; font-weight: 600; }
.region-page-thumbnails { display: grid; align-content: start; gap: .75rem; max-height: 720px; padding: .85rem; overflow: auto; }
.region-page-thumbnail { width: 100%; padding: .55rem; border: 2px solid #e1e7ef; border-radius: 12px; color: inherit; text-align: left; background: #f8fafc; transition: border-color .15s, box-shadow .15s, transform .15s; }
.region-page-thumbnail:hover { border-color: #aebdd0; transform: translateY(-1px); }
.region-page-thumbnail.is-active { border-color: var(--studio-navy); box-shadow: 0 0 0 3px rgba(66, 92, 129, .14); }
.region-thumbnail-heading { display: flex; justify-content: space-between; gap: .35rem; margin-bottom: .45rem; color: var(--studio-navy-dark); font-size: .79rem; line-height: 1.2; }
.region-thumbnail-heading > span { color: #64748b; font-size: .66rem; direction: ltr; }
.region-thumbnail-canvas { position: relative; display: block; width: 100%; line-height: 0; overflow: hidden; border-radius: 8px; background: #eef2f7; }
.region-thumbnail-canvas .template-preview-image { width: 100%; height: auto; max-height: none; object-fit: contain; border: 0; border-radius: 0; background: transparent; }
.region-thumbnail-overlays { position: absolute; inset: 0; display: block; pointer-events: none; }
.region-thumbnail-box { position: absolute; display: grid; place-items: center; overflow: hidden; border: 1px solid currentColor; color: #fff; font-size: 8px; font-weight: 900; line-height: 1; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.region-canvas-panel { min-width: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #eef2f7; }
.region-canvas-toolbar { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem 1rem; border-bottom: 1px solid #dfe6ef; background: #fff; }
.region-canvas-toolbar > div:first-child strong, .region-canvas-toolbar > div:first-child span { display: block; }
.region-canvas-toolbar > div:first-child strong { color: var(--studio-navy-dark); }
.region-canvas-toolbar > div:first-child span { color: #64748b; font-size: .76rem; }
.region-zoom-controls { display: inline-flex; align-items: center; border: 1px solid #d7dee8; border-radius: 10px; overflow: hidden; background: #fff; }
.region-zoom-controls button, .region-zoom-controls output { min-width: 42px; height: 38px; display: grid; place-items: center; padding: 0 .65rem; border: 0; border-right: 1px solid #d7dee8; color: var(--studio-navy-dark); background: #fff; font-size: .82rem; font-weight: 800; }
.region-zoom-controls button:last-child { border-right: 0; }
.region-zoom-controls button:hover { background: #f1f5f9; }
.region-canvas-viewport { position: relative; min-height: 560px; overflow: auto; display: block; padding: 24px; outline: none; overscroll-behavior: contain; touch-action: none; }
.region-canvas-viewport:focus-visible { box-shadow: inset 0 0 0 3px rgba(66, 92, 129, .3); }
.region-canvas-stage { position: relative; flex: none; margin-right: auto; margin-left: auto; overflow: hidden; background: #fff; box-shadow: 0 8px 32px rgba(15, 23, 42, .2); user-select: none; -webkit-user-select: none; }
.region-canvas-stage > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.region-canvas-overlays { position: absolute; inset: 0; }
.region-box { position: absolute; min-width: 1px; min-height: 1px; display: grid; place-items: center; border: 2px solid currentColor; color: #c2410c; background: rgba(234, 88, 12, .25); cursor: move; touch-action: none; }
.region-box[data-kind="link"] { color: #1d4ed8; background: rgba(37, 99, 235, .22); }
.region-box[data-kind="text"] { color: #047857; background: rgba(5, 150, 105, .22); }
.region-box.is-selected { z-index: 5; outline: 3px solid rgba(255, 255, 255, .9); box-shadow: 0 0 0 5px currentColor, 0 5px 15px rgba(15, 23, 42, .24); }
.region-box-label { max-width: 100%; padding: .22rem .35rem; overflow: hidden; color: #fff; font-size: clamp(9px, 1.3vw, 13px); font-weight: 900; line-height: 1.1; text-overflow: ellipsis; text-shadow: 0 1px 3px rgba(0, 0, 0, .72); white-space: nowrap; pointer-events: none; }
.region-resize-handle { position: absolute; z-index: 2; width: 18px; height: 18px; border: 2px solid currentColor; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(15, 23, 42, .24); touch-action: none; }
.region-resize-handle::after { content: ""; position: absolute; inset: -13px; border-radius: 50%; }
.region-resize-handle[data-handle="nw"] { left: 0; top: 0; transform: translate(-50%, -50%); cursor: nwse-resize; }
.region-resize-handle[data-handle="n"] { left: 50%; top: 0; transform: translate(-50%, -50%); cursor: ns-resize; }
.region-resize-handle[data-handle="ne"] { right: 0; top: 0; transform: translate(50%, -50%); cursor: nesw-resize; }
.region-resize-handle[data-handle="e"] { right: 0; top: 50%; transform: translate(50%, -50%); cursor: ew-resize; }
.region-resize-handle[data-handle="se"] { right: 0; bottom: 0; transform: translate(50%, 50%); cursor: nwse-resize; }
.region-resize-handle[data-handle="s"] { left: 50%; bottom: 0; transform: translate(-50%, 50%); cursor: ns-resize; }
.region-resize-handle[data-handle="sw"] { left: 0; bottom: 0; transform: translate(-50%, 50%); cursor: nesw-resize; }
.region-resize-handle[data-handle="w"] { left: 0; top: 50%; transform: translate(-50%, -50%); cursor: ew-resize; }
.region-box:not(.is-selected) .region-resize-handle { display: none; }
.region-canvas-stage.is-drawing { cursor: crosshair; }
.region-canvas-help { padding: .6rem 1rem; color: #64748b; font-size: .76rem; text-align: center; background: #fff; border-top: 1px solid #dfe6ef; }
.region-page-list-wrap { padding: .9rem 1rem; border-bottom: 1px solid #edf0f4; }
.region-page-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.region-list-button { min-height: 34px; max-width: 100%; padding: .3rem .55rem; overflow: hidden; border: 1px solid #cfd8e4; border-radius: 999px; color: var(--studio-navy-dark); background: #fff; font-size: .76rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.region-list-button.is-active { color: #fff; border-color: var(--studio-navy); background: var(--studio-navy); }
.region-properties-empty { padding: 2.5rem 1.25rem; color: #64748b; text-align: center; }
.region-properties-forms { max-height: 565px; overflow-y: auto; }
.region-properties-card { padding: 1rem; }
.region-properties-card[hidden], .region-style-controls[hidden] { display: none !important; }
.region-style-panel { padding: .85rem; border: 1px solid #dbe4ef; border-radius: 12px; background: #f8fafc; }
.region-style-panel .form-control-color { width: 100%; padding: .35rem; cursor: pointer; }
.region-form-errors { font-size: .86rem; }
.region-properties-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; padding: .85rem 1rem; border-top: 1px solid #e5eaf0; background: #fff; }
.region-sheet-close { display: none; width: 42px; height: 42px; border: 0; border-radius: 50%; color: #475569; background: #f1f5f9; font-size: 1.5rem; }
.region-mobile-save { display: none; }
.region-editor-form-error-pulse { animation: region-error-pulse .8s ease-out; }
@keyframes region-error-pulse { 50% { box-shadow: inset 0 0 0 3px rgba(220, 38, 38, .28); } }
.login-shell { min-height: calc(100vh - 6rem); display: grid; place-items: center; }
.login-card { width: min(100%, 520px); background: #fff; border-radius: 22px; overflow: hidden; box-shadow: 0 20px 60px rgba(31, 41, 55, .14); }
.login-header { padding: 2.2rem 1.5rem; color: #fff; text-align: center; background: linear-gradient(145deg, var(--studio-navy-dark), var(--studio-navy)); }
.login-header h1 { font-size: 1.55rem; font-weight: 800; margin: .8rem 0 .3rem; }
.login-header p { margin: 0; opacity: .85; }
.login-logo { width: 70px; height: 70px; object-fit: contain; padding: 7px; background: #fff; border-radius: 17px; }
.login-body { padding: 2rem; }
.login-body input { display: block; width: 100%; min-height: 50px; padding: .75rem; border: 1px solid #dce2ea; border-radius: 10px; }

@media (max-width: 767px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .studio-nav .navbar-brand span { display: none; }
  .table { min-width: 620px; }
}

@media (max-width: 1199px) {
  .region-editor-layout { grid-template-columns: 165px minmax(360px, 1fr) 300px; }
}

@media (max-width: 991px) {
  .region-editor-header { align-items: flex-start; }
  .region-editor-save-area { display: none; }
  .region-editor-layout { grid-template-columns: 1fr; min-height: 0; overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .region-pages-panel { order: 1; border: 1px solid #dfe6ef; border-radius: 16px; overflow: hidden; }
  .region-pages-panel .region-panel-title { display: none; }
  .region-page-thumbnails { display: flex; max-height: none; padding: .65rem; overflow-x: auto; scroll-snap-type: x proximity; }
  .region-page-thumbnail { flex: 0 0 132px; scroll-snap-align: start; }
  .region-canvas-panel { order: 2; margin-top: .75rem; border: 1px solid #dfe6ef; border-radius: 16px; overflow: hidden; }
  .region-canvas-viewport { min-height: 520px; }
  .region-properties-panel { position: fixed; z-index: 1050; left: 0; right: 0; bottom: 0; max-height: min(78vh, 720px); display: flex; flex-direction: column; border: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -16px 50px rgba(15, 23, 42, .24); transform: translateY(105%); transition: transform .22s ease; }
  .region-properties-panel.is-open { transform: translateY(0); }
  .region-properties-panel::before { content: ""; align-self: center; width: 48px; height: 5px; margin-top: .5rem; border-radius: 999px; background: #cbd5e1; }
  .region-sheet-close { display: grid; place-items: center; width: 44px; height: 44px; }
  .region-properties-panel button { min-height: 44px; }
  .region-list-button { min-height: 44px; }
  .region-properties-forms { max-height: none; overflow-y: auto; }
  .region-properties-card { padding-bottom: 1.5rem; }
  .region-page-list-wrap { flex: none; }
  .region-properties-empty { overflow-y: auto; }
  .region-properties-actions { flex: none; }
  .region-mobile-save { position: sticky; z-index: 25; bottom: .5rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: 1rem; padding: .65rem; border: 1px solid #dfe6ef; border-radius: 14px; background: rgba(255, 255, 255, .96); box-shadow: 0 8px 30px rgba(31, 41, 55, .13); backdrop-filter: blur(12px); }
  .region-mobile-save .btn { min-height: 46px; }
}

@media (max-width: 575px) {
  main.container { padding-left: .75rem; padding-right: .75rem; }
  .region-editor-toolbar { top: .35rem; flex-wrap: nowrap; overflow-x: auto; }
  .region-editor-toolbar .btn { flex: 0 0 auto; min-height: 44px; }
  .region-toolbar-divider, .region-draw-hint { display: none; }
  .region-canvas-toolbar { padding: .55rem .65rem; }
  .region-canvas-toolbar > div:first-child span { display: none; }
  .region-zoom-controls button, .region-zoom-controls output { min-width: 44px; height: 44px; padding: 0 .45rem; }
  .region-canvas-viewport { min-height: 58vh; padding: 16px; }
  .region-canvas-help { font-size: .68rem; }
  .region-resize-handle { width: 22px; height: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .region-page-thumbnail, .region-properties-panel { transition: none; }
}
