:root {
  --bg: #0d0f14;
  --surface: #161921;
  --surface2: #1e2130;
  --border: #272c3f;
  --border2: #353c55;
  --accent: #5d6ef7;
  --accent-h: #6e7ff8;
  --text: #dde2f0;
  --muted: #6b7494;
  --success: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --r: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────── */
header {
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.logo svg { flex-shrink: 0; }
.logo span { color: var(--accent); }
.header-sub { color: var(--muted); font-size: 12px; }
.header-admin {
  margin-left: auto;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  transition: color .15s, border-color .15s;
}
.header-admin:hover { color: var(--text); border-color: var(--accent); }

/* ── Layout ──────────────────────────────────── */
main {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 48px);
  overflow: hidden;
}

/* ── Left Panel ──────────────────────────────── */
.panel-left {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-scroll::-webkit-scrollbar { width: 5px; }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.panel-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-sessions { display: flex; gap: 6px; }

/* ── Section Labels ──────────────────────────── */
.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ── Drop Zone ───────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--r);
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--surface2);
  user-select: none;
}

.drop-zone:hover, .drop-zone.over {
  border-color: var(--accent);
  background: rgba(93,110,247,.07);
}

.drop-icon { font-size: 26px; color: var(--accent); margin-bottom: 6px; line-height: 1; }
.drop-text { font-size: 13px; line-height: 1.5; }
.drop-text small { color: var(--muted); font-size: 11px; display: block; margin-top: 2px; }

/* ── Image Cards ─────────────────────────────── */
.image-list { display: flex; flex-direction: column; gap: 7px; }

.img-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: border-color .15s;
}
.img-card:hover { border-color: var(--border2); }
.img-card-error { border-color: #f97316 !important; box-shadow: 0 0 0 2px rgba(249,115,22,.25); }
.img-card-error:hover { border-color: #fb923c !important; }

.card-top { display: flex; align-items: center; gap: 9px; padding: 9px 9px 0 9px; }

.card-thumb {
  width: 44px; height: 44px;
  object-fit: contain;
  border-radius: 5px;
  background: #111420;
  flex-shrink: 0;
}

.card-meta { flex: 1; min-width: 0; }
.card-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-dims { font-size: 10px; color: var(--muted); margin-top: 2px; }

.btn-del {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 4px; border-radius: 4px; font-size: 15px; line-height: 1;
  transition: color .15s, background .15s; flex-shrink: 0;
}
.btn-del:hover { color: var(--danger); background: rgba(239,68,68,.1); }

.card-body { padding: 8px 9px 9px 9px; display: flex; flex-direction: column; gap: 6px; }

.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-label { color: var(--muted); flex-shrink: 0; }

.toggle-label {
  display: flex; align-items: center; gap: 5px;
  color: var(--muted); cursor: pointer; user-select: none; font-size: 11px;
}

.size-fields { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.size-unit { color: var(--muted); font-size: 11px; }

/* ── Inputs ──────────────────────────────────── */
input[type=number], input[type=text], select {
  background: var(--bg);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 12px;
  font-family: inherit;
  transition: border-color .15s;
  width: 100%;
  -moz-appearance: textfield;
}
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
input:focus, select:focus { outline: none; border-color: var(--accent); }

.input-qty  { width: 58px !important; }
.input-size { width: 58px !important; }

input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }

/* ── Settings ────────────────────────────────── */
.settings-grid { display: flex; flex-direction: column; gap: 7px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { color: var(--muted); font-size: 11px; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  border: none; border-radius: var(--r); padding: 9px 16px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: transform .12s, opacity .12s, background .12s;
  font-family: inherit; width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .38; cursor: not-allowed; transform: none; }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover { background: #252a3a; }

.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border2); }
.btn-outline:hover { background: var(--surface2); }

.btn-sm { padding: 6px 12px !important; font-size: 12px !important; flex: 1; }

/* ── Right Panel ─────────────────────────────── */
.panel-right { display: flex; flex-direction: column; padding: 14px; gap: 10px; overflow: hidden; }

.preview-wrap {
  flex: 1;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface2);
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 0;
}

.preview-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.preview-wrap::-webkit-scrollbar-track { background: transparent; }
.preview-wrap::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.preview-empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--muted); pointer-events: none;
}
.preview-empty-icon { font-size: 52px; opacity: .2; }
.preview-empty p { font-size: 13px; }

