:root {
  --bg: #0f172a;
  --card: #1e293b;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --line: #334155;
  --accent: #3b82f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* Header chung: xem header.css ở gốc */

.layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
  padding: 20px 24px;
  align-items: start;
}
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.panel h2 { font-size: 16px; margin: 18px 0 10px; }
.panel h2:first-child { margin-top: 0; }

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab-btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.tab-btn:hover { border-color: var(--accent); }
.tab-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Google Sheet link */
.sheet-url-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.sheet-url-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 10px;
}
.sheet-url-input:focus { outline: none; border-color: var(--accent); }

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  background: var(--bg);
  color: var(--ink);
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Buttons */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  margin: 4px 6px 4px 0;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn-secondary { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
th.name-col, td.name-cell { width: 34%; }
td.name-cell {
  display: table-cell;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
}
td.sku-cell { word-break: break-all; font-size: 12px; color: var(--muted); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #172033; color: var(--muted); position: sticky; top: 0; }
tbody tr:hover { background: #24324a; }
td input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 13px;
  background: transparent;
  color: var(--ink);
}
td input:hover, td input:focus { border-color: var(--line); background: var(--bg); outline: none; }
td input:focus { border-color: var(--accent); }

.img-cell { display: flex; align-items: center; gap: 6px; }
.img-thumb {
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.img-upload {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.img-upload:hover { border-color: var(--accent); }

.hint { color: var(--muted); font-size: 13px; }

/* Status badges */
.status-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
}
.badge-ok { background: #052e16; color: #4ade80; border: 1px solid #14532d; }
.badge-err { background: #450a0a; color: #f87171; border: 1px solid #7f1d1d; }

.image-card-broken { border: 2px solid var(--err); background: #450a0a; }

/* Output */
.output-actions { margin-bottom: 10px; }
.output-text {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 480px;
  overflow-y: auto;
}

/* Image grid preview */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.kien-heading {
  grid-column: 1 / -1;
  margin: 6px 0 2px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  border-bottom: 2px solid var(--line);
  padding-bottom: 6px;
}
.image-card {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #24324a;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
}
.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.image-card .name-label {
  position: absolute;
  top: 0;
  left: 0;
  max-width: 100%;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  border-bottom-right-radius: 12px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 10px 0 24px;
}

.error-list {
  margin: 10px 0;
  padding: 10px 14px;
  border: 1px solid #7f1d1d;
  border-radius: 10px;
  background: #450a0a;
  color: #fca5a5;
  font-size: 13px;
}
.error-list ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

/* --- Loading spinner (nút tải dữ liệu) --- */
.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(148, 163, 184, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
