:root {
  --bg: #f8f5f2;
  --card: #ffffff;
  --text: #333333;
  --accent: #8b5e3c;
  --accent-light: #d4a373;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 1rem;
}

header {
  text-align: center;
  margin-bottom: 1rem;
}

#tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

#tabs button {
  background: var(--card);
  color: var(--accent);
  border: 1px solid var(--accent-light);
}

#tabs button.active {
  background: var(--accent);
  color: white;
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

.two-col {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 700px) {
  .two-col {
    grid-template-columns: 1fr 1fr;
  }
}

ul {
  list-style: none;
  padding: 0;
}

li {
  background: #f0ede9;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

textarea {
  font-family: monospace;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
}

h1 {
  margin: 0;
  color: var(--accent);
}

main {
  display: grid;
  gap: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

section {
  background: var(--card);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

form {
  display: grid;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.9rem;
}

input,
select,
textarea {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
}

select {
  background: white;
  min-height: 2.5rem;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.65rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}

button:hover {
  background: var(--accent-light);
}

pre {
  background: #f0ede9;
  padding: 0.75rem;
  border-radius: 6px;
  min-height: 1.5rem;
  white-space: pre-wrap;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  table-layout: fixed;
}

.data-table th:nth-child(1),
.data-table td:nth-child(1) {
  width: 35%;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  width: 15%;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) {
  width: 12%;
}

.data-table th:nth-child(4),
.data-table td:nth-child(4) {
  width: 18%;
}

.data-table th:nth-child(5),
.data-table td:nth-child(5) {
  width: 20%;
}

.data-table th,
.data-table td {
  padding: 0.6rem 0.4rem;
  border-bottom: 1px solid #eee;
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;
}

.data-table th {
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--accent-light);
}

.data-table tr:hover {
  background: #faf8f6;
}

.data-table code {
  font-size: 0.75rem;
  color: #666;
  word-break: break-all;
}

@media (max-width: 600px) {
  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table th,
  .data-table td,
  .data-table tr {
    display: block;
  }

  .data-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .data-table td {
    border: none;
    border-bottom: 1px solid #eee;
    position: relative;
    padding-left: 40%;
  }

  .data-table td:before {
    position: absolute;
    top: 0.6rem;
    left: 0.4rem;
    width: 35%;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
  }
}

/* stepper */
.stepper {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.stepper input {
  width: 80px;
  text-align: center;
}

.stepper button {
  width: 2rem;
  padding: 0.45rem 0;
  font-size: 1.1rem;
  line-height: 1;
  background: var(--accent-light);
}

.stepper button:hover {
  background: var(--accent);
}

/* dashboard */
.dashboard-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.tile {
  background: #f0ede9;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.tile h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: #666;
}

.tile p {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

.tile.tile-alert {
  background: #f8d7da;
  color: #721c24;
}

.tile.tile-alert h3,
.tile.tile-alert p {
  color: #721c24;
}

.dashboard-lists {
  display: grid;
  gap: 1.25rem;
}

.dashboard-group h3 {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-size: 1rem;
}

/* recipe ingredient rows */
.recipe-ing-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.recipe-ing-row input,
.recipe-ing-row select {
  flex: 1 1 100px;
  min-width: 80px;
}

.recipe-ing-row .remove-recipe-ing {
  flex: 0 0 auto;
  background: #b06c5c;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
}

#add-recipe-ingredient {
  margin-bottom: 0.75rem;
  background: var(--accent-light);
}

/* list row delete buttons */
.data-table .delete-row {
  background: #b06c5c;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.status-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-open {
  background: #e6f4ea;
  color: #1e7e34;
}

.status-partial {
  background: #fff3cd;
  color: #856404;
}

.status-closed {
  background: #f8d7da;
  color: #721c24;
}

/* work orders */
.kpi-title {
  margin: 1rem 0 0.5rem;
  color: var(--accent);
  font-size: 1rem;
}

.wo-id {
  font-size: 0.85em;
}

.wo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.wo-actions button {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}


.wo-detail h4 {
  margin: 0.75rem 0 0.35rem;
  color: var(--accent);
  font-size: 0.95rem;
}

.wo-detail .data-table {
  margin-bottom: 0.5rem;
}

.wo-mini-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
}

.wo-mini-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  margin: 0;
}

.wo-mini-form input,
.wo-mini-form select {
  width: 8rem;
  min-width: 6rem;
}

.wo-mini-form button {
  flex: 0 0 auto;
  background: var(--accent-light);
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
}

.wo-blockers {
  color: #721c24;
  font-size: 0.9rem;
  margin: 0.25rem 0;
}

.status-draft {
  background: #eee9e4;
  color: #5a4a3a;
}

.status-released {
  background: #fff3cd;
  color: #856404;
}

.status-in_progress {
  background: #e6f4ea;
  color: #1e7e34;
}

.status-completed {
  background: #e3ecf7;
  color: #2a5885;
}

.status-cancelled {
  background: #f8d7da;
  color: #721c24;
}

/* reports */
.report-range {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.report-days.active {
  background: var(--accent);
  color: #fff;
}
.report-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.chart-box {
  background: var(--card);
  border-radius: 8px;
  padding: 1rem;
}
