:root {
    --bg: #0f1115;
    --bg-2: #161922;
    --panel: #1c2030;
    --panel-2: #232839;
    --text: #e6e8ee;
    --muted: #8a92a6;
    --border: #2b2f44;
    --accent: #7c5cff;
    --accent-2: #6248e8;
    --ok: #34d399;
    --err: #f87171;
    --warn: #fbbf24;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }

/* ====== shell ====== */
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.app-sidebar {
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.app-sidebar__brand {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 20px 20px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.brand-mark {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1;
}

.brand-name {
    color: var(--text);
    font-weight: 600;
    font-size: 18px;
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}

.nav-item:hover { background: var(--panel); text-decoration: none; }

.nav-item.active { background: var(--accent); color: #fff; }

.nav-item--disabled {
    color: var(--muted);
    cursor: default;
}

.nav-ico {
    width: 18px;
    text-align: center;
    opacity: 0.85;
}

.nav-section {
    text-transform: uppercase;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.08em;
    padding: 18px 12px 6px 12px;
}

/* ====== main ====== */
.app-main { display: flex; flex-direction: column; min-width: 0; }

.app-header {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-2);
}

.app-header__title { color: var(--muted); font-size: 14px; }
.app-header__user { display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 500; }
.user-role { color: var(--muted); font-size: 13px; }

.app-content { padding: 28px 28px 60px 28px; max-width: 1200px; width: 100%; }

.page-title { font-size: 26px; font-weight: 600; margin: 0 0 8px 0; }
.page-lead { color: var(--muted); margin: 0 0 24px 0; }
.page-empty { padding: 40px; text-align: center; color: var(--muted); }

.toolbar { margin: 12px 0 16px 0; display: flex; gap: 8px; }

/* ====== cards ====== */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin: 8px 0 24px 0;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
}

.card--muted { opacity: 0.7; }

.card__label { color: var(--muted); font-size: 13px; }
.card__value { font-size: 32px; font-weight: 600; margin-top: 4px; }
.card__hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ====== buttons ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    transition: background 0.12s ease, transform 0.04s ease;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }

.btn-danger { background: transparent; border-color: var(--err); color: var(--err); }
.btn-danger:hover { background: rgba(248,113,113,0.1); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--panel-2); }

.btn-sm { padding: 5px 9px; font-size: 13px; }
.btn-block { width: 100%; }

/* ====== inputs ====== */
.input {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    width: 100%;
    font-family: inherit;
    outline: none;
}
.input:focus { border-color: var(--accent); }
.input-sm { padding: 6px 9px; font-size: 13px; }

select.input { appearance: none; cursor: pointer; }

label {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin: 14px 0 6px 0;
}

.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: 18px; height: 18px; }

/* ====== table ====== */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    background: var(--panel);
    border-radius: 10px;
    overflow: hidden;
}
.table th, .table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.table th { background: var(--bg-2); color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--panel-2); }

/* ====== forms / sections ====== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
}

.form-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
}

.form-section h3 {
    margin: 0 0 6px 0;
    font-size: 16px;
    font-weight: 600;
}

.form-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ====== alerts ====== */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin: 12px 0;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert-error { background: rgba(248,113,113,0.08); color: var(--err); border-color: rgba(248,113,113,0.3); }
.alert-ok { background: rgba(52,211,153,0.08); color: var(--ok); border-color: rgba(52,211,153,0.3); }
.alert-warn { background: rgba(251,191,36,0.1); color: #fbbf24; border-color: rgba(251,191,36,0.35); }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
}

.catalog-photo-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.catalog-photo-filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}
.catalog-photo-filter:hover { border-color: var(--accent); }
.catalog-photo-filter.active {
    border-color: var(--accent);
    background: rgba(124, 92, 255, 0.15);
    color: var(--accent);
}
.catalog-photo-filter .count {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(255,255,255,0.08);
}
.catalog-photo-col {
    width: 120px;
    min-width: 120px;
}
.catalog-photo-drop {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 96px;
    min-height: 72px;
    padding: 6px;
    border-radius: 10px;
    border: 2px dashed var(--border);
    background: var(--panel-2);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.catalog-photo-drop:hover,
.catalog-photo-drop.is-drag-over {
    border-color: var(--accent);
    background: rgba(124, 92, 255, 0.08);
}
.catalog-photo-drop.is-uploading {
    opacity: 0.55;
    pointer-events: none;
}
.catalog-photo-drop-hint {
    font-size: 11px;
    line-height: 1.3;
    text-align: center;
    color: var(--muted);
    padding: 4px;
    user-select: none;
}
.catalog-photo-thumb {
    width: 84px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--panel);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.catalog-table .row-photo-missing .catalog-photo-drop {
    border-color: rgba(248, 113, 113, 0.45);
}
.catalog-photo-drop-wrap {
    position: relative;
    display: inline-block;
}
.catalog-photo-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--err);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    z-index: 2;
}
.catalog-photo-remove:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: var(--err);
}
.row-archived {
    opacity: 0.72;
}
.badge-archived {
    margin-left: 6px;
    font-size: 11px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.06);
}
.badge-photo-none {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.35);
}
tr.row-photo-missing td { background: rgba(248, 113, 113, 0.04); }
tr.row-photo-pending td { background: rgba(251, 191, 36, 0.04); }

