:root {
  --paper: #e6e9e2;
  --paper-strong: #dde1d9;
  --ink: #171915;
  --ink-soft: #3f433b;
  --muted: #51574e;
  --line: rgba(23, 25, 21, 0.2);
  --signal: #b93214;
  --acid: #c9f45a;
  --white: #fff;
  --danger: #b6281b;
  --display: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--body);
  background: var(--paper);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

:where(button, a, input):focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
}

.admin-header :where(button, a):focus-visible {
  outline-color: var(--acid);
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 78px;
  padding: 0 clamp(20px, 4vw, 58px);
  color: var(--white);
  background: var(--ink);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--ink);
  font: 700 20px/1 var(--mono);
  background: var(--acid);
  clip-path: polygon(0 0, 100% 0, 100% 73%, 76% 100%, 0 100%);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-copy strong {
  font-size: 18px;
}

.brand-copy small {
  color: rgba(255, 255, 255, 0.62);
  font: 10px/1.2 var(--mono);
}

.session-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.admin-main {
  width: min(1440px, 100%);
  min-height: calc(100vh - 78px);
  margin: 0 auto;
  padding: clamp(28px, 4vw, 56px);
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 190px);
  place-items: center;
}

.login-panel {
  width: min(450px, 100%);
  padding: clamp(28px, 5vw, 48px);
  background: rgba(255, 255, 255, 0.38);
  border: 1px solid var(--ink);
}

.login-panel h1,
.page-heading h1,
.dialog-heading h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
}

.login-panel h1 {
  font-size: 46px;
}

.login-copy {
  margin: 12px 0 32px;
  color: var(--muted);
  line-height: 1.7;
}

.stack-form {
  display: flex;
  flex-direction: column;
}

.field-label {
  margin: 0 0 9px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}

.text-input {
  width: 100%;
  min-height: 54px;
  margin-bottom: 22px;
  padding: 0 15px;
  color: var(--ink);
  font-size: 16px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 3px;
  outline: 0;
}

.text-input:focus {
  background: var(--white);
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(201, 244, 90, 0.82);
}

.form-error {
  min-height: 20px;
  margin: -8px 0 14px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.primary-button,
.secondary-button,
.icon-button,
.text-button,
.upload-zone {
  border: 0;
  cursor: pointer;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
  padding: 0 18px 0 22px;
  color: var(--white);
  font-weight: 700;
  background: var(--signal);
  border-radius: 3px;
  box-shadow: 0 8px 18px rgba(23, 25, 21, 0.16);
}

.primary-button:hover {
  background: #9f2b10;
}

.primary-button:disabled {
  color: #4e544b;
  cursor: not-allowed;
  background: #d5d3ca;
  box-shadow: none;
}

.primary-button.compact {
  min-height: 44px;
  padding: 0 16px;
}

.primary-button.compact .icon {
  order: -1;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 15px;
  font-weight: 650;
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 3px;
}

.secondary-button:hover {
  background: var(--acid);
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
}

.admin-header .icon-button {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.24);
}

.icon-button:hover {
  background: var(--acid);
  color: var(--ink);
  border-color: var(--ink);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 18px 0 34px;
}

.page-heading h1 {
  font-size: clamp(42px, 5vw, 66px);
  line-height: 1;
}

.metric-row {
  display: flex;
  gap: 36px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 112px;
}

.metric small {
  color: var(--muted);
  font: 10px/1.2 var(--mono);
}

.metric strong {
  font: 700 18px/1.2 var(--mono);
}

.data-panel {
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid var(--ink);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.search-form {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: min(420px, 100%);
  min-height: 44px;
  padding: 0 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--line);
  border-radius: 3px;
}

.search-form:focus-within {
  color: var(--ink);
  background: var(--white);
  border-color: var(--ink);
}

.search-form input {
  min-width: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

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

table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font: 700 11px/1.3 var(--mono);
}

td {
  font-size: 14px;
}

td.price-cell {
  font: 600 15px/1.3 var(--mono);
}

td.time-cell {
  color: var(--muted);
  font: 12px/1.4 var(--mono);
}

