:root {
  --bg: #f5f8fc;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #dde3ee;
  --primary: #1465d9;
  --danger: #d32f2f;
  --ok: #12805c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, #f8fbff, #f2f7ff 45%, #eef4ff);
  scroll-behavior: smooth;
  line-height: 1.45;
  overflow-x: hidden;
}

header {
  padding: 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

header h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0.3px;
}

header p {
  margin: 8px 0 0;
  color: var(--muted);
}

main {
  padding: 20px;
  display: grid;
  gap: 16px;
  max-width: 1360px;
  margin: 0 auto;
  width: 100%;
}

.quick-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(4px);
}

.quick-nav a {
  text-decoration: none;
  color: #0f4aa9;
  background: #eaf2ff;
  border: 1px solid #cfe0ff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.quick-nav a:hover {
  background: #dce9ff;
}

.quick-nav a.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  scroll-margin-top: 70px;
  min-width: 0;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 19px;
  font-weight: 650;
}

.two-col {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-form {
  display: grid;
  gap: 10px;
}

.grid-form > button {
  justify-self: start;
  width: auto;
  min-width: 140px;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-row > button {
  min-width: 0;
}

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

#preview-result {
  white-space: pre-wrap;
  font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 13px;
  color: #23314d;
  background: #f7faff;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
}

label {
  display: grid;
  gap: 4px;
  font-size: 14px;
  color: var(--muted);
}

input,
select,
button {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}

button {
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.95);
}

table {
  width: 100%;
  border-collapse: collapse;
}

.table-scroll {
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-scroll table {
  border: 0;
}

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

.tag-alert,
.tag-ok,
.tag-prepare,
.tag-production,
.tag-stock {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  color: #fff;
  font-size: 12px;
}

.tag-alert {
  background: var(--danger);
}

.tag-ok {
  background: var(--ok);
}

.tag-prepare {
  background: #ef6c00;
}

.tag-production {
  background: #0277bd;
}

.tag-stock {
  background: #2e7d32;
}

#alert-list {
  margin: 0;
  padding-left: 18px;
}

#toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: #121212;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease;
}

#toast.show {
  opacity: 0.95;
  transform: translateY(0);
}

#toast.error {
  background: #b71c1c;
}

@media (max-width: 720px) {
  header h1 {
    font-size: 20px;
  }

  main {
    padding: 12px;
  }

  th,
  td {
    font-size: 12px;
  }

  .btn-row {
    grid-template-columns: 1fr;
  }
}

.table-scroll thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

details > summary {
  cursor: pointer;
  color: var(--text);
}

.col-subsidiary {
  min-width: 180px;
  width: 180px;
  white-space: nowrap;
}

.col-order {
  min-width: 130px;
  white-space: nowrap;
}

.col-name {
  min-width: 170px;
  white-space: nowrap;
}

.col-size {
  min-width: 140px;
  white-space: nowrap;
}

.col-qty {
  min-width: 98px;
  text-align: right;
  white-space: nowrap;
}

.col-money {
  min-width: 100px;
  text-align: right;
  white-space: nowrap;
}

.col-status {
  min-width: 72px;
  white-space: nowrap;
}