.callout {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    margin-top: 16px;
}
.callout h3 { margin: 0 0 8px 0; font-size: 15px; }
.callout ol { margin: 0; padding-left: 22px; color: var(--muted); }
.callout ol li { margin: 4px 0; }

/* ====== auth ====== */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.auth-card {
    width: min(420px, 100%);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px 28px 32px 28px;
}

.auth-card__brand {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 22px;
}

.auth-card h1 {
    font-size: 22px;
    margin: 0 0 4px 0;
}

.auth-subtitle {
    color: var(--muted);
    margin: 0 0 18px 0;
    font-size: 14px;
}

.auth-form {
    display: flex;
    flex-direction: column;
}

.auth-form label { margin-top: 12px; }
.auth-form input { margin-bottom: 0; }
.auth-form button { margin-top: 22px; }

.shop-shell {
    min-height: 100vh;
    display: grid;
    place-items: start center;
    padding: 24px;
}

.shop-card {
    width: min(680px, 100%);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
}

.shop-card h1 {
    margin: 0 0 4px 0;
    font-size: 24px;
}

/* ====== switch ====== */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
    position: absolute;
    inset: 0;
    background: var(--panel-2);
    border-radius: 20px;
    transition: 0.2s;
    cursor: pointer;
}
.switch span:before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: var(--text);
    border-radius: 50%;
    transition: 0.2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span:before { transform: translateX(16px); }

/* ====== KPI cards (customer card) ====== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin: 16px 0 22px;
}
.kpi-card {
    border-radius: 10px;
    padding: 18px 20px;
    color: #fff;
    box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 6px 24px rgba(0,0,0,0.25);
}
.kpi-card .kpi-title { opacity: 0.85; font-size: 14px; }
.kpi-card .kpi-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.kpi-green  { background: linear-gradient(135deg, #16a34a, #15803d); }
.kpi-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.kpi-blue   { background: linear-gradient(135deg, #2563eb, #1d4ed8); }

/* ====== rows ====== */
.row-clickable:hover td { background: rgba(124, 92, 255, 0.08); }
a.store-row-link { color: inherit; text-decoration: none; }
a.store-row-link:hover { text-decoration: underline; }
.import-from-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.import-from-row:last-child { border-bottom: none; }
.row-selected td { background: rgba(124, 92, 255, 0.18) !important; }
.sub-table th { background: var(--panel-2); }
.text-green { color: var(--ok); }
.text-red   { color: var(--err); }

/* ====== spinner overlay ====== */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 21, 0.62);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: grid;
    place-items: center;
}
.spinner-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px 30px;
    min-width: 220px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.55);
}
.spinner-text { color: var(--muted); font-size: 14px; text-align: center; }
.spinner {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 4px solid rgba(124, 92, 255, 0.18);
    border-top-color: var(--accent);
    animation: spin 0.9s linear infinite;
}
.inline-spinner {
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.25);
    border-top-color: #fff;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== pills (statuses) ====== */