#preview-img { width: 100%; display: block; border-radius: 5px; }

/* ── Stats ───────────────────────────────────── */
.stats-bar { display: grid; grid-template-columns: repeat(5,1fr); gap: 8px; }

.stat-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 9px 11px;
}
.stat-label { font-size: 9px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.stat-value { font-size: 17px; font-weight: 700; margin-top: 3px; }

/* ── Actions ─────────────────────────────────── */
.actions-row { display: flex; gap: 8px; }
.actions-row .btn { flex: 1; }

/* ── Modal Overlay ───────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  animation: fade-in .15s ease;
}
.modal-overlay.hidden { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 28px 28px 24px;
  width: 360px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slide-up .18s ease;
}

@keyframes slide-up { from { transform: translateY(12px); opacity:0; } to { transform: none; opacity:1; } }

.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; text-align: center; }
.modal-sub { color: var(--muted); font-size: 13px; text-align: center; margin-top: 4px; }

/* ── Payment Modal ───────────────────────────── */
.pay-amount {
  font-size: 28px; font-weight: 800; color: var(--accent);
  text-align: center; margin: 10px 0 18px;
}

.qr-wrap {
  background: #fff; border-radius: 10px; padding: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}

#pay-qr-img { width: 200px; height: 200px; display: block; }

.pay-code-row { display: flex; gap: 6px; margin-bottom: 14px; }

.pay-code-row input {
  flex: 1; font-size: 10px; font-family: monospace;
  padding: 6px 8px; background: var(--bg); color: var(--muted);
  border: 1px solid var(--border2); border-radius: 6px; width: auto;
}

.btn-copy {
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text); border-radius: 6px; padding: 0 12px;
  font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit;
  white-space: nowrap; transition: background .15s;
}
.btn-copy:hover { background: #2a2e40; }
.btn-copy.copied { color: var(--success); border-color: var(--success); }

.pay-waiting {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); font-size: 13px; margin-bottom: 6px;
}

.pay-timer { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 12px; }

.pay-icon {
  font-size: 40px; text-align: center; margin: 8px 0 16px;
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; font-size: 28px; font-weight: 700;
}
.pay-icon-ok { background: rgba(34,197,94,.15); color: var(--success); }
.pay-icon-err { background: rgba(239,68,68,.12); color: var(--danger); }

/* ── Jobs Modal ──────────────────────────────── */
.modal-jobs { width: 420px; padding-bottom: 16px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header .modal-title { text-align: left; margin: 0; }

.btn-close-modal {
  background: none; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer; line-height: 1; padding: 2px;
  border-radius: 4px; transition: color .15s;
}
.btn-close-modal:hover { color: var(--text); }

.jobs-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }

.job-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 12px;
  display: flex; align-items: center; gap: 12px;
}

.job-info { flex: 1; min-width: 0; }
.job-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

.job-actions { display: flex; gap: 5px; flex-shrink: 0; }

.btn-job-load {
  background: var(--accent); color: #fff; border: none;
  border-radius: 5px; padding: 5px 12px; font-size: 11px;
  font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background .12s;
}
.btn-job-load:hover { background: var(--accent-h); }

.btn-job-del {
  background: none; border: 1px solid var(--border2);
  color: var(--muted); border-radius: 5px; padding: 5px 8px;
  font-size: 12px; cursor: pointer; transition: color .12s, border-color .12s;
}
.btn-job-del:hover { color: var(--danger); border-color: var(--danger); }

