:root {
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #121212;
  --surface: #1a1a1c;
  --surface-2: #212123;
  --surface-hover: #29292b;
  --border: #303032;
  --border-strong: #3d3d40;

  --text-primary: #f0efec;
  --text-secondary: #a3a19c;
  --text-muted: #6c6a66;

  --accent: #c99a52;
  --accent-hover: #b6883f;
  --accent-soft: rgba(201, 154, 82, 0.12);
  --accent-text: #121212;

  --success: #5a9c73;
  --success-soft: rgba(90, 156, 115, 0.12);
  --danger: #c06158;
  --danger-soft: rgba(192, 97, 88, 0.12);
  --neutral-tag: #8d9199;

  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html, body {
  background-color: var(--bg);
}

body {
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.925rem;
  min-height: 100vh;
}

a {
  text-decoration: none;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  letter-spacing: -0.01em;
}

.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }

/* Navbar */
.app-navbar {
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 0;
}

.app-navbar .navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-primary);
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background-color: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: -0.02em;
}

.brand-name {
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.app-navbar .nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.88rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
}

.app-navbar .nav-link:hover {
  color: var(--text-primary);
  background-color: var(--surface-2);
}

.app-navbar .nav-link.active {
  color: var(--text-primary);
  background-color: var(--surface-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* Layout */
.app-main {
  min-height: calc(100vh - 60px);
}

h1.h3 {
  font-size: 1.4rem;
  font-weight: 600;
}

/* Panels */
.panel {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

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

.panel-header h2, .panel-header h5 {
  margin: 0;
  font-weight: 600;
  font-size: 0.95rem;
}

.panel-body {
  padding: 1.25rem;
}

/* Stat strip */
.stats-strip {
  display: flex;
  flex-wrap: wrap;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat-block {
  flex: 1 1 200px;
  padding: 1.1rem 1.4rem;
  border-left: 1px solid var(--border);
}

.stat-block:first-child {
  border-left: none;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1.2;
}

/* Buttons */
.btn {
  font-weight: 500;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-accent {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-accent:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-text);
}

.btn-outline-light {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-outline-light:hover {
  background-color: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-outline-danger {
  color: var(--danger);
  border-color: var(--border-strong);
}

.btn-outline-danger:hover {
  background-color: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

/* Tables */
.table {
  color: var(--text-primary);
  vertical-align: middle;
  margin-bottom: 0;
  font-size: 0.87rem;
}

.table > :not(caption) > * > * {
  background-color: transparent;
  border-bottom-color: var(--border);
  padding: 0.75rem 1rem;
}

.table thead th {
  color: var(--text-secondary);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
  background-color: var(--surface-2);
}

.duplicate-row {
  opacity: 0.6;
}

.duplicate-row:hover {
  opacity: 1;
}

.table-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.thumb-count-badge {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0.05rem 0.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: 0.66rem;
  font-weight: 600;
  vertical-align: middle;
}

/* Status tags */
.status-tag {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid currentColor;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.6;
}

.status-tag.success { color: var(--success); }
.status-tag.failed { color: var(--danger); }
.status-tag.processing { color: var(--accent); }
.status-tag.pending { color: var(--neutral-tag); }

/* Forms */
.form-control, .form-select {
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.87rem;
  border-radius: var(--radius-sm);
}

.form-control:focus, .form-select:focus {
  background-color: var(--surface-2);
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-label {
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
}

.input-group-text {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.editable-cell {
  background-color: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  width: 100%;
  padding: 0.3rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-family: inherit;
}

.editable-cell:hover {
  background-color: var(--surface-2);
}

.editable-cell:focus {
  background-color: var(--surface-2);
  border-color: var(--accent);
  outline: none;
}

.editable-cell.saved {
  border-color: var(--success);
}

.editable-cell.save-error {
  border-color: var(--danger);
}

/* Dropzone */
.dropzone {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background-color: var(--surface);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background-color: var(--accent-soft);
}

.dropzone-icon {
  font-size: 2.2rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.dropzone-preview {
  max-width: 100%;
  max-height: 360px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Multi-file preview grid */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.6rem;
  margin-top: 1rem;
}

.preview-tile {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface-2);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-tile-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  border: none;
  background-color: rgba(0, 0, 0, 0.65);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.preview-tile-remove:hover {
  background-color: var(--danger);
}

.preview-tile-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: #fff;
  font-size: 0.64rem;
  padding: 0.8rem 0.35rem 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-tile-add {
  cursor: pointer;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--text-secondary);
  border-style: dashed;
  font-size: 0.7rem;
}

.preview-tile-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.preview-tile-add-icon {
  font-size: 1.3rem;
  font-family: var(--font-mono);
  line-height: 1;
}

/* Photo gallery (upload detail) */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.6rem;
}

.photo-gallery a {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background-color: var(--surface-2);
}

.photo-gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.15s ease;
}

.photo-gallery a:hover img {
  transform: scale(1.04);
}

/* Pagination */
.pagination .page-link {
  background-color: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.pagination .page-item.active .page-link {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* Filter tabs */
.filter-tabs {
  display: flex;
  gap: 1.1rem;
  border-bottom: 1px solid var(--border);
}

.filter-tab {
  padding: 0.1rem 0.05rem 0.6rem;
  color: var(--text-secondary);
  font-size: 0.83rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.filter-tab:hover {
  color: var(--text-primary);
}

.filter-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.empty-state {
  padding: 3.5rem 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-mark {
  width: 40px;
  height: 40px;
  margin: 0 auto 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 1.1rem;
}

.detail-image-wrap {
  background-color: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 0.65rem;
  text-align: center;
}

.detail-image-wrap img {
  max-width: 100%;
  max-height: 420px;
  border-radius: var(--radius-sm);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.87rem;
}

.meta-row:last-child {
  border-bottom: none;
}

.meta-label {
  color: var(--text-secondary);
}

.meta-value {
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
}

.meta-value.mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

/* Copy to clipboard */
.copy-row-btn {
  white-space: nowrap;
}

.copy-flash {
  background-color: var(--success-soft) !important;
  border-color: var(--success) !important;
  color: var(--success) !important;
}

.card-name-cell {
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtext {
  color: var(--text-muted);
  font-size: 0.78rem;
}
