:root {
  --bg: #0b0d10;
  --panel: #12161c;
  --surface: #1a2029;
  --text: #e8eef6;
  --muted: #a9b2bf;
  --primary: #4f8cff;
  --primary-700: #3d6ecc;
  --danger: #ff6b6b;
  --ok: #21c07a;
  --border: #28303b;
  --shadow: 0 6px 24px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.25);
}

/* Light Mode */
:root[data-theme="light"] {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --surface: #ffffff;
  --text: #1a2029;
  --muted: #64748b;
  --primary: #4f8cff;
  --primary-700: #3d6ecc;
  --danger: #ef4444;
  --ok: #10b981;
  --border: #e2e8f0;
  --shadow: 0 4px 16px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.05);
}

:root[data-theme="light"] body {
  background: linear-gradient(180deg, #f5f7fa 0%, #e8ecf1 100%);
}

:root[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, .9);
}

:root[data-theme="light"] .input {
  box-shadow: inset 0 1px 2px rgba(0,0,0,.05);
}

:root[data-theme="light"] .paint-item {
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

:root[data-theme="light"] .swatch {
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);
}

:root[data-theme="light"] .image-modal-backdrop {
  background: rgba(0,0,0,.75);
}

:root[data-theme="light"] .tab-panel {
  background: rgba(0,0,0,.02);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: linear-gradient(180deg, #0b0d10 0%, #0f1318 100%);
  transition: background 0.3s ease, color 0.3s ease;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(18, 22, 28, .8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-title { display: flex; gap: 12px; align-items: baseline; }
.app-header h1 { margin: 0; font-size: 20px; letter-spacing: .3px; }
.total-count { color: var(--muted); font-size: 14px; font-weight: 500; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
}
.theme-toggle:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}
.theme-toggle:active {
  transform: scale(0.95);
}

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
}
.filters { display: flex; gap: 16px; align-items: center; color: var(--muted); }
.checkbox { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }

.input {
  appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,140,255, .25); }
textarea.input { resize: vertical; }

.btn {
  appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: transparent; }
.btn.primary:hover { background: var(--primary-700); }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

main { padding: 8px 12px 40px; }
.empty-state {
  margin: 40px auto;
  max-width: 720px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.paint-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 980px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.paint-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

.swatch { width: 32px; height: 32px; min-width: 32px; border-radius: 6px; border: 1px solid var(--border); box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); flex-shrink: 0; }
.paint-item .swatch { order: -1; }
.swatch-lg { width: 100%; height: 40px; }
.meta { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.title { display: flex; flex-wrap: wrap; gap: 4px; align-items: baseline; }
.brand { font-weight: 600; font-size: 14px; }
.name { color: var(--text); font-size: 14px; }
.code { color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.sub { display: flex; gap: 8px; color: var(--muted); font-size: 11px; }
.qty { font-weight: 600; color: var(--ok); }

.row-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.icon-btn:hover { border-color: var(--primary); }
.icon-btn.danger { color: #fff; background: var(--danger); border-color: transparent; }
.thumb { width: 100%; max-height: 160px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.paint-item .thumb { width: 40px; height: 40px; min-width: 40px; max-height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; order: -2; }
.lookup-media { margin-top: 8px; }

.dialog { border: none; border-radius: 16px; padding: 0; background: var(--panel); color: var(--text); box-shadow: var(--shadow); width: min(720px, 92vw); }
.dialog::backdrop { background: rgba(0,0,0,.5); }
.dialog form { padding: 16px; display: grid; gap: 14px; }
.dialog h2 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.field { display: grid; gap: 6px; }
.field span { color: var(--muted); font-size: 12px; }
.color-preview { align-content: end; }

.tabs { display: flex; gap: 6px; }
.tab { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.tab.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,140,255,.25); }
.tab-panel { border: 1px dashed var(--border); border-radius: 12px; padding: 12px; background: rgba(255,255,255,.02); }

.actions-row { display: flex; gap: 8px; }
.hint { color: var(--muted); }
.output { display: inline-block; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; min-height: 40px; }

.image-modal { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.image-modal[hidden] { display: none; }
.image-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.85); }
.image-modal-content { position: relative; z-index: 1; max-width: 90vw; max-height: 90vh; }
.image-modal-content img { max-width: 100%; max-height: 90vh; border-radius: 12px; box-shadow: var(--shadow); }
.image-modal-close { position: absolute; top: -40px; right: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); color: var(--text); border: 1px solid var(--border); cursor: pointer; font-size: 20px; }
.image-modal-close:hover { background: var(--danger); border-color: transparent; }

@media (max-width: 680px) {
  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .filters { justify-content: space-between; }
}


