:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1b1f24;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --border: #e5e7eb;
  --chip: #eef2ff;
  --radius: 14px;
  --shadow: 0 8px 22px rgba(16, 24, 40, 0.08);
  --shadow-sm: 0 2px 10px rgba(16, 24, 40, 0.06);
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue",
    Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

.container {
  max-width: 1100px;
  margin: 40px auto;
  padding: 0 20px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr auto;
  gap: 12px;
  margin-bottom: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.controls {
  padding: 14px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1.3fr 1fr 1fr auto;
}

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: #fafbff;
  color: var(--muted);
  font-size: 0.92rem;
}

.chip {
  background: var(--chip);
  color: var(--primary-600);
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #e0e7ff;
  font-weight: 600;
  font-size: 0.82rem;
}

.field { position: relative; }

.field input[type="search"],
.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow-sm);
  outline: none;
  font-size: 0.95rem;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.field input[type="search"]:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.btn {
  appearance: none;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.02s ease;
  white-space: nowrap;
}

.btn.secondary {
  color: var(--primary);
  background: transparent;
}

.btn:hover { background: var(--primary-600); }
.btn.secondary:hover { background: var(--chip); }
.btn:active { transform: translateY(1px); }

.table-wrap { overflow: auto; }

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 720px;
  background: #fff;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  font-size: 0.95rem;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
  font-weight: 600;
  color: #334155;
}

tr:hover td { background: #fafafa; }

table thead th:first-child { border-top-left-radius: 12px; }
table thead th:last-child { border-top-right-radius: 12px; }
table tbody tr:last-child td:first-child { border-bottom-left-radius: 12px; }
table tbody tr:last-child td:last-child { border-bottom-right-radius: 12px; }

@media (max-width: 720px) {
  .controls { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr; }
  .meta { flex-wrap: wrap; }
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 520px;
  max-width: 96%;
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform 0.25s ease;
  display: grid;
  grid-template-rows: auto 1fr;
  z-index: 50;
}

.drawer.open { transform: translateX(0); }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer .panel-header {
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.drawer .panel-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
}

.panel-body {
  padding: 14px;
  overflow: auto;
  display: grid;
  gap: 12px;
}

.search-controls {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.search-controls .row {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
}

.img-result {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  aspect-ratio: 16 / 9;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.caption {
  font-size: 0.9rem;
  color: #4b5563;
  margin-top: 6px;
}

.loader {
  height: 4px;
  background: #eef2ff;
  border-radius: 999px;
  overflow: hidden;
}

.loader > i {
  display: block;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: load 1.2s infinite;
}

@keyframes load {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

.empty {
  color: #6b7280;
  padding: 8px 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.thumb {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f3f4f6;
  aspect-ratio: 1 / 1;
  cursor: pointer;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
