html {
  scrollbar-gutter: stable;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: #f1f1f1;
  color: #222;
}

.wrap {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1rem 2rem;
}

.narrow {
  max-width: 520px;
}

.wide-form {
  max-width: 700px;
}

.card {
  background: #fff;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.topnav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
  scrollbar-width: thin;
}

.topnav a,
.topnav button {
  background: #333;
  color: #fff;
  text-decoration: none;
  border: 0;
  padding: 0.65rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 130px;
  text-align: center;
  box-sizing: border-box;
}

.button-link {
  background: #333;
  color: #fff;
  text-decoration: none;
  border: 0;
  padding: 0.65rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
  white-space: nowrap;
  text-align: center;
  box-sizing: border-box;
}

.button-link.secondary {
  background: #777;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

label {
  display: block;
  margin-bottom: 1rem;
}

input,
textarea,
select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.35rem;
  padding: 0.65rem;
  border: 1px solid #bbb;
  border-radius: 4px;
  font: inherit;
}

button {
  font: inherit;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  align-items: end;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border: 1px solid #ccc;
  padding: 0.6rem;
  text-align: left;
  vertical-align: top;
}

thead {
  background: #4d5660;
  color: #fff;
}

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

.actions {
  white-space: nowrap;
}

.link-button {
  background: none;
  border: 0;
  color: #0057b8;
  text-decoration: underline;
  padding: 0;
  cursor: pointer;
}

.message {
  min-height: 1.25rem;
  margin-top: 1rem;
}

.muted {
  color: #666;
  margin-top: 0;
}

.hidden {
  display: none !important;
}

.file-note {
  margin-top: 0.35rem;
  color: #555;
  font-size: 0.92rem;
}

.crop-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
}

.crop-modal.hidden {
  display: none !important;
}

.crop-panel {
  background: #fff;
  width: min(980px, 100%);
  max-height: 95vh;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.crop-header {
  padding: 0.9rem 1rem 0.25rem;
}

.crop-header h2 {
  margin: 0 0 0.35rem 0;
}

.crop-body {
  padding: 0 1rem 1rem;
  min-height: 300px;
  overflow: auto;
}

.crop-image-wrap {
  width: 100%;
  min-height: 300px;
  max-height: 70vh;
}

.crop-image-wrap img {
  display: block;
  max-width: 100%;
}

.crop-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding: 0 1rem 1rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .row {
    align-items: flex-start;
    flex-direction: column;
  }

  .button-row {
    align-items: stretch;
  }

  .button-link {
    text-align: center;
  }

  .topnav {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .topnav a,
  .topnav button {
    min-width: 0;
    flex: 1 1 calc(50% - 0.5rem);
  }

  .crop-panel {
    max-height: 100vh;
    width: 100%;
    border-radius: 0;
  }

  .crop-image-wrap {
    min-height: 240px;
    max-height: 56vh;
  }

  .crop-actions {
    justify-content: stretch;
  }

  .crop-actions button {
    flex: 1 1 auto;
  }
}