.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.pill-ok      { background: rgba(52, 211, 153, 0.16); color: #34d399; border-color: rgba(52,211,153,0.35); }
.pill-warn    { background: rgba(251, 191, 36, 0.16); color: #fbbf24; border-color: rgba(251,191,36,0.35); }
.pill-err     { background: rgba(248, 113, 113, 0.16); color: #f87171; border-color: rgba(248,113,113,0.35); }
.pill-info    { background: rgba(124, 92, 255, 0.16); color: #b6a4ff; border-color: rgba(124,92,255,0.35); }
.pill-neutral { background: rgba(255,255,255,0.06); color: var(--muted); border-color: var(--border); }

/* ====== KPI extras ====== */
.kpi-row-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin: 16px 0 22px;
}
.kpi-pink   { background: linear-gradient(135deg, #ec4899, #db2777); }
.kpi-purple { background: linear-gradient(135deg, #7c5cff, #5b3dff); }

/* ====== tabs ====== */
.tabs {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--border);
    margin: 18px 0 14px;
}
.tabs button {
    background: transparent;
    color: var(--muted);
    border: none;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.tabs button:hover { color: var(--text); }
.tabs button.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

/* ====== form-grid 2-cols ====== */
.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 18px;
}
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 18px;
}
.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 18px;
}
@media (max-width: 900px) {
    .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ====== card panels ====== */
.card-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    margin: 14px 0;
}
.card-panel h3 { margin: 0 0 12px 0; }

/* ====== sortable table ====== */
.table-sortable th.sortable { user-select: none; transition: background 0.15s; }
.table-sortable th.sortable:hover { background: rgba(124, 92, 255, 0.08); }
.table-sortable th.sort-active { color: var(--accent); }

/* ====== category sort (admin) ====== */
.cat-sort-table .cat-sort-row { transition: background 0.12s; }
.cat-sort-table .cat-sort-row[draggable="true"] { cursor: grab; }
.cat-sort-table .cat-sort-row[draggable="true"]:active { cursor: grabbing; }
.cat-sort-table .cat-sort-over { background: rgba(124, 92, 255, 0.14) !important; outline: 1px dashed var(--accent); }
.cat-sort-grip-cell {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.cat-sort-grip {
    color: var(--muted);
    cursor: grab;
    user-select: none;
    font-size: 14px;
    letter-spacing: -2px;
    padding: 4px 6px;
    border-radius: 4px;
}
.cat-sort-grip:active { cursor: grabbing; background: rgba(124, 92, 255, 0.12); }
.cat-collapse-btn {
    min-width: 28px;
    padding: 2px 6px !important;
    font-size: 11px;
}
.cat-sort-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
}
.cat-sort-actions .btn-sm { min-width: 32px; padding: 4px 8px; }
.cat-link-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 88px;
}
.cat-link-id { font-size: 11px; line-height: 1; }

/* ====== заказы (список с составом) ====== */
.order-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.order-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    overflow: hidden;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.order-card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
}
.order-card-head:hover {
    background: var(--panel-2);
}
.order-card-toggle {
    flex-shrink: 0;
    min-width: 32px;
    height: 32px;
    padding: 0 !important;
    font-size: 12px;
    margin-top: 2px;
    border: 1px solid var(--border) !important;
    border-radius: 8px;
    color: var(--muted);
}
.order-card-toggle:hover {
    color: var(--text);
    border-color: var(--accent) !important;
    background: rgba(124, 92, 255, 0.12) !important;
}
.order-card-summary {
    flex: 1;
    min-width: 0;
}
.order-card-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}
.order-card-title .order-card-num {
    font-weight: 700;
    letter-spacing: 0.02em;
}
.order-card-title .order-card-when {
    color: var(--muted);
    font-weight: 500;
    font-size: 13px;
}
.order-card-title .order-card-sum {
    margin-left: auto;
    font-size: 16px;
    font-weight: 700;
    color: var(--ok);
}
.order-card-meta {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}
.order-card-meta .order-card-sep {
    color: var(--muted);
}
.order-card-meta .order-card-store {
    color: var(--muted);
}
.order-card-address {
    margin-top: 4px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.45;
}
.order-card-preview {
    margin-top: 8px;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.order-card-preview-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 4px;
}
.order-card-actions {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    align-items: flex-start;
    max-width: 260px;
}
.order-card-body {
    border-top: 1px solid var(--border);
    padding: 12px 16px 14px 60px;
    background: var(--bg-2);
}
.order-lines {
    list-style: none;
    margin: 0;
    padding: 0;
}
.order-lines li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: baseline;
    gap: 12px 16px;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.order-lines li:last-child { border-bottom: none; }
.order-line-name {
    color: var(--text);
    font-weight: 500;
    line-height: 1.35;
}
.order-line-qty {
    color: var(--muted);
    white-space: nowrap;
    font-size: 13px;
}
.order-line-sum {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    min-width: 80px;
    text-align: right;
}
.order-card-totals {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    text-align: right;
    color: var(--muted);
    line-height: 1.6;
}
.order-card-totals strong {
    color: var(--text);
    font-size: 16px;
}
.order-card-totals .order-card-bonus {
    color: var(--ok);
}
.order-card-extra {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: 12px;
    color: var(--muted);
    line-height: 1.55;
}
@media (max-width: 720px) {
    .order-card-head { flex-wrap: wrap; }
    .order-card-title .order-card-sum {
        margin-left: 0;
        width: 100%;
    }
    .order-card-actions {
        width: 100%;
        max-width: none;
        justify-content: flex-start;
        padding-left: 44px;
    }
    .order-card-body { padding-left: 16px; }
    .order-lines li {
        grid-template-columns: 1fr;
        gap: 2px;
    }
    .order-line-sum { text-align: left; }
}

/* ====== предпросмотр баннера витрины (как в Telegram) ====== */
.banner-editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 24px;
    align-items: start;
    margin-top: 24px;
}
@media (max-width: 960px) {
    .banner-editor-layout { grid-template-columns: 1fr; }
}
.tg-preview-wrap {
    position: sticky;
    top: 16px;
}
.tg-preview-wrap h4 {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--muted);
    font-weight: 600;
}
.tg-preview-phone {
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    background: #f3f4f6;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}
.tg-preview-topbar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 700;
    font-size: 16px;
    color: #111827;
}
.tg-preview-body {
    padding: 10px 0 16px;
    background: #f3f4f6;
    min-height: 200px;
}
.tg-preview-body .banner-carousel {
    --banner-gap: 10px;
    --banner-slide-w: 94%;
    --banner-max-w: 400px;
    margin: 0 12px 8px;
}
.tg-preview-body .banner-track {
    display: flex;
    gap: var(--banner-gap);
    overflow-x: auto;
    padding: 4px 2px 10px;
}
.tg-preview-body .banner-slide {
    flex: 0 0 var(--banner-slide-w, 94%);
    width: var(--banner-slide-w, 94%);
    max-width: var(--banner-max-w);
    aspect-ratio: 2 / 1;
    min-height: 168px;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #111827;
    color: #fff;
    text-align: left;
}
.tg-preview-body .banner-slide::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,.8), transparent 65%);
    pointer-events: none;
}
.tg-preview-body .banner-slide img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.tg-preview-body .banner-slide-content {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 4px;
}
.tg-preview-body .banner-badge {
    display: inline-block;
    background: #dc2626;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: 8px;
    width: fit-content;
}
.tg-preview-body .banner-title {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 6px;
}
.tg-preview-body .banner-sub {
    font-size: 13px;
    opacity: 0.92;
    margin-bottom: 12px;
    line-height: 1.35;
}
.tg-preview-body .banner-cta {
    display: inline-block;
    background: #fff;
    color: #111;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 700;
    font-size: 14px;
    width: fit-content;
}
.tg-preview-hint {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    margin-top: 8px;
}
.banner-store-pick {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  background: #f9fafb;
}
.banner-store-pick__item {
  margin: 0;
  font-size: 14px;
}

