:root {
  color-scheme: light;
  --bg: #fdf9fb;
  --card: #ffffff;
  --text: #1f1a17;
  --muted: #6b625c;
  --brand-purple: #c790d1;
  --brand-pink: #f39aa6;
  --brand-coral: #f7a19d;
  --accent: #b84d66;
  --accent-dark: #9a3f56;
  --border: #f0e4ea;
  --shadow: 0 10px 30px rgba(31, 26, 23, 0.08);
  --gradient: linear-gradient(90deg, var(--brand-purple), var(--brand-pink), var(--brand-coral));
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  display: flex;
  min-height: 100vh;
  --sidebar-offset: var(--sidebar-width);
}

.app-shell.sidebar-collapsed {
  --sidebar-offset: 0px;
}

.sidebar-backdrop {
  display: none;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  height: 100vh;
  overflow-y: auto;
  transform: translateX(0);
  transition: transform 0.2s ease;
}

.app-shell.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

.main-toolbar {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem 0;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
}

.sidebar-toggle:hover {
  background: #faf3f7;
}

.sidebar-toggle-bars,
.sidebar-toggle-bars::before,
.sidebar-toggle-bars::after {
  display: block;
  width: 1.125rem;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  position: relative;
}

.sidebar-toggle-bars::before,
.sidebar-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
}

.sidebar-toggle-bars::before {
  top: -6px;
}

.sidebar-toggle-bars::after {
  top: 6px;
}

.sidebar-brand {
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.sidebar-brand a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.sidebar-brand img {
  width: 40px;
  height: auto;
}

.sidebar-brand span {
  font-weight: 600;
  font-size: 1.1rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0 0.75rem;
  flex: 1;
}

.sidebar-nav a {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.95rem;
}

.sidebar-nav a:hover {
  background: #faf3f7;
}

.sidebar-nav a.active {
  background: #f8e8ef;
  color: var(--accent-dark);
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.sidebar-footer form {
  margin-top: 0.5rem;
}

.sidebar-footer button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-offset);
  transition: margin-left 0.2s ease;
  width: calc(100% - var(--sidebar-offset));
}

.flash-messages {
  max-width: 1200px;
  margin: 1rem auto 0;
  padding: 0 1.5rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.flash-success {
  background: #e8f5ea;
  color: #1f5f2d;
}

.flash-error {
  background: #fdecea;
  color: #8a1f1f;
}

.page-header {
  padding: 1.5rem 1.5rem 0.5rem;
  max-width: 1200px;
}

.page-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
}

.page-header p {
  margin: 0;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1rem 1.5rem;
  max-width: 1200px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}

.stat-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.6rem;
  line-height: 1.1;
}

.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin: 0 1.5rem 1rem;
  max-width: 1200px;
}

.chart-card h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
}

.chart-container {
  position: relative;
  height: 260px;
}

.status-badge.status-active {
  background: #e8f5ec;
  color: #2f6b43;
}

.status-badge.status-blocked {
  background: #fdecea;
  color: #9a3f56;
}

.admin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin: 1rem 1.5rem 2rem;
  max-width: 1200px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-idle,
.status-queued {
  background: #f0f0f0;
  color: #555;
}

.status-running {
  background: #fff3cd;
  color: #856404;
}

.status-completed,
.status-complete,
.status-processed {
  background: #e8f5ea;
  color: #1f5f2d;
}

.status-failed,
.status-partial {
  background: #fdecea;
  color: #8a1f1f;
}

.status-approved {
  background: #e8f5ea;
  color: #1f5f2d;
}

.license-panel {
  margin-bottom: 1.25rem;
}

.license-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.license-panel-summary {
  margin: 0 0 1rem;
  color: var(--muted);
}

.license-upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-top: 1rem;
}

.license-upload-form label {
  display: block;
  width: 100%;
  font-weight: 600;
}

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

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

.btn-primary:hover {
  background: var(--accent-dark);
}

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

