:root {
  --red: #e4002b;
  --red-dark: #bc0023;
  --ink: #2f2f33;
  --muted: #6b6b73;
  --line: #e8e5e1;
  --paper: #ffffff;
  --wash: #f7f5f2;
  --shadow: 0 8px 24px rgba(25, 24, 22, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans JP", sans-serif;
  line-height: 1.6;
}

.topbar {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.topbar-actions form {
  margin: 0;
}

.logout-button {
  cursor: pointer;
}

.eyebrow {
  color: var(--red);
  font-weight: 700;
  margin: 0 0 0.15rem;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.7rem;
}

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

h3 {
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

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

main {
  width: min(1180px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
  display: grid;
  gap: 1rem;
}

.ghost-link,
.button {
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  min-height: 42px;
  padding: 0.65rem 1rem;
  text-decoration: none;
}

.ghost-link,
.button.secondary {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.button.primary {
  background: var(--red);
  border: 1px solid var(--red);
  color: #fff;
}

.button:hover {
  cursor: pointer;
}

.button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.operation-panel,
.panel,
.flow article {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.operation-panel {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  padding: 1rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.spinner {
  animation: spin 0.8s linear infinite;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  height: 1em;
  margin-right: 0.45rem;
  vertical-align: -0.15em;
  width: 1em;
}

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

.flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.flow article {
  padding: 1rem;
}

.flow span {
  align-items: center;
  background: var(--red);
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  font-weight: 700;
  height: 28px;
  justify-content: center;
  margin-bottom: 0.6rem;
  width: 28px;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
}

.tab {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  flex: 0 0 auto;
  font: inherit;
  font-weight: 700;
  padding: 0.7rem 1rem;
}

.tab.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.panel {
  display: none;
  padding: 1rem;
}

.panel.active {
  display: grid;
  gap: 1rem;
}

.section-head,
.modifier-product-head,
.modifier-group-head {
  align-items: flex-end;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.section-head input,
.tie-in-builder input,
.tie-in-builder select,
.table-wrap input {
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  padding: 0.65rem 0.75rem;
}

.section-head input {
  width: min(420px, 100%);
}

.sub-section-head {
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
  padding-top: 1rem;
}

.import-result {
  background: #fff8e8;
  border: 1px solid #f1d28a;
  border-radius: 8px;
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem;
}

.import-result[hidden] {
  display: none;
}

.import-summary {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.import-summary span {
  color: var(--muted);
  font-weight: 700;
}

.tie-in-builder {
  align-items: end;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) 110px auto;
  padding: 1rem;
}

.tie-in-builder label {
  display: grid;
  gap: 0.35rem;
}

.tie-in-builder label span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.tie-in-builder select,
.tie-in-builder input {
  width: 100%;
}

.modifier-editor {
  display: grid;
  gap: 1rem;
}

.modifier-product {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.modifier-product-head {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 1rem;
}

.modifier-product-head h3 {
  margin-bottom: 0.15rem;
}

.modifier-product-head p,
.modifier-group-head span {
  margin: 0;
}

.modifier-product-head > span {
  color: var(--red);
  font-weight: 700;
  white-space: nowrap;
}

.modifier-group {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
}

.modifier-group:last-child {
  border-bottom: none;
}

.modifier-group-head strong,
.modifier-group-head span {
  display: block;
}

.modifier-options {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.modifier-option {
  align-items: center;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
}

.modifier-option input {
  accent-color: var(--red);
}

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

.table-actions {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

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

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

.select-column {
  text-align: center;
  width: 48px;
}

th {
  color: var(--muted);
  font-size: 0.9rem;
}

td input {
  width: 100%;
}

.check-cell {
  align-items: center;
  display: inline-flex;
  gap: 0.45rem;
  font-weight: 700;
}

.check-cell input {
  accent-color: var(--red);
  height: 18px;
  width: 18px;
}

.id-name {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0.35rem 0 0;
}

.delete-row-btn {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--red);
  cursor: pointer;
  font-weight: 700;
  padding: 0.55rem 0.75rem;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 1.5rem;
  text-align: center;
}

.toast-container {
  display: grid;
  gap: 0.5rem;
  position: fixed;
  right: 1rem;
  top: 1rem;
  z-index: 50;
}

.toast {
  background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: #fff;
  padding: 0.8rem 1rem;
}

.toast.success {
  background: #237a3b;
}

.toast.error {
  background: var(--red-dark);
}

.login-page {
  min-height: 100vh;
}

.login-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  width: min(460px, calc(100% - 2rem));
}

.login-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.login-form {
  display: grid;
  gap: 1rem;
}

.login-form label {
  display: grid;
  gap: 0.35rem;
}

.login-form span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.login-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  padding: 0.75rem;
}

.login-error {
  color: var(--red-dark);
  font-weight: 700;
  margin-bottom: 0;
}

@media (max-width: 760px) {
  .operation-panel,
  .section-head,
  .modifier-product-head,
  .modifier-group-head {
    align-items: stretch;
    flex-direction: column;
  }

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

  .actions,
  .section-actions,
  .button,
  .section-head input {
    width: 100%;
  }

  .tie-in-builder {
    grid-template-columns: 1fr;
  }
}
