@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --bordo: #8b043d;
  --bordo-dark: #481024;
  --beige: #f4ede8;
  --white: #ffffff;
  --black: #000000;
  --gray: #484847;
  --gray-light: #e5dcd5;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(72, 16, 36, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Manrope', Arial, Helvetica, sans-serif;
  background: var(--beige);
  color: var(--bordo-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--bordo);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.header {
  background: var(--bordo);
  color: var(--beige);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--beige);
}

.brand:hover {
  text-decoration: none;
}

.brand .mark {
  width: 26px;
  height: 26px;
  color: var(--beige);
}

.brand .word {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.header nav {
  display: flex;
  gap: 20px;
  align-items: center;
}

.header nav a,
.header nav button {
  color: var(--beige);
  opacity: 0.9;
  font-weight: 600;
  font-size: 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.header nav a:hover,
.header nav button:hover {
  opacity: 1;
  text-decoration: underline;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 36px 24px 64px;
}

.narrow {
  max-width: 480px;
}

h1 {
  font-size: 28px;
  font-weight: 800;
  margin: 0 0 8px;
  color: var(--bordo-dark);
}

h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 16px;
}

.subtitle {
  color: var(--gray);
  margin-bottom: 28px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--bordo-dark);
}

.field input[type='text'],
.field input[type='password'],
.field textarea,
.field input[type='search'] {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-light);
  border-radius: 8px;
  font-family: inherit;
  font-size: 15px;
  background: var(--white);
  color: var(--bordo-dark);
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--bordo);
}

.field textarea {
  resize: vertical;
  min-height: 90px;
}

.field-file {
  border: 2px dashed var(--gray-light);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  background: var(--beige);
}

.field-file input {
  width: 100%;
}

.hint {
  font-size: 13px;
  color: var(--gray);
  margin-top: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 12px 22px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--bordo);
  color: var(--beige);
}
.btn-primary:hover {
  background: var(--bordo-dark);
  text-decoration: none;
}

.btn-secondary {
  background: var(--white);
  color: var(--bordo);
  border: 1.5px solid var(--bordo);
}
.btn-secondary:hover {
  background: var(--beige);
  text-decoration: none;
}

.btn-danger {
  background: var(--white);
  color: #b3261e;
  border: 1.5px solid #b3261e;
}
.btn-danger:hover {
  background: #fdecea;
  text-decoration: none;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

.btn-icon {
  padding: 6px 10px;
  font-size: 15px;
  line-height: 1;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.reorder-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.error-box {
  background: #fdecea;
  color: #b3261e;
  border: 1px solid #f3b7b1;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 14px;
}

.success-box {
  background: #e9f7ee;
  color: #1e7a3c;
  border: 1px solid #b7e3c4;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 14px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.search-form {
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}

table.registry {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

table.registry th {
  text-align: left;
  background: var(--bordo);
  color: var(--beige);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 12px 16px;
}

table.registry td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-light);
  font-size: 14px;
  vertical-align: middle;
}

table.registry tr:last-child td {
  border-bottom: none;
}

table.registry tr:hover {
  background: #fbf7f4;
}

.file-title {
  font-weight: 700;
  color: var(--bordo-dark);
}

.file-desc {
  color: var(--gray);
  font-size: 13px;
  margin-top: 2px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: var(--beige);
  color: var(--bordo);
  text-transform: uppercase;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.qr-box {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.qr-box img {
  width: 240px;
  height: 240px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-light);
  background: var(--beige);
}

.qr-missing {
  width: 240px;
  height: 240px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--gray-light);
  background: var(--beige);
  color: var(--gray);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  font-size: 14px;
}

.meta-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  font-size: 14px;
}

.meta-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.meta-list li span:first-child {
  color: var(--gray);
}

.link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--beige);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  word-break: break-all;
  margin-bottom: 20px;
}

.section {
  margin-bottom: 32px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--bordo-dark);
}

.divider {
  height: 1px;
  background: var(--gray-light);
  margin: 28px 0;
}

.footer {
  text-align: center;
  padding: 20px;
  color: var(--gray);
  font-size: 13px;
}

/* Клиентская страница файла */
.viewer-header {
  background: var(--bordo);
  padding: 26px 32px;
  color: var(--beige);
}

.viewer-header .brand {
  margin-bottom: 14px;
}

.viewer-header h1 {
  color: var(--beige);
  font-size: 22px;
  margin-bottom: 4px;
}

.viewer-header p {
  color: var(--gray-light);
  margin: 0;
  font-size: 14px;
}

.viewer-body {
  padding: 28px 24px 60px;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

.viewer-frame {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
}

.viewer-frame img {
  max-width: 100%;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

.viewer-frame iframe {
  width: 100%;
  height: 80vh;
  border: none;
  border-radius: 8px;
}

.download-bar {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.file-description {
  margin: 14px 4px 0;
  color: var(--gray);
  font-size: 14px;
  text-align: center;
}

.not-found {
  text-align: center;
  padding: 100px 20px;
}

.not-found .mark {
  width: 64px;
  height: 64px;
  color: var(--bordo);
  margin-bottom: 20px;
}

/* Несколько файлов в одной ссылке */

.file-row {
  border: 1.5px solid var(--gray-light);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--beige);
}

.file-row .field-file {
  padding: 14px;
}

.file-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

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

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form input[type='text'] {
  padding: 8px 10px;
  border: 1.5px solid var(--gray-light);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  min-width: 160px;
}

.inline-form input[type='file'] {
  font-size: 13px;
  max-width: 220px;
}

.file-block {
  margin-bottom: 28px;
}

.file-block:last-child {
  margin-bottom: 0;
}

.file-block-label {
  font-weight: 700;
  color: var(--bordo-dark);
  font-size: 16px;
  margin-bottom: 10px;
}

.viewer-frame video {
  max-width: 100%;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

.url-frame {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 20px;
  flex-wrap: wrap;
  text-align: left;
}

.url-link {
  font-weight: 700;
  color: var(--bordo);
  font-size: 16px;
  word-break: break-all;
}

.url-link:hover {
  text-decoration: underline;
}

.url-desc {
  color: var(--gray);
  font-size: 14px;
}

@media (max-width: 640px) {
  .header {
    padding: 14px 18px;
  }
  main {
    padding: 24px 16px 48px;
  }
  table.registry thead {
    display: none;
  }
  table.registry,
  table.registry tbody,
  table.registry tr,
  table.registry td {
    display: block;
    width: 100%;
  }
  table.registry tr {
    padding: 14px 0;
    border-bottom: 1px solid var(--gray-light);
  }
  table.registry td {
    border-bottom: none;
    padding: 4px 0;
  }
}