.btn-secondary:hover {
  background: var(--surface-hover, #f3f4f6);
}

.form-field {
  margin-bottom: 1rem;
}

.form-field label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.form-field input,
.form-field select,
.form-field textarea,
.invite-email-field {
  width: 100%;
  max-width: 420px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.invite-email-field {
  max-width: none;
  margin-bottom: 0.75rem;
  resize: vertical;
}

.form-error {
  color: #8a1f1f;
  margin-bottom: 1rem;
}

.clothing-image-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.clothing-image-list li {
  width: 120px;
}

.clothing-image-list img {
  width: 120px;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  background: #f3f4f6;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 2rem;
}

.login-card h1 {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 0.5rem;
}

.login-logo {
  width: 72px;
  height: auto;
  margin-bottom: 0.75rem;
}

.login-brand h1 {
  margin: 0 0 1.5rem;
}

.login-card p {
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.processing-banner {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.processing-banner.running,
.processing-banner.queued {
  background: #fff3cd;
  color: #856404;
}

.processing-banner.failed {
  background: #fdecea;
  color: #8a1f1f;
}

.processing-banner.completed {
  background: #e8f5ea;
  color: #1f5f2d;
}

.processing-overview {
  margin-bottom: 1rem;
}

.processing-bar {
  display: flex;
  width: 100%;
  height: 0.65rem;
  border-radius: 999px;
  overflow: hidden;
  background: #ececec;
  box-shadow: inset 0 0 0 1px rgba(31, 26, 23, 0.06);
}

.processing-bar-segment {
  display: block;
  height: 100%;
  min-width: 0;
}

.processing-bar-segment.status-idle {
  background: #d8d8d8;
}

.processing-bar-segment.status-queued {
  background: #9a9a9a;
}

.processing-bar-segment.status-running {
  background: #f0c040;
}

.processing-bar-segment.status-completed {
  background: #5da86a;
}

.processing-bar-segment.status-failed {
  background: #d9534f;
}

.processing-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  list-style: none;
  margin: 0.55rem 0 0;
  padding: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.processing-legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-swatch.status-idle {
  background: #d8d8d8;
}

.legend-swatch.status-queued {
  background: #9a9a9a;
}

.legend-swatch.status-running {
  background: #f0c040;
}

.legend-swatch.status-completed {
  background: #5da86a;
}

.legend-swatch.status-failed {
  background: #d9534f;
}

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

.legend-value {
  color: var(--muted);
}

.process-all-progress {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fffaf7;
}

.process-all-progress.hidden {
  display: none;
}

.process-all-progress-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.process-all-eta {
  color: var(--muted);
  font-size: 0.92rem;
}

.process-all-progress-track {
  width: 100%;
  height: 0.85rem;
  border-radius: 999px;
  overflow: hidden;
  background: #ececec;
  box-shadow: inset 0 0 0 1px rgba(31, 26, 23, 0.06);
}

.process-all-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand-purple), var(--brand-pink));
  transition: width 0.4s ease;
}

.process-all-detail {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.admin-toolbar form {
  margin: 0;
}

.admin-search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 220px;
}

.admin-search-form input[type="search"],
.admin-search-form input[type="url"] {
  flex: 1;
  min-width: 180px;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}

.admin-search-form select {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.admin-search-summary {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.pagination-status {
  color: var(--muted);
  font-size: 0.95rem;
}

.pagination .btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.view-toggle {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.view-toggle .btn.active {
  background: #f8e8ef;
  border-color: var(--accent);
  color: var(--accent-dark);
}

.btn-small {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.btn-danger {
  border-color: #c0392b;
  color: #c0392b;
}

.btn-danger:hover {
  background: #fdecea;
}

.inline-form {
  display: inline;
}

.action-cell {
  white-space: nowrap;
}

.action-cell form {
  display: inline;
  margin-left: 0.35rem;
}

.hidden {
  display: none;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.dress-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

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

.dress-tile-image {
  aspect-ratio: 3 / 4;
  background: #f8f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

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

.dress-tile-placeholder {
  color: var(--muted);
  font-size: 0.9rem;
}

.dress-tile-body {
  padding: 0.85rem 1rem 1rem;
}

.dress-tile-body h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.dress-tile-price {
  margin: 0 0 0.25rem;
  font-weight: 600;
  color: var(--accent-dark);
}

.dress-tile-role {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.dress-tile-description {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dress-tile-links {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.dress-tile-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.ai-badge {
  font-size: 0.8rem;
  color: var(--muted);
}

.checkbox-readonly {
  cursor: default;
  color: var(--text);
}

.checkbox-readonly input {
  cursor: default;
}

.relative-time {
  cursor: help;
  text-decoration: underline dotted var(--muted);
  text-underline-offset: 0.15em;
}

.dress-tile-discovered {
  font-size: 0.85rem;
  color: var(--muted);
}

.dress-delete-form {
  margin: 0;
}

.dress-delete-form-overlay {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
}

.dress-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent-dark);
  box-shadow: 0 2px 8px rgba(31, 26, 23, 0.15);
  cursor: pointer;
}

.dress-delete-btn:hover {
  background: #fff;
  color: #8b1e3f;
}

.actions-col {
  width: 2.5rem;
  text-align: center;
}

@media (max-width: 768px) {
  .app-shell {
    --sidebar-offset: 0px;
  }

  .app-shell:not(.sidebar-collapsed) .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(31, 26, 23, 0.35);
    border: none;
    padding: 0;
    margin: 0;
  }

  .main-content {
    width: 100%;
    margin-left: 0;
  }
}