.actions-column {
  width: 116px;
  text-align: right;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.row-actions .icon-button {
  width: 36px;
  height: 36px;
}

.row-actions .icon {
  width: 17px;
  height: 17px;
}

.row-actions .delete-button:hover {
  color: var(--white);
  background: var(--danger);
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 64px 24px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
  font-family: var(--display);
  font-size: 28px;
  font-weight: 500;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
}

.table-footer > span {
  color: var(--muted);
  font: 11px/1.4 var(--mono);
}

.pagination {
  display: flex;
  gap: 8px;
}

.sheet-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 5px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.34);
}

.sheet-dialog::backdrop {
  background: rgba(13, 15, 12, 0.78);
  backdrop-filter: blur(4px);
}

.sheet-dialog > form,
.sheet-dialog > .dialog-heading,
.sheet-dialog > .upload-zone,
.sheet-dialog > .template-row,
.sheet-dialog > .form-error,
.sheet-dialog > .primary-button {
  margin-right: clamp(22px, 5vw, 48px);
  margin-left: clamp(22px, 5vw, 48px);
}

.dialog-close {
  position: absolute;
  top: 18px;
  right: 18px;
}

.dialog-heading {
  padding: 42px 0 30px;
}

.dialog-heading h2 {
  font-size: 38px;
}

.dialog-heading + form,
.dialog-heading ~ .upload-zone {
  margin-top: 0;
}

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

.price-input-grid .text-input {
  min-width: 0;
}

.sheet-dialog > form {
  padding-bottom: 42px;
}

.upload-zone {
  display: grid;
  justify-items: center;
  width: calc(100% - clamp(44px, 10vw, 96px));
  min-height: 190px;
  padding: 28px 20px;
  color: var(--ink);
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 3px;
}

.upload-zone:hover {
  background: rgba(201, 244, 90, 0.24);
  border-color: var(--ink);
}

.upload-zone .icon {
  width: 30px;
  height: 30px;
  margin-bottom: 16px;
  color: var(--signal);
}

.upload-zone strong {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 500;
}

.upload-zone span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.template-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 12px;
}

.text-button {
  min-height: 44px;
  padding: 0;
  font-weight: 700;
  background: transparent;
  border-bottom: 1px solid currentColor;
}

.text-button:hover {
  color: var(--signal);
}

.sheet-dialog > .primary-button {
  width: calc(100% - clamp(44px, 10vw, 96px));
  margin-bottom: 38px;
}

.toast {
  position: fixed;
  z-index: 10;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 18px;
  color: var(--white);
  font-size: 13px;
  line-height: 1.5;
  background: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  box-shadow: 0 18px 44px rgba(23, 25, 21, 0.24);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-row {
    width: 100%;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-form {
    width: 100%;
  }

  .toolbar-actions {
    justify-content: flex-end;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  table {
    min-width: 0;
  }

  tbody {
    padding: 0 14px;
  }

  tr {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 18px;
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
  }

  td {
    padding: 0;
    border: 0;
  }

  td::before {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font: 10px/1.2 var(--mono);
    content: attr(data-label);
  }

  td:nth-child(1),
  td:nth-child(2) {
    grid-column: span 1;
  }

  td:nth-child(3),
  td:nth-child(4),
  td:nth-child(5) {
    grid-column: span 1;
  }

  td:nth-child(6) {
    grid-column: 1 / -1;
  }

  td.actions-column {
    position: absolute;
    top: 14px;
    right: 0;
    width: auto;
  }

  td.actions-column::before {
    display: none;
  }

  .row-actions {
    gap: 5px;
  }
}

@media (max-width: 560px) {
  .admin-header {
    min-height: 72px;
    padding: 0 18px;
  }

  .brand-copy small,
  .session-bar > span {
    display: none;
  }

  .admin-main {
    padding: 24px 14px 40px;
  }

  .login-shell {
    min-height: calc(100vh - 130px);
  }

  .login-panel {
    padding: 28px 22px;
  }

  .login-panel h1 {
    font-size: 38px;
  }

  .page-heading h1 {
    font-size: 42px;
  }

  .metric-row {
    gap: 20px;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .secondary-button,
  .primary-button.compact {
    width: 100%;
  }

  .price-input-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

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

@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;
  }
}
