:root {
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --bg-muted: #eef2f7;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --danger-soft: rgba(239, 68, 68, 0.1);
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.16);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-elevated: #141414;
  --bg-muted: #1c1c1c;
  --text: #f5f5f5;
  --text-muted: #a3a3a3;
  --text-subtle: #737373;
  --border: #262626;
  --border-strong: #333333;
  --primary: #f5f5f5;
  --primary-hover: #e5e5e5;
  --primary-soft: rgba(255, 255, 255, 0.08);
  --danger-soft: rgba(239, 68, 68, 0.15);
  --danger: #f87171;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.6);
  --focus-ring: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  transition: background 0.2s ease, color 0.2s ease;
}

a {
  color: var(--primary);
}

button,
input,
select {
  font: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn:hover {
  background: var(--bg-muted);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

[data-theme="dark"] .btn-primary {
  color: #0a0a0a;
}

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

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  background: var(--bg-muted);
}

.btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
}

.input,
.select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

[data-theme="dark"] .badge {
  color: var(--text);
}

.alert-error {
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--danger);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

/* Login */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-md);
}

.login-card h1 {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.login-card .subtitle {
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}

.field {
  margin-bottom: 18px;
}

/* Dashboard */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-form {
  display: flex;
  align-items: center;
}

.filter-form .select {
  width: auto;
  min-width: 200px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.user-badge strong {
  color: var(--text);
  font-weight: 600;
}

.app-main {
  padding: 28px 24px 48px;
  max-width: 1440px;
  margin: 0 auto;
}

.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.stats-bar strong {
  color: var(--text);
}

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

.listing-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.listing-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.listing-card:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), var(--shadow-md);
}

.listing-card__image,
.listing-card__placeholder {
  width: 100%;
  height: 210px;
  object-fit: cover;
  background: var(--bg-muted);
}

.listing-card__body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.listing-card__title {
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.listing-card__price {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
}

.listing-card__meta {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.listing-card__hint {
  margin-top: auto;
  padding-top: 8px;
  color: var(--text-subtle);
  font-size: 0.8rem;
}

.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
}

/* Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal {
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 22px 24px 0;
}

.modal__title {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.35;
  padding-right: 12px;
}

.modal__content {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
  padding: 20px 24px 24px;
}

.modal__image,
.modal__image-placeholder {
  width: 100%;
  height: 280px;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--bg-muted);
}

.modal__image-placeholder {
  display: grid;
  place-items: center;
  color: var(--text-subtle);
  font-size: 0.9rem;
  border: 1px dashed var(--border-strong);
}

.detail-grid {
  display: grid;
  gap: 14px;
}

.detail-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  border: 1px solid var(--border);
}

.detail-item__label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  margin-bottom: 4px;
}

.detail-item__value {
  font-size: 0.95rem;
  color: var(--text);
  word-break: break-word;
}

.modal__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 24px 24px;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: space-between;
  }

  .modal__content {
    grid-template-columns: 1fr;
  }

  .modal__image,
  .modal__image-placeholder {
    height: 220px;
  }
}