.banner-thumb {
    width: 56px;
    height: 36px;
    object-fit: cover;
    border-radius: 6px;
    background: #e5e7eb;
}
.banner-editor-thumb {
    display: block;
    width: 100%;
    max-width: 320px;
    max-height: 140px;
    object-fit: cover;
    border-radius: 12px;
    margin: 8px 0;
    background: #e5e7eb;
}
.banner-upload-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 6px;
}
.banner-upload-row .input[type=file] {
    max-width: 280px;
}
.banner-preview-url {
    font-size: 12px;
    color: var(--muted);
    word-break: break-all;
    margin-top: 6px;
}

/* ====== store scope (all / one / many) ====== */
.store-scope-modes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-bottom: 4px;
}
.store-scope-mode {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}
.store-scope-pick {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding: 10px 12px;
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel-2, rgba(255, 255, 255, 0.03));
}
.store-scope-pick__item {
    margin: 0;
    font-size: 14px;
}

/* ====== integration settings ====== */
.integration-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}
.integration-block {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.integration-block--wide {
    grid-column: 1 / -1;
}
.integration-block__head {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 4px;
}
.integration-block__head h2 {
    margin: 0 0 4px;
    font-size: 18px;
}
.integration-block__icon {
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
}
.integration-notify-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
@media (max-width: 960px) {
    .integration-grid,
    .integration-notify-grid {
        grid-template-columns: 1fr;
    }
}

.delivery-zones-table th,
.delivery-zones-table td {
    padding: 8px 10px;
    vertical-align: middle;
}
.delivery-zones-table .input {
    margin: 0;
    min-width: 100px;
}
.delivery-zones-editor {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.delivery-zones-editor--muted {
    opacity: 0.85;
}
.delivery-zones-editor--muted .delivery-zones-table {
    pointer-events: none;
}
