* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f8f9fa; --card: #fff; --text: #1a1a2e; --muted: #6b7280;
  --primary: #2563eb; --primary-hover: #1d4ed8; --primary-light: #eff6ff;
  --success: #16a34a; --warning: #f59e0b; --danger: #dc2626;
  --border: #e5e7eb; --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --radius: 10px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }

/* Header */
.header { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.header h1 { font-size: 1.25rem; font-weight: 600; color: var(--primary); }
.badge { font-size: .7rem; font-weight: 700; background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 999px; margin-left: 8px; }
.header-right { display: flex; align-items: center; gap: 12px; font-size: .9rem; color: var(--muted); }

/* Layout */
.main { display: flex; min-height: calc(100vh - 60px); }
.sidebar { width: 220px; background: var(--card); border-right: 1px solid var(--border); padding: 16px 0; position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; }
.nav { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; }
.nav-btn { text-align: left; padding: 10px 12px; border: none; background: transparent; border-radius: 8px; font-size: .9rem; color: var(--muted); cursor: pointer; transition: all .15s; }
.nav-btn:hover { background: var(--primary-light); color: var(--primary); }
.nav-btn.active { background: var(--primary); color: #fff; }

.content { flex: 1; padding: 24px; max-width: 100%; overflow-x: auto; }
.tab-panel { display: none; animation: fadeIn .2s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); transition: transform .15s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.stat-card.loading { opacity: .6; }
.stat-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text); }

/* Toolbar */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.select, .search-input, .input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); font-size: .9rem; }
.search-input { flex: 1; min-width: 200px; }
.input:focus, .select:focus, .textarea:focus, .search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.textarea { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font-family: monospace; font-size: .85rem; resize: vertical; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: none; border-radius: 8px; font-size: .85rem; font-weight: 500; cursor: pointer; transition: all .15s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: .8rem; }
.actions-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }

/* Table */
.table-container { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f9fafb; font-weight: 600; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
td img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.cell-title { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-status { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: .7rem; font-weight: 600; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-ko { background: #fee2e2; color: #991b1b; }
.actions-cell { display: flex; gap: 6px; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.pagination button { padding: 8px 14px; border: 1px solid var(--border); background: var(--card); border-radius: 8px; cursor: pointer; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .3; cursor: not-allowed; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.card.warning { border-color: #fde68a; background: #fffbeb; }
.card.warning h3 { color: #92400e; }
.hint { font-size: .8rem; color: var(--muted); margin-bottom: 16px; }
.hint code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: .75rem; }

/* Result messages */
.result { padding: 12px 16px; border-radius: 8px; margin-top: 12px; font-size: .9rem; }
.result.hidden { display: none; }
.result.success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.result.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.result.info { background: var(--primary-light); color: var(--primary); border: 1px solid #bfdbfe; }

/* Form groups */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 6px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.modal-content { position: relative; background: var(--card); border-radius: var(--radius); max-width: 600px; width: 100%; max-height: 80vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 1.1rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); padding: 0 8px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }

/* Product detail in modal */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.detail-value { font-size: .9rem; font-weight: 500; }
.detail-image { width: 100%; max-width: 300px; border-radius: 8px; }

/* Loading spinner */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -220px; top: 60px; height: calc(100vh - 60px); z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  td:nth-child(2), td:nth-child(7) { display: none; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  th:nth-child(4), td:nth-child(4) { display: none; }
}