:root {
  --orange: #EE4D2D;
  --shopee: #EE4D2D;
  --orange-dark: #d73e1f;
  --orange-light: #fff0ee;
  --text: #222;
  --text-muted: #666;
  --border: #e0e0e0;
  --bg: #f5f5f5;
  --white: #fff;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ---- Topbar ---- */
.topbar {
  background: var(--orange);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.brand {
  color: var(--white);
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -.3px;
}
.topbar-nav { display: flex; align-items: center; gap: 12px; }
.auth-status { font-size: 12px; font-weight: 600; }
.auth-ok { color: rgba(255,255,255,.9); }
.btn-auth {
  background: rgba(255,255,255,.2);
  color: var(--white);
  border: 1px solid rgba(255,255,255,.4);
  padding: 6px 14px;
  font-size: 13px;
}
.btn-auth:hover { background: rgba(255,255,255,.3); }

/* ---- Container ---- */
.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

/* ---- Import form ---- */
.import-card h2 { margin-bottom: 12px; }
.import-form {
  display: flex;
  gap: 10px;
}
.input-url {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
.input-url:focus { border-color: var(--orange); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--orange); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--orange-dark); }
.btn-shopee { background: var(--orange); color: var(--white); width: 100%; font-size: 15px; padding: 12px; }
.btn-shopee:hover:not(:disabled) { background: var(--orange-dark); }
.btn-outline {
  background: transparent;
  color: var(--orange);
  border: 1px solid var(--orange);
  padding: 5px 12px;
  font-size: 13px;
}
.btn-outline:hover { background: var(--orange-light); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #c0392b; color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #a93226; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--orange-light); }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 440px; width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.modal-box p { color: var(--text-muted); margin: .6rem 0 1.4rem; line-height: 1.5; }
.modal-actions { display: flex; flex-direction: column; gap: .6rem; }
.modal-actions .btn { text-align: center; }

/* ---- Alerts ---- */
.alert {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
}
.alert-error { background: #fff0ee; color: #c0392b; border: 1px solid #f5c6cb; }
.alert-success { background: #f0faf0; color: #256029; border: 1px solid #c3e6cb; }
.alert-warn { background: #fffbe6; color: #7d5a00; border: 1px solid #ffe58f; }
.session-warn { color: #ffe082; font-size: 12px; font-weight: 600; }

/* ---- Section header ---- */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.section-header h2 { margin-bottom: 0; }
.badge-count {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
}

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

.td-thumb { width: 52px; }
.thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.thumb-empty {
  background: var(--bg);
  border: 1px dashed var(--border);
}
.td-title a { color: var(--text); text-decoration: none; font-weight: 500; }
.td-title a:hover { color: var(--orange); }
.td-date { color: var(--text-muted); white-space: nowrap; }

/* ---- Status badges ---- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.badge-draft     { background: #f0f0f0; color: #555; }
.badge-published { background: #e6f9ed; color: #1a7f37; }
.badge-failed    { background: #fff0ee; color: #c0392b; }

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

/* ---- Breadcrumb ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.breadcrumb a { color: var(--orange); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---- Detail layout ---- */
.detail-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 768px) {
  .detail-layout { grid-template-columns: 1fr; }
}

.form-col { display: flex; flex-direction: column; gap: 20px; }
.gallery-col { position: sticky; top: 20px; }

/* ---- Gallery ---- */
.gallery-card { padding: 16px; }
.gallery-main {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 6px;
  background: var(--bg);
  margin-bottom: 10px;
}
.gallery-main-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-thumbs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.gallery-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .15s;
  opacity: .75;
}
.gallery-thumb:hover, .gallery-thumb.active {
  border-color: var(--orange);
  opacity: 1;
}
.gallery-empty {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 10px;
}
.gallery-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}
.meta-shop { color: var(--text-muted); }
.meta-link { color: var(--orange); text-decoration: none; margin-left: auto; }
.meta-link:hover { text-decoration: underline; }

/* ---- Form ---- */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
  width: 100%;
}
.input:focus { border-color: var(--orange); }
.textarea { resize: vertical; min-height: 120px; }
.char-hint { font-size: 11px; color: var(--text-muted); }
.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 4px; }

/* ---- Publish card ---- */
.publish-card { border: 1px solid var(--orange-light); }
.publish-note { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.publish-warn { color: #856404; }
.publish-warn a { color: var(--orange); }
.publish-error { margin-top: 10px; font-size: 12px; color: #c0392b; word-break: break-word; }

/* ---- Gallery delete ---- */
.gallery-delete { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

/* ---- Import preview ---- */
.preview-value { margin: 4px 0 0; font-size: 14px; color: var(--text); line-height: 1.5; }
.preview-desc { white-space: pre-wrap; color: var(--text-muted); font-size: 13px; }

/* ---- Tabs ---- */
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 4px 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -1px;
}
.tab-btn.active { color: var(--orange); border-bottom-color: var(--orange); }
.tab-btn:hover:not(.active) { color: var(--text); }
