:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #dce1e8;
  --text: #1b2430;
  --text-dim: #64748b;
  --primary: #ff7a1a;
  --primary-dim: #e0620c;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(27, 36, 48, 0.08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #ffe9d6 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.right { text-align: right; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
  background: var(--surface-2);
  color: var(--text);
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--primary); color: #1a1206; }
.btn-primary:hover { background: var(--primary-dim); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.brand { text-align: center; margin-bottom: 24px; }
.brand h1 { margin: 8px 0 2px; font-size: 28px; letter-spacing: 0.5px; }
.brand-sub { margin: 0; color: var(--text-dim); font-size: 13px; }
.brand-logo { font-size: 40px; }
.brand-logo.sm { font-size: 22px; }

form label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
input, .select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
input:focus, .select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.tabs { display: flex; gap: 6px; margin-left: 10px; }
.tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.tab.active { background: var(--surface-2); color: var(--text); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-badge { font-size: 13px; color: var(--text-dim); }
.user-badge b { color: var(--text); }
.role-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary);
  color: #1a1206;
  font-weight: 700;
  text-transform: uppercase;
}
.role-pill.user { background: var(--surface-2); color: var(--text-dim); }

/* ---------- Content ---------- */
.content { max-width: 1100px; margin: 0 auto; padding: 24px 22px 60px; }
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.search-wrap { flex: 1; min-width: 220px; }
.search-wrap input { margin-top: 0; }
.select { width: auto; min-width: 170px; margin-top: 0; }

/* ---------- Items grid ---------- */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: 0.15s;
}
.item-card:hover { border-color: var(--primary-dim); transform: translateY(-2px); }
.item-thumb {
  height: 150px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.item-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.item-thumb .placeholder { font-size: 42px; opacity: 0.4; }
.item-body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.item-name { font-weight: 700; font-size: 15px; }
.item-cat { font-size: 12px; color: var(--text-dim); }
.item-sku { font-size: 11px; color: var(--text-dim); font-family: ui-monospace, monospace; }
.item-desc { font-size: 13px; color: var(--text-dim); flex: 1; }
.item-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.item-price { font-weight: 800; color: var(--primary); font-size: 16px; }
.item-qty { font-size: 12px; color: var(--text-dim); }
.item-actions { display: flex; gap: 6px; padding: 0 14px 14px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--surface); color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface); }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.status-dot.on::before { background: var(--success); }
.status-dot.off::before { background: var(--danger); }

/* ---------- Pager ---------- */
.pager { display: flex; justify-content: center; gap: 8px; margin-top: 24px; align-items: center; }
.pager span { color: var(--text-dim); font-size: 13px; }

.empty { text-align: center; color: var(--text-dim); padding: 60px 0; }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(27, 36, 48, 0.45); }
.modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}
.modal h2 { margin: 0 0 18px; font-size: 20px; }
.modal .row { display: flex; gap: 12px; }
.modal .row > * { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.checkbox-row input { width: auto; margin: 0; }
.image-preview { margin-top: 6px; height: 120px; border: 1px dashed var(--border); border-radius: 9px; display: grid; place-items: center; overflow: hidden; background: var(--surface-2); }
.image-preview img { width: 100%; height: 100%; object-fit: contain; }
.image-preview .placeholder { color: var(--text-dim); font-size: 13px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 12px 18px;
  border-radius: 9px;
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: slidein 0.2s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