.jobs-empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* ── Spinner ─────────────────────────────────── */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
.spinner-sm {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid var(--border2); border-top-color: var(--muted);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────── */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r); padding: 11px 16px;
  font-size: 13px; max-width: 300px; z-index: 999;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  transition: opacity .25s, transform .25s;
}
.toast.hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
.toast.warn    { border-color: var(--warn);    color: var(--warn); }

/* ── Download loading overlay ────────────────── */
.dl-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(13,15,20,.85); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .2s;
}
.dl-overlay.hidden { opacity: 0; pointer-events: none; }
.dl-box {
  background: #161921; border: 1px solid #272c3f; border-radius: 14px;
  padding: 36px 48px; text-align: center; max-width: 340px;
}
.dl-spinner {
  width: 44px; height: 44px; border: 3px solid #272c3f;
  border-top-color: #5d6ef7; border-radius: 50%;
  animation: spin .8s linear infinite; margin: 0 auto 18px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.dl-title { font-size: 15px; font-weight: 600; color: #dde2f0; margin-bottom: 8px; }
.dl-sub   { font-size: 12px; color: #6b7494; line-height: 1.5; }

/* ── Hidden utility ──────────────────────────── */
.hidden { display: none !important; }

/* ── Partners Strip ──────────────────────────── */
.partners-strip {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  flex-shrink: 0;
}

.partners-hdr {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.partners-cards {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.partners-cards::-webkit-scrollbar { height: 4px; }
.partners-cards::-webkit-scrollbar-track { background: transparent; }
.partners-cards::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.partner-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  min-width: 190px;
  max-width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color .15s, transform .12s;
}
.partner-card:hover { border-color: var(--border2); transform: translateY(-1px); }

.partner-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.partner-logo {
  width: 40px; height: 40px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  flex-shrink: 0;
}

.partner-logo-ph {
  width: 40px; height: 40px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.partner-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.partner-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.partner-links {
  display: flex;
  gap: 5px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.partner-link {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 5px;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.partner-link:hover { opacity: .82; transform: translateY(-1px); }

.partner-link-web {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
}

.partner-link-wa {
  background: rgba(37,211,102,.12);
  border: 1px solid rgba(37,211,102,.25);
  color: #25d366;
}

/* ── Mobile ──────────────────────────────────── */
@media (max-width: 768px) {
  html, body {
    height: auto;
    overflow-y: auto;
    overflow-x: hidden;
  }

  header {
    padding: 0 14px;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .header-sub { display: none; }

  main {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .panel-left {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .panel-scroll {
    overflow: visible;
    max-height: none;
  }

  .panel-right {
    overflow: visible;
  }

  .preview-wrap {
    flex: none;
    height: 56vw;
    min-height: 220px;
    max-height: 360px;
  }

  .stats-bar { grid-template-columns: repeat(3, 1fr); }
  .stat-value { font-size: 15px; }

  .actions-row { flex-direction: column; }

  .partners-cards {
    flex-direction: column;
    overflow-x: hidden;
  }
  .partner-card {
    min-width: unset;
    max-width: unset;
    width: 100%;
  }

  .modal {
    width: calc(100% - 24px);
    padding: 22px 18px 18px;
    max-height: 90vh;
    border-radius: 12px;
  }
  .modal-jobs { width: calc(100% - 24px); }

  .toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

@media (max-width: 480px) {
  header { padding: 0 12px; gap: 8px; }
  .logo { font-size: 15px; }
  .logo svg { width: 18px; height: 18px; }

  .panel-scroll { padding: 12px; gap: 12px; }
  .panel-right  { padding: 10px; gap: 8px; }

  .stats-bar { grid-template-columns: repeat(2, 1fr); }

  .preview-wrap {
    height: 52vw;
    min-height: 190px;
  }

  .drop-zone { padding: 14px 10px; }
  .drop-icon { font-size: 22px; }
}
