:root {
  --bg: #f7f1e8;
  --panel: #fffdf8;
  --ink: #2c1810;
  --muted: #7a6558;
  --line: #eadfce;
  --accent: #c4783a;
  --dark: #2c1810;
  --danger: #b42318;
  --ok: #2f7d4a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

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

.error {
  min-height: 1.4em;
  color: var(--danger);
  font-size: 14px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 12px;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.modal-card,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 12px 32px rgba(44, 24, 16, 0.06);
}

.login-card {
  width: min(420px, 100%);
  padding: 32px;
  display: grid;
  gap: 14px;
}

.login-card h1,
.page-header h2,
.modal-head h3 {
  margin: 0;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

button.primary,
.login-card button[type='submit'] {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: var(--dark);
  color: var(--bg);
}

button.ghost,
.sidebar-user button,
#modal-close {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 8px 14px;
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 24px 18px;
  background: #efe6d8;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: grid;
  gap: 4px;
}

.brand span,
.sidebar-user span {
  color: var(--muted);
  font-size: 13px;
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.sidebar nav button {
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 10px 12px;
}

.sidebar nav button.active,
.sidebar nav button:hover {
  background: var(--dark);
  color: var(--bg);
}

.sidebar-user {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

main {
  padding: 28px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.chip {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: #efe6d8;
  color: #6b5344;
}

.chip.active {
  background: var(--dark);
  color: var(--bg);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: 16px;
  overflow: hidden;
}

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

th {
  background: #f3eadc;
  font-weight: 600;
}

.thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 10px;
  background: #efe6d8;
}

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

.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.badge.pending {
  background: #fbe7d4;
  color: #9a4e12;
}

.badge.completed {
  background: #d9f0e1;
  color: var(--ok);
}

.badge.cancelled {
  background: #eee7e0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.preview-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preview-row img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 12px;
  background: #efe6d8;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(44, 24, 16, 0.35);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-card {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 20px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.order-meta {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.role-select {
  width: auto;
  min-width: 132px;
  padding: 6px 10px;
  font-size: 13px;
}

.role-select:disabled {
  background: #f3eadc;
  color: var(--muted);
  cursor: default;
}

.setting-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.setting-card strong {
  display: block;
  margin-bottom: 6px;
}

.setting-card p {
  margin: 0;
  max-width: 520px;
  line-height: 1.5;
}

#settings-status {
  margin: 12px 4px 0;
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #d9ccbc;
  transition: background 0.2s ease;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(44, 24, 16, 0.2);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-track {
  background: var(--ok);
}

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch input:disabled + .switch-track {
  opacity: 0.6;
}

.empty {
  padding: 48px;
  text-align: center;
  color: var(--muted);
}

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

  .sidebar {
    flex-direction: row;
    align-items: center;
    overflow: auto;
  }

  .sidebar nav {
    grid-auto-flow: column;
  }

  .sidebar-user {
    margin-top: 0;
  }

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