:root {
  --black: #090806;
  --black-2: #14100c;
  --paper: #fff7e8;
  --paper-2: #f3e4c8;
  --sand: #d9bd80;
  --sand-2: #b8934e;
  --text: #14100c;
  --muted: #5d5142;
  --line: #cdb88e;
  --danger: #8f241c;
  --success: #155c49;
  --focus: #ffd166;
  --shadow: 0 14px 30px rgba(9, 8, 6, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--black);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--paper-2);
  font-size: 16px;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

::selection {
  background: var(--black);
  color: var(--paper);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1.08rem;
  line-height: 1.2;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 100;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--focus);
  color: var(--black);
  font-weight: 900;
  text-decoration: none;
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--black);
}

.auth-panel {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid #6f5d39;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.brand-block,
.topbar-brand,
.user-menu,
.form-header,
.section-title,
.page-heading,
.check-row {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 14px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
  background: var(--black);
  color: var(--sand);
  font-weight: 900;
}

.form-stack,
.admin-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 800;
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #9f895d;
  border-radius: 8px;
  background: #fffdf7;
  color: var(--text);
}

textarea.input {
  resize: vertical;
}

.input:focus-visible {
  outline-offset: 2px;
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--black);
  border-radius: 8px;
  background: var(--paper);
  color: var(--black);
  font-weight: 900;
  text-decoration: none;
}

.button:hover {
  background: #f7ecd7;
}

.button:active {
  transform: translateY(1px);
}

.button-primary {
  background: var(--black);
  color: var(--paper);
}

.button-primary:hover {
  background: #241d15;
}

.button-ghost {
  border-color: #7b6848;
  background: transparent;
}

.button-danger {
  border-color: var(--danger);
  background: #fff0ea;
  color: var(--danger);
}

.button-small {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.92rem;
}

.button-full {
  width: 100%;
}

.switch-auth {
  margin: 0;
  text-align: center;
}

.switch-auth a {
  color: var(--black);
  font-weight: 900;
}

.form-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.94rem;
}

.form-message-error {
  color: var(--danger);
}

.form-message-success {
  color: var(--success);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  min-height: 70px;
  padding: 12px clamp(14px, 4vw, 42px);
  border-bottom: 1px solid #6f5d39;
  background: var(--black);
  color: var(--paper);
}

.topbar-brand {
  gap: 10px;
  color: var(--paper);
  font-weight: 900;
  text-decoration: none;
}

.topbar-brand .brand-mark,
.user-menu .avatar {
  background: var(--sand);
  color: var(--black);
}

.topbar-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.topbar-nav a,
.admin-tabs a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  font-weight: 900;
}

.topbar-nav a:hover,
.topbar-nav a.is-active {
  background: #2a2117;
  color: var(--sand);
}

.user-menu {
  gap: 10px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 8px;
  font-weight: 900;
}

.user-copy {
  display: grid;
  min-width: 0;
}

.user-copy strong,
.user-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy span {
  color: var(--sand);
  font-size: 0.85rem;
}

.main-view {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 64px;
}

.page-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.tabs,
.admin-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 18px;
}

.tab {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border: 1px solid #8f784f;
  border-radius: 8px;
  background: var(--paper);
  color: var(--black);
  font-weight: 900;
  white-space: nowrap;
}

.tab:hover {
  background: #f7ecd7;
}

.tab span,
.section-title span {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  background: #ead8b5;
  color: var(--black);
}

.tab.is-active {
  background: var(--black);
  color: var(--paper);
}

.tab.is-active span {
  background: var(--sand);
  color: var(--black);
}

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

.app-card,
.admin-form,
.admin-list,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.app-card {
  display: grid;
  min-height: 100%;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
}

.app-card:hover {
  transform: translateY(-2px);
}

.app-card:active {
  transform: translateY(0);
}

.app-media {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--black-2);
}

.app-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-fallback {
  display: inline-grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border: 2px solid var(--sand);
  border-radius: 8px;
  color: var(--sand);
  font-size: 1.55rem;
  font-weight: 900;
}

.app-card-body {
  display: grid;
  align-content: space-between;
  gap: 16px;
  padding: 16px;
}

.app-description {
  margin: 8px 0 0;
  color: var(--muted);
}

.empty-state {
  padding: 28px;
  text-align: center;
}

.empty-state p {
  max-width: 520px;
  margin: 8px auto 0;
}

.loading-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  gap: 12px;
  color: var(--muted);
}

.loader {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--black);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.admin-tabs {
  margin-bottom: 14px;
}

.admin-tabs a {
  border: 1px solid #8f784f;
  background: var(--paper);
}

.admin-tabs a:hover,
.admin-tabs a.is-active {
  background: var(--black);
  color: var(--paper);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-form,
.admin-list {
  padding: 18px;
}

.form-header,
.section-title {
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  margin-bottom: 14px;
}

.inline-warning {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--sand-2);
  border-radius: 8px;
  background: #fff2d5;
  color: #5c3d08;
}

.check-row {
  grid-template-columns: auto 1fr;
  justify-content: start;
  gap: 10px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.image-editor {
  display: grid;
  gap: 10px;
}

.image-preview {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--black-2);
  color: var(--sand);
  font-weight: 900;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fffdf7;
}

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

th {
  background: #ead8b5;
  color: var(--black);
  font-size: 0.84rem;
  text-transform: uppercase;
}

td span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

tr:last-child td {
  border-bottom: 0;
}

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

.table-select {
  min-width: 132px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 8px;
  font-weight: 900;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-active {
  background: #e4f2ec;
  color: var(--success);
}

.status-muted {
  background: #ece1cf;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 13px 16px;
  border-radius: 8px;
  background: var(--black);
  color: var(--paper);
  box-shadow: var(--shadow);
  font-weight: 900;
}

.toast-error {
  background: var(--danger);
  color: white;
}

.toast-success {
  background: var(--success);
  color: white;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 840px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .topbar-nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    order: 3;
  }

  .user-copy {
    display: none;
  }

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

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .auth-panel {
    padding: 20px;
  }

  .main-view {
    width: min(100% - 22px, 1240px);
    padding-top: 24px;
  }

  .topbar {
    gap: 12px;
    padding: 10px 12px;
  }

  .topbar-brand span:last-child {
    display: none;
  }

  .user-menu {
    gap: 7px;
  }

  .button {
    padding-left: 11px;
    padding-right: 11px;
  }

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