/* ── TOKENS ──────────────────────────────────────────────────────────────────── */
:root {
  --bg:         #0c0e17;
  --surface:    #141720;
  --s2:         #1c1f2e;
  --s3:         #22263a;
  --border:     #252836;
  --border2:    #303450;
  --text:       #e2e4ef;
  --muted:      #7b7f9a;
  --muted2:     #5a5e7a;
  --accent:     #6c63ff;
  --accent-dim: rgba(108,99,255,.15);
  --input-bg:   #0f1119;
  --red:        #ff5a65;
  --green:      #3ecf8e;
  --radius:     10px;
  --radius-lg:  16px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; font-size: 14px; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }

.header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; flex-wrap: wrap; }
.header-title { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.header-title h1 { font-size: 16px; font-weight: 700; letter-spacing: -.3px; }
.header-icon { font-size: 20px; }
.header-badge { font-size: 11px; background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(108,99,255,.3); padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.url-fetch-row { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.url-fetch-row input { flex: 1; min-width: 0; background: var(--input-bg); border: 1px solid var(--border2); border-radius: var(--radius); color: var(--text); padding: 8px 12px; outline: none; transition: border-color .15s; }
.url-fetch-row input:focus { border-color: var(--accent); }
.btn-fetch, .btn-admin { background: var(--s3); border: 1px solid var(--border2); color: var(--text); padding: 8px 14px; border-radius: var(--radius); white-space: nowrap; transition: background .15s, border-color .15s; }
.btn-fetch:hover { background: var(--s2); border-color: var(--accent); }
.btn-admin { background: var(--accent-dim); border-color: rgba(108,99,255,.4); color: var(--accent); font-weight: 600; }
.btn-admin:hover { background: rgba(108,99,255,.25); }

.app-layout { display: grid; grid-template-columns: 280px 1fr; min-height: calc(100vh - 57px); }
.controls-panel { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.control-section { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.control-section:last-child { border-bottom: none; }
.section-label { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.control-section input[type="text"], .control-section input[type="url"], .control-section textarea { background: var(--input-bg); border: 1px solid var(--border2); border-radius: var(--radius); color: var(--text); padding: 8px 10px; outline: none; resize: vertical; transition: border-color .15s; width: 100%; }
.control-section input:focus, .control-section textarea:focus { border-color: var(--accent); }
.control-section textarea { min-height: 70px; }

.brand-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.brand-card { background: var(--s2); border: 1px solid var(--border2); border-radius: var(--radius); padding: 10px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; transition: border-color .15s, background .15s; text-align: center; }
.brand-card:hover { border-color: var(--accent); background: var(--s3); }
.brand-card.active { border-color: var(--accent); background: var(--accent-dim); }
.brand-card-logo { height: 30px; display: flex; align-items: center; justify-content: center; }
.brand-card-logo img { max-height: 28px; max-width: 110px; object-fit: contain; }
.brand-card-name { font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .4px; }

.color-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.color-row input[type="color"] { width: 32px; height: 28px; border: 1px solid var(--border2); border-radius: 6px; background: none; cursor: pointer; padding: 2px; }

.btn-row, .corner-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.corner-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.layout-btn, .ver-btn, .corner-btn { background: var(--s2); border: 1px solid var(--border2); color: var(--muted); padding: 6px 10px; border-radius: 7px; font-size: 11px; font-weight: 600; transition: all .15s; text-align: center; }
.layout-btn:hover, .ver-btn:hover, .corner-btn:hover { border-color: var(--accent); color: var(--text); }
.layout-btn.active, .ver-btn.active, .corner-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.layout-btn { flex: 1; }

.search-row { display: flex; gap: 6px; }
.search-row input { flex: 1; background: var(--input-bg); border: 1px solid var(--border2); border-radius: var(--radius); color: var(--text); padding: 7px 10px; outline: none; transition: border-color .15s; }
.search-row input:focus { border-color: var(--accent); }
.search-row button { background: var(--s3); border: 1px solid var(--border2); color: var(--text); padding: 7px 12px; border-radius: var(--radius); transition: all .15s; }
.search-row button:hover { border-color: var(--accent); }

.img-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; max-height: 240px; overflow-y: auto; }
.img-thumb { aspect-ratio: 16/9; border-radius: 7px; overflow: hidden; cursor: pointer; border: 2px solid transparent; position: relative; background: var(--s3); }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-thumb.selected { border-color: var(--accent); }
.img-thumb .shimmer { position: absolute; inset: 0; background: linear-gradient(90deg, var(--s3) 25%, var(--s2) 50%, var(--s3) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
.img-none-btn { aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; border-radius: 7px; cursor: pointer; border: 2px solid var(--border2); color: var(--muted2); font-size: 18px; transition: all .15s; }
.img-none-btn:hover { border-color: var(--accent); }
.img-none-btn.selected { border-color: var(--accent); background: var(--accent-dim); }
.img-status { font-size: 11px; color: var(--muted); min-height: 14px; }

.preview-panel { padding: 24px; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }
.preview-area { display: flex; flex-direction: column; gap: 10px; }
.preview-scaler { width: 100%; position: relative; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }
.preview-scaler canvas { transform-origin: top left; display: block; image-rendering: high-quality; }
.preview-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

.social-mockup { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; max-width: 500px; }
.url-bar { background: var(--s3); padding: 8px 14px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soc-img-area { width: 100%; background: var(--s2); overflow: hidden; }
.soc-img-area img { width: 100%; display: block; }
.soc-card-text { padding: 12px 14px; }
.soc-domain { font-size: 11px; color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.soc-title  { font-size: 14px; font-weight: 600; margin-bottom: 3px; line-height: 1.3; }
.soc-desc   { font-size: 12px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.action-row { display: flex; gap: 10px; flex-wrap: wrap; }
.dl-btn, .meta-btn { padding: 11px 20px; border-radius: var(--radius); font-weight: 600; font-size: 14px; border: none; transition: all .15s; }
.dl-btn { background: var(--accent); color: #fff; flex: 1; }
.dl-btn:hover { background: #5a52e0; }
.dl-btn:disabled { opacity: .6; cursor: wait; }
.meta-btn { background: var(--s3); border: 1px solid var(--border2); color: var(--text); }
.meta-btn:hover { border-color: var(--accent); }

.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--s3); border: 1px solid var(--border2); color: var(--text); padding: 10px 20px; border-radius: 30px; font-size: 13px; font-weight: 500; opacity: 0; transition: transform .25s, opacity .25s; z-index: 9999; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.admin-modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(4px); }
.admin-modal.open { display: flex; }
.admin-dialog { background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-lg); width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 40px); display: flex; flex-direction: column; overflow: hidden; }
.admin-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 24px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.admin-header h2 { font-size: 17px; font-weight: 700; }
.admin-header p  { font-size: 12px; color: var(--muted); margin-top: 3px; }
.admin-close { background: var(--s3); border: 1px solid var(--border2); color: var(--muted); width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; transition: all .15s; flex-shrink: 0; }
.admin-close:hover { color: var(--red); border-color: var(--red); }
.admin-body { display: flex; flex: 1; overflow: hidden; }
.admin-nav { width: 180px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 12px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.admin-tab { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--muted); transition: background .12s, color .12s; position: relative; }
.admin-tab:hover { background: var(--s2); color: var(--text); }
.admin-tab.active { background: var(--accent-dim); color: var(--accent); }
.admin-tab-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.admin-tab-check { margin-left: auto; color: var(--green); font-size: 10px; }
.add-brand-row { margin-top: 6px; border-top: 1px solid var(--border); padding-top: 8px; color: var(--accent); font-weight: 600; }
.admin-panels { flex: 1; overflow-y: auto; padding: 20px 24px; }
.admin-brand-panel { display: none; }
.admin-brand-panel.active { display: block; }

.abp-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.abp-color-block { width: 56px; height: 56px; border-radius: var(--radius); flex-shrink: 0; }
.abp-info h3 { font-size: 16px; font-weight: 700; }
.abp-info p  { font-size: 12px; color: var(--muted); margin-top: 2px; }
.abp-swatches { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.swatch-chip { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); background: var(--s2); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px 3px 6px; }
.swatch-dot { width: 12px; height: 12px; border-radius: 50%; }

.upload-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.upload-section h4 { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.upload-section p  { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.upload-zone { border: 2px dashed var(--border2); border-radius: var(--radius); padding: 20px 10px; text-align: center; cursor: pointer; position: relative; transition: border-color .15s, background .15s; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--accent); background: var(--accent-dim); }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.uz-icon { font-size: 22px; }
.uz-text { font-size: 12px; font-weight: 600; color: var(--text); }
.uz-hint { font-size: 10px; color: var(--muted); }

.logo-preview { border-radius: var(--radius); padding: 16px; display: flex; align-items: center; justify-content: center; position: relative; background: var(--s2); min-height: 90px; }
.logo-preview.dark-bg { background: #111; }
.logo-preview img { max-height: 60px; max-width: 100%; object-fit: contain; }
.template-preview { border-radius: var(--radius); overflow: hidden; position: relative; border: 1px solid var(--border2); }
.template-preview img { width: 100%; display: block; }
.remove-btn { position: absolute; top: 6px; right: 6px; background: rgba(255,90,101,.15); border: 1px solid rgba(255,90,101,.3); color: var(--red); width: 22px; height: 22px; border-radius: 50%; font-size: 10px; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.remove-btn:hover { background: var(--red); color: #fff; }

.template-notes { margin-top: 10px; }
.template-notes label { font-size: 11px; color: var(--muted); display: block; margin-bottom: 5px; }
.template-notes textarea { width: 100%; background: var(--input-bg); border: 1px solid var(--border2); border-radius: 8px; color: var(--text); padding: 8px; font-size: 12px; resize: vertical; min-height: 60px; outline: none; transition: border-color .15s; }
.template-notes textarea:focus { border-color: var(--accent); }

.brand-del-btn { background: transparent; border: 1px solid rgba(255,90,101,.3); color: var(--red); padding: 8px 16px; border-radius: var(--radius); font-size: 13px; transition: all .15s; }
.brand-del-btn:hover { background: rgba(255,90,101,.1); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label { font-size: 11px; font-weight: 600; color: var(--muted); }
.form-field input[type="text"], .form-field select { background: var(--input-bg); border: 1px solid var(--border2); border-radius: 8px; color: var(--text); padding: 8px 10px; outline: none; transition: border-color .15s; }
.form-field input:focus, .form-field select:focus { border-color: var(--accent); }
.color-input-row { display: flex; gap: 6px; align-items: center; }
.color-input-row input[type="color"] { width: 34px; height: 32px; border: 1px solid var(--border2); border-radius: 6px; background: none; cursor: pointer; padding: 2px; flex-shrink: 0; }
.color-input-row input[type="text"] { flex: 1; background: var(--input-bg); border: 1px solid var(--border2); border-radius: 8px; color: var(--text); padding: 6px 8px; outline: none; font-family: monospace; font-size: 12px; }

.nb-preview { margin-bottom: 16px; }
.nb-swatch { width: 100%; height: 40px; border-radius: var(--radius); transition: background .3s; }
.save-brand-btn { background: var(--accent); border: none; color: #fff; padding: 10px 20px; border-radius: var(--radius); font-weight: 600; transition: background .15s; }
.save-brand-btn:hover { background: #5a52e0; }

.cb-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cb-row:last-child { border-bottom: none; }

.r2-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 600; letter-spacing: .4px; padding: 2px 8px; border-radius: 12px; background: rgba(62,207,142,.12); color: var(--green); border: 1px solid rgba(62,207,142,.3); }

.loading-overlay { position: absolute; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; border-radius: var(--radius-lg); font-size: 13px; color: var(--muted); z-index: 10; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }
