:root {
  --color-bg: #f7f7f7;
  --color-surface: #ffffff;
  --color-text: #1a1a1a;
  --color-muted: #6b6b6b;
  --color-border: #e5e5e5;
  --color-primary: #e4002b;
  --color-primary-hover: #b8001f;
  --color-danger: #1a1a1a;
  --color-danger-hover: #000000;
  --color-success-bg: #eafbea;
  --color-success-text: #1e7e34;
  --color-error-bg: #fdeceb;
  --color-error-text: #b8001f;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

.topbar {
  position: relative;
  z-index: 1;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.topbar__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar__brand {
  display: flex;
  align-items: center;
}

.topbar__brand-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.topbar__title {
  font-weight: 700;
  color: var(--color-primary);
  font-size: 16px;
}

.topbar__logo-img {
  display: block;
  max-height: 40px;
  max-width: 240px;
  object-fit: contain;
}

.topbar__nav a {
  margin-left: 16px;
  color: var(--color-primary);
  text-decoration: none;
  font-size: 14px;
}

.topbar__nav a:hover {
  text-decoration: underline;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.card {
  position: relative;
  z-index: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.page-bg-texture {
  position: fixed;
  inset: -50%;
  z-index: 0;
  background-repeat: repeat;
  background-size: 240px 240px;
  transform: rotate(15deg);
  transform-origin: center;
  opacity: 0.18;
  pointer-events: none;
}

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

#accounts-section {
  scroll-margin-top: 16px;
}

h1 {
  font-size: 20px;
  margin: 0 0 20px;
}

h2 {
  font-size: 17px;
  margin: 0 0 12px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-header h2 {
  margin-bottom: 0;
}

.section-header__actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

button:disabled,
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

form label {
  display: block;
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 14px;
}

form input[type="text"],
form input[type="password"],
form input[type="file"],
form textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  color: var(--color-text);
}

form textarea {
  resize: vertical;
}

form input:focus,
form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(228, 0, 43, 0.15);
}

.tabs {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.tab-btn {
  background: none;
  border: none;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-muted);
}

.tab-btn:hover {
  background: none;
  color: var(--color-text);
}

.tab-btn.is-active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

button,
.btn {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  background: var(--color-primary);
  color: #fff;
}

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

.btn--danger {
  background: var(--color-danger);
}

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

.row-btn {
  padding: 7px 12px;
  font-size: 13px;
  line-height: 1.2;
  box-sizing: border-box;
}

.btn-generate,
.btn-copy,
.btn-secondary {
  padding-top: 8px;
  padding-bottom: 8px;
  background: #fff;
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}

.btn-generate:hover,
.btn-copy:hover,
.btn-secondary:hover {
  background: #f8fafc;
}

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
}

.modal__header h2 {
  margin: 0;
}

.modal__close {
  background: none;
  border: none;
  padding: 2px 6px;
  font-size: 22px;
  line-height: 1;
  color: var(--color-muted);
}

.modal__close:hover {
  background: none;
  color: var(--color-text);
}

.modal__body {
  padding: 4px 20px 20px;
  overflow-y: auto;
  max-height: calc(80vh - 60px);
}

.hint {
  font-size: 13px;
  color: var(--color-muted);
  margin: 0 0 12px;
}

.loading[hidden] {
  display: none;
}

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--color-muted);
  font-size: 14px;
}

.loading__spinner {
  width: 18px;
  height: 18px;
  flex: none;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.logo-preview {
  display: block;
  max-height: 60px;
  max-width: 300px;
  object-fit: contain;
  margin-bottom: 12px;
}

.inline-form {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.inline-form input[type="text"],
.inline-form input[type="file"] {
  width: auto;
  margin-top: 0;
}

.card form + form,
.card form + button,
.card form + .btn-secondary {
  margin-top: 8px;
}

.section-header__actions form + form {
  margin-top: 0;
}

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

.actions-row form,
.actions-row .inline-form,
.actions-row .btn-secondary {
  margin: 0;
}

.actions-row form + form,
.actions-row form + button,
.actions-row form + .btn-secondary {
  margin-top: 0;
}


.page-intro {
  text-align: center;
  margin-bottom: 24px;
}

.page-intro__icon {
  color: var(--color-primary);
  margin-bottom: 8px;
}

.page-intro h1 {
  margin-bottom: 8px;
}

.page-intro .hint {
  margin: 0 auto;
}

.result-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.result-icon {
  flex: none;
  display: flex;
}

.result-icon--ok {
  color: var(--color-success-text);
}

.result-icon--needs_inspection {
  color: var(--color-error-text);
}

.result-icon--not_found {
  color: var(--color-muted);
}

.result-card__name {
  font-weight: 600;
  margin-bottom: 4px;
}

.result-card__message {
  color: var(--color-muted);
}

.result-card--ok .result-card__message {
  color: var(--color-success-text);
}

.result-card--needs_inspection .result-card__message {
  color: var(--color-error-text);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.history-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.history-item__icon {
  flex: none;
  display: flex;
}

.history-item__main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.history-item__inn {
  font-weight: 600;
  font-size: 14px;
}

.history-item__name {
  color: var(--color-muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item__time {
  flex: none;
  color: var(--color-muted);
  font-size: 12px;
}

.flash-list {
  margin-bottom: 20px;
}

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 8px;
}

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

.flash--error {
  background: var(--color-error-bg);
  color: var(--color-error-text);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
}

th {
  color: var(--color-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.form-table input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sort-link {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.sort-link:hover {
  color: var(--color-primary);
}

.sort-arrow {
  color: var(--color-primary);
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.per-page-form label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  color: var(--color-muted);
}

.per-page-form select {
  height: 37px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

.pagination a,
.pagination__current,
.pagination__ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 6px;
  color: var(--color-text);
  text-decoration: none;
}

.pagination a:hover {
  background: #f1f5f9;
}

.pagination__current {
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: var(--color-text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
