* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --border: #dbe1ea;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #111827;
  --primary-contrast: #ffffff;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 16px;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  text-decoration: none;
  color: #1d4ed8;
}

h1, h2, h3, p {
  margin-top: 0;
}

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-card input,
.login-card button,
input,
textarea,
select,
button {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 16px;
  border-radius: 12px;
}

input,
textarea,
select {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

button {
  border: none;
  cursor: pointer;
}

.login-card button,
.btn-primary {
  background: var(--primary);
  color: var(--primary-contrast);
}

.error-text {
  color: #dc2626;
  font-size: 14px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 72px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  gap: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

.topbar-right {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-link {
  color: #fff;
  font-size: 15px;
}

.app-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 72px - 60px);
}

.sidebar {
  background: #e5e7eb;
  padding: 20px;
  border-right: 1px solid #d1d5db;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-link {
  display: block;
  padding: 14px 16px;
  border-radius: 12px;
  color: var(--text);
  background: transparent;
}

.nav-link.active {
  background: var(--surface);
  box-shadow: var(--shadow);
  font-weight: bold;
}

.main-content {
  padding: 24px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h2 {
  margin-bottom: 8px;
}

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

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.narrow-card {
  max-width: 420px;
  margin: 0 auto;
}

.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.stat-card h3 {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 10px;
}

.stat-card p {
  font-size: 28px;
  font-weight: bold;
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.full-width {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.alert {
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.alert.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.footer {
  min-height: 60px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
  background: #fff;
}

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

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid #d1d5db;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

@media (max-width: 768px) {
  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  background: #f9fafb;
  font-size: 14px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.six-cols {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.alert.error {
  background: #fee2e2;
  color: #991b1b;
}

@media (max-width: 1024px) {
  .six-cols {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .details-grid,
  .six-cols {
    grid-template-columns: 1fr;
  }
}

.page-header-inline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.actions-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.actions-inline form {
  margin: 0;
}

.btn-link-solid,
.btn-link-outline,
.btn-link-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

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

.btn-link-outline {
  border: 1px solid var(--border);
  color: var(--text);
  background: #fff;
}

.btn-link-danger {
  border: none;
  background: transparent;
  color: #b91c1c;
  padding: 0;
  min-height: auto;
}

@media (max-width: 768px) {
  .page-header-inline {
    flex-direction: column;
  }
}

.help-text {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.image-card {
  display: block;
  overflow: hidden;
  border-radius: 14px;
  background: #f9fafb;
  border: 1px solid var(--border);
}

.image-card img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
}

@media (max-width: 1024px) {
  .image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .image-grid {
    grid-template-columns: 1fr;
  }

  .image-card img {
    height: 240px;
  }
}

.compact-table {
  min-width: 0;
}

.compact-table th,
.compact-table td {
  padding: 10px 12px;
}

.stat-card p {
  word-break: break-word;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}

.filters-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

@media (max-width: 1024px) {
  .filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .filters-grid {
    grid-template-columns: 1fr;
  }

  .filters-actions {
    justify-content: stretch;
    flex-direction: column;
  }

  .filters-actions > * {
    width: 100%;
  }
}

.ai-suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.ai-box {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.ai-box h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.ai-box p {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
}

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

@media (max-width: 768px) {
  .ai-suggestions-grid {
    grid-template-columns: 1fr;
  }
}


.ai-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-apply-btn {
  min-height: 40px;
  width: auto;
  padding: 10px 14px;
  font-size: 14px;
}

.section-subtitle {
  margin: 0 0 16px;
  font-size: 18px;
}

.ai-box p + p {
  margin-top: 10px;
}

.report-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.print-body {
  background: #ffffff;
}

.print-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.print-header {
  margin-bottom: 24px;
}

@media print {
  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .print-container {
    max-width: none;
    padding: 0;
  }
}


.image-card-edit {
  padding: 0;
  overflow: hidden;
}

.image-delete-form {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.wizard-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.wizard-step {
  display: none;
}

.wizard-step.active {
  display: block;
}

.wizard-progress {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wizard-progress-bar {
  width: 100%;
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.wizard-progress-fill {
  height: 100%;
  width: 20%;
  background: var(--primary);
  transition: width 0.25s ease;
}

.wizard-steps-labels {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.wizard-step-label {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.wizard-step-label.active {
  background: #111827;
  color: #fff;
}

.wizard-footer {
  position: sticky;
  bottom: 16px;
  z-index: 5;
}

.wizard-footer-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.wizard-submit-hidden {
  display: none !important;
}

.nested-card {
  margin-top: 24px;
  box-shadow: none;
  border: 1px solid var(--border);
}

@media (max-width: 1024px) {
  .wizard-steps-labels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .wizard-steps-labels {
    grid-template-columns: 1fr;
  }

  .wizard-footer-actions {
    flex-direction: column;
  }

  .wizard-footer-actions > * {
    width: 100%;
  }
}

.ai-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.ai-box-head h4 {
  margin: 0;
}

.ai-applied-badge {
  min-height: 24px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: transparent;
  background: transparent;
  transition: all 0.2s ease;
}

.ai-box.ai-applied {
  border-color: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.12);
}

.ai-box.ai-applied .ai-applied-badge {
  color: #166534;
  background: #dcfce7;
}

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

.actions-inline form {
  margin: 0;
}

.actions-inline a,
.actions-inline button {
  font-size: 14px;
  line-height: 1.2;
}

.btn-link-danger {
  border: none;
  background: transparent;
  color: #b91c1c;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.btn-link-danger:hover {
  text-decoration: underline;
}

.data-table td:last-child,
.data-table th:last-child {
  min-width: 150px;
}
