:root {
  color-scheme: light;
  --ink: #1f2529;
  --muted: #68737c;
  --line: #dfe5e8;
  --paper: #ffffff;
  --soft: #f5f7f6;
  --accent: #0b766f;
  --accent-2: #c4472d;
  --gold: #a66b16;
  --ok: #166534;
  --warn: #9a3412;
  --danger: #a11b1b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #eef2f1;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.manual-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(320px, 1.3fr);
  gap: 14px;
  align-items: center;
  padding: 14px clamp(14px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.top-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px 150px auto;
  gap: 8px;
}

.search,
select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

.session-controls {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
}

.session-controls span {
  max-width: 150px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-controls .save-feedback {
  max-width: none;
  color: var(--ok);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(11, 118, 111, 0.92), rgba(196, 71, 45, 0.72)),
    #eef2f1;
}

.login-panel {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 50px rgba(22, 36, 34, 0.2);
}

.login-brand {
  margin-bottom: 20px;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.login-form input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

.login-error {
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: var(--danger);
  background: #fff1f2;
  font-size: 13px;
  font-weight: 900;
}

.manual-main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 34px) 52px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 22px;
  align-items: end;
  min-height: 260px;
  padding: 28px;
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(105deg, rgba(24, 72, 64, 0.95), rgba(24, 72, 64, 0.7)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='520' viewBox='0 0 1200 520'%3E%3Crect width='1200' height='520' fill='%23edf5f2'/%3E%3Crect x='760' y='92' width='280' height='190' rx='18' fill='%23fff7ed'/%3E%3Crect x='790' y='126' width='220' height='18' rx='9' fill='%230b766f' opacity='.8'/%3E%3Crect x='790' y='166' width='168' height='18' rx='9' fill='%23c4472d' opacity='.82'/%3E%3Crect x='790' y='206' width='196' height='18' rx='9' fill='%23a66b16' opacity='.75'/%3E%3Ccircle cx='975' cy='366' r='92' fill='%23f8dfca'/%3E%3Cellipse cx='975' cy='366' rx='62' ry='24' fill='%23c4472d'/%3E%3Cellipse cx='926' cy='343' rx='34' ry='16' fill='%230b766f'/%3E%3Crect x='120' y='342' width='340' height='52' rx='26' fill='%23ffffff' opacity='.75'/%3E%3Cpath d='M156 368h258' stroke='%23a66b16' stroke-width='13' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

.hero h2 {
  max-width: 760px;
  margin: 8px 0 10px;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.03;
}

.hero p {
  max-width: 740px;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.75;
}

.kicker {
  display: inline-flex;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  font-weight: 800;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hero-stats div {
  min-height: 96px;
  display: grid;
  place-content: center;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  text-align: center;
}

.hero-stats strong {
  font-size: 28px;
}

.hero-stats span {
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.tab {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-weight: 800;
}

.tab.active {
  border-color: rgba(11, 118, 111, 0.35);
  color: var(--accent);
  background: #e8f5f3;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.section-head h2 {
  margin: 0;
  font-size: 22px;
}

.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.recipe-workspace {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(220px, 300px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.inventory-workspace {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(220px, 310px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.sop-dashboard {
  display: grid;
  grid-template-columns: minmax(260px, 1.8fr) repeat(3, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.sop-dashboard > div,
.sop-checkin {
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.sop-dashboard strong {
  color: var(--accent);
  font-size: 28px;
}

.sop-dashboard span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sop-checkin {
  color: #fff;
  background: var(--accent);
}

.sop-checkin strong,
.sop-checkin span {
  color: #fff;
}

.sop-grid {
  display: grid;
  gap: 12px;
}

.sop-task {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.sop-task.completed {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.sop-task-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.sop-task h3 {
  margin: 4px 0 4px;
  font-size: 17px;
}

.sop-task p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sop-time {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--accent);
  background: #e8f5f3;
  font-weight: 900;
}

.sop-status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.sop-status.done {
  color: var(--ok);
  background: #dcfce7;
}

.sop-status.due {
  color: var(--danger);
  background: #fee2e2;
}

.sop-status.pending {
  color: var(--warn);
  background: #ffedd5;
}

.sop-task ul {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.62;
}

.sop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.recipe-folder-panel,
.recipe-dish-panel {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 112px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.recipe-dish-panel {
  top: 92px;
}

.recipe-panel-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.recipe-panel-head strong {
  font-size: 14px;
}

.recipe-panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.recipe-folder-list,
.recipe-dish-list {
  display: grid;
}

.recipe-folder-btn,
.recipe-dish-row {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.recipe-folder-btn:last-child,
.recipe-dish-row:last-child {
  border-bottom: 0;
}

.recipe-folder-btn:hover,
.recipe-dish-row:hover {
  background: #eef7f5;
}

.recipe-folder-btn.active {
  color: var(--accent);
  background: #e8f5f3;
  box-shadow: inset 4px 0 0 var(--accent);
}

.recipe-folder-btn.drop-target {
  background: #fff7e8;
  box-shadow: inset 0 0 0 2px var(--gold);
}

.recipe-folder-btn span,
.recipe-dish-row span span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 900;
}

.recipe-folder-btn strong {
  min-width: 28px;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: #f2f5f4;
  font-size: 12px;
  text-align: center;
}

.recipe-dish-row {
  cursor: grab;
}

.recipe-dish-row[draggable="false"] {
  cursor: pointer;
}

.recipe-dish-row:active {
  cursor: grabbing;
}

.recipe-dish-row.dragging {
  opacity: 0.55;
}

.recipe-dish-row.drop-before {
  box-shadow: inset 0 3px 0 var(--accent);
}

.recipe-dish-row.drop-after {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.recipe-dish-row > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.recipe-dish-row small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.recipe-grid,
.standard-grid,
.prep-grid {
  display: grid;
  gap: 12px;
}

.recipe-card,
.standard-card,
.prep-card,
.inventory-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.recipe-card.hidden,
tr.hidden {
  display: none;
}

.recipe-head {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.recipe-photo {
  width: 118px;
  min-height: 92px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.recipe-photo img,
.table-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recipe-photo.missing {
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(11, 118, 111, 0.1), rgba(196, 71, 45, 0.08)),
    #fff;
  font-size: 12px;
  font-weight: 900;
}

.recipe-head small {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.recipe-head h3 {
  margin: 4px 0 7px;
  font-size: 24px;
}

.recipe-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.video-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.online-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.online-chip-row span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  color: #7c2d12;
  background: #ffedd5;
  font-size: 12px;
  font-weight: 800;
}

.video-link,
.tag,
.mini-btn {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.video-link {
  color: #fff;
  gap: 7px;
  background: #ff0033;
  box-shadow: 0 6px 14px rgba(255, 0, 51, 0.18);
}

.tag {
  color: var(--accent);
  background: #e8f5f3;
}

.youtube-icon {
  width: 24px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
  color: #ff0033;
  background: #fff;
  font-size: 10px;
  line-height: 1;
}

.mini-btn {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.mini-btn.danger {
  border-color: #fecaca;
  color: var(--danger);
  background: #fff1f2;
}

.editor-panel {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fbfb;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.editor-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.editor-grid label.wide {
  grid-column: 1 / -1;
}

.editor-grid input,
.editor-grid select,
.editor-grid textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 13px;
  resize: vertical;
}

.inline-select {
  min-width: 128px;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.category-manager {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.category-manager-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.save-feedback {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ok);
  background: #dcfce7;
  font-size: 13px;
  font-weight: 900;
}

.category-edit-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 8px;
}

.category-edit-list.editing {
  grid-template-columns: 1fr;
}

.category-view-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
}

.category-view-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 900;
}

.category-view-row strong {
  min-width: 28px;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  text-align: center;
}

.category-edit-row {
  display: grid;
  grid-template-columns: 58px minmax(120px, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.category-edit-row.dragging {
  opacity: 0.55;
}

.category-edit-row.drop-before {
  box-shadow: inset 0 3px 0 var(--accent);
}

.category-edit-row.drop-after {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.drag-handle {
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--accent);
  background: #e8f5f3;
  font-size: 12px;
  font-weight: 900;
  cursor: grab;
}

.category-edit-row input {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.source-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.status-pill,
.image-missing {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.linked {
  color: #166534;
  background: #dcfce7;
}

.status-pill.missing,
.image-missing {
  color: #9a3412;
  background: #ffedd5;
}

.table-thumb {
  width: 72px;
  height: 54px;
  display: block;
  border-radius: 8px;
}

.recipe-body {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  gap: 14px;
  padding: 16px;
}

.recipe-body h4,
.standard-card h3,
.prep-card h3,
.inventory-panel h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.formula-list {
  display: grid;
  gap: 6px;
}

.formula-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.formula-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formula-row strong {
  color: var(--accent-2);
}

.note-block {
  margin-top: 10px;
  padding: 10px;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  color: #58390b;
  background: #fff7ed;
  line-height: 1.55;
}

.danger-block {
  border-left-color: var(--danger);
  color: #7f1d1d;
  background: #fff1f2;
}

.recipe-body ol,
.recipe-body ul,
.standard-card ul,
.prep-card ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.62;
}

.subsection {
  margin-top: 14px;
}

.standard-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.standard-card,
.prep-card,
.inventory-panel {
  padding: 15px;
}

.text-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.text-card-head h3 {
  min-width: 0;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.standard-card .inline-editor,
.prep-card .inline-editor {
  padding: 0;
  border-bottom: 0;
  background: transparent;
}

.inventory-panel {
  display: grid;
  gap: 10px;
}

.inventory-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.inventory-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.inventory-card-head h3 {
  margin: 3px 0 0;
  font-size: 17px;
}

.inventory-card-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

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

.inventory-card .formula-list {
  padding: 12px;
}

.inventory-editor {
  border-bottom: 1px solid var(--line);
}

.standard-card h3 {
  color: var(--accent);
}

.prep-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: var(--muted);
  background: #f7faf9;
  font-size: 12px;
}

td strong {
  color: var(--ink);
}

.empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  text-align: center;
}

@media (max-width: 1080px) {
  .manual-top,
  .hero,
  .recipe-workspace,
  .inventory-workspace,
  .sop-dashboard,
  .recipe-body,
  .standard-grid,
  .prep-grid {
    grid-template-columns: 1fr;
  }

  .recipe-folder-panel,
  .recipe-dish-panel {
    position: static;
    max-height: 360px;
  }

  .hero-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .top-controls {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 20px;
  }

  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recipe-head,
  .section-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .recipe-photo {
    width: 100%;
    min-height: 130px;
  }

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

  .category-edit-list,
  .category-edit-row {
    grid-template-columns: 1fr;
  }

  .video-list {
    justify-content: flex-start;
  }
}
