/* 轮胎库存管理 · 样式
   设计基调：浅灰底 + 白卡片 + 深蓝主色，信息密度高但不拥挤 */

:root {
  --brand: #1f5fbf;
  --brand-dark: #16407a;
  --brand-soft: #eef4fd;
  --ink: #16202c;
  --ink-soft: #41506b;
  --muted: #6b7684;
  --line: #e4e7ec;
  --bg: #f2f3f5;
  --ok: #0f7b55;
  --warn: #b45309;
  --danger: #c0392b;
  --radius: 12px;
  font-synthesis-weight: none;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* 带 hidden 属性的元素必须真的隐藏：
   下面 .overlay 写了 display:flex，会盖掉浏览器默认的 [hidden] 规则 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body.is-busy {
  overflow: hidden;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 12px 40px;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 50px;
  margin: 0 -12px 12px;
  padding: 0 12px;
  background: var(--brand-dark);
  color: #fff;
}

.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-align: center;
}

.icon-btn,
.text-btn {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 14px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  min-width: 52px;
}

.icon-btn {
  font-size: 24px;
  line-height: 1;
  min-width: 30px;
  text-align: left;
}

.icon-btn:active,
.text-btn:active {
  background: rgba(255, 255, 255, 0.18);
}

/* ---------- 通用块 ---------- */

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.meta {
  margin: 0 0 8px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 12.5px;
}

.req {
  color: var(--danger);
}

/* ---------- 表单 ---------- */

input,
textarea,
select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 95, 191, 0.12);
}

textarea {
  resize: vertical;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

label {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

label input,
label select {
  margin-top: 5px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 10px;
}

.grid-2 .wide2 {
  grid-column: 1 / -1;
}

/* ---------- 按钮 ---------- */

button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 11px 16px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
}

.btn.wide {
  display: block;
  width: 100%;
}

.btn.primary {
  background: var(--brand);
  color: #fff;
}

.btn.primary:active {
  background: var(--brand-dark);
}

.btn.danger {
  background: #fff;
  color: var(--danger);
  border-color: #edc9c3;
}

.btn.ghost {
  background: #fff;
  color: var(--brand);
  border-color: #cddcf2;
}

.btn.quiet {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  margin-top: 4px;
}

.btn.small {
  padding: 6px 12px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.row {
  display: flex;
  gap: 10px;
  margin-top: 2px;
}

.row > .btn {
  flex: 1;
}

.wide + .preview,
.btn + .preview {
  margin-top: 10px;
}

details.paste {
  margin-top: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

details.paste summary {
  cursor: pointer;
  color: var(--brand);
  font-size: 12.5px;
}

details.paste textarea {
  margin-top: 8px;
}

/* 价格表名称的选择按钮 */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 8px;
}

.chip {
  border: 1px solid #cddcf2;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
}

.chip:active {
  background: #dfeafc;
}

/* ---------- 搜索 ---------- */

.searchbar {
  position: relative;
  margin-bottom: 10px;
}

.searchbar input {
  height: 44px;
  padding-left: 34px;
  padding-right: 36px;
  font-size: 15px;
  border-radius: 10px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-52%);
  color: #98a2b3;
  font-size: 17px;
  pointer-events: none;
}

.clear-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #98a2b3;
  font-size: 14px;
  padding: 8px 10px;
}

/* ---------- 商品列表 ---------- */

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

.list.plain {
  border: 0;
  border-radius: 0;
}

.item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.item:last-child {
  border-bottom: 0;
}

.item:active {
  background: var(--brand-soft);
}

.row-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.model {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.2px;
  font-variant-numeric: tabular-nums;
}

.pattern {
  font-size: 12.5px;
  color: var(--muted);
}

.qty {
  margin-left: auto;
  font-size: 15px;
  font-weight: 600;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
}

.row-sub .series {
  color: var(--ink-soft);
  font-weight: 500;
}

mark {
  background: #fff1a8;
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

.empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  background: #fff;
  border-radius: var(--radius);
}

.list .empty,
.list.plain .empty {
  border-radius: 0;
  padding: 22px 12px;
}

/* ---------- 详情 ---------- */

.detail-head {
  padding-bottom: 12px;
}

.detail-model {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
}

.detail-pattern {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.detail-stock {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.detail-stock-label {
  color: var(--muted);
  font-size: 13px;
}

.detail-stock-value {
  font-size: 20px;
  font-weight: 650;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
}

.fields {
  margin: 0;
}

.field {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.field:last-child {
  border-bottom: 0;
}

.field dt {
  color: var(--muted);
  font-size: 13px;
}

.field dd {
  margin: 0;
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

.card.tip {
  background: #f4faf6;
  border-color: #d6ecdf;
  color: #2b6b4c;
  font-size: 13px;
  padding: 11px 14px;
}

.card.tip p {
  margin: 0;
}

/* ---------- 后台 ---------- */

.whoami {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
}

.whoami .who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.role {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 11.5px;
}

.whoami .text-btn {
  color: var(--brand);
  min-width: auto;
  padding: 4px 6px;
}

/* 导入预览 */

.preview {
  background: var(--brand-soft);
  border: 1px solid #cfdff5;
  border-radius: 10px;
  padding: 12px;
}

.preview-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  word-break: break-all;
}

.preview-count {
  color: var(--brand);
  font-weight: 600;
  white-space: nowrap;
}

.preview-meta {
  margin: 8px 0 0;
  padding-left: 16px;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.7;
}

.preview-sample {
  margin-top: 8px;
  padding: 8px 10px;
  background: #fff;
  border-radius: 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--ink-soft);
  overflow-x: auto;
}

.preview-line {
  white-space: nowrap;
}

.preview .modal-actions {
  margin-top: 12px;
}

.preview .modal-actions .btn {
  flex: 1;
}

/* 出入库流水 */

.move-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.move-row:last-child {
  border-bottom: 0;
}

.move-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.move-action {
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11.5px;
  white-space: nowrap;
}

.move-action.is-in {
  background: #e8f5ee;
  color: var(--ok);
}

.move-action.is-out {
  background: #fdeeea;
  color: var(--danger);
}

.move-model {
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.move-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
}

.move-right {
  text-align: right;
  white-space: nowrap;
}

.move-qty {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.move-price {
  color: var(--muted);
  font-size: 11.5px;
}

/* 管理员名单 */

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.admin-row:last-child {
  border-bottom: 0;
}

.admin-name {
  font-size: 14px;
}

.admin-time {
  color: var(--muted);
  font-size: 11.5px;
}

/* ---------- 提示、遮罩、弹窗 ---------- */

.floating-progress {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  background: rgba(22, 32, 44, 0.86);
  color: #fff;
  border-radius: 999px;
  font-size: 12.5px;
  z-index: 55;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%);
  max-width: 84vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ok);
  color: #fff;
  font-size: 13.5px;
  text-align: center;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18);
}

.toast.err {
  background: var(--danger);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink-soft);
  font-size: 13.5px;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid #d7dbe0;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(16, 24, 40, 0.45);
}

.modal {
  width: 100%;
  max-width: 440px;
  max-height: 82vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  padding: 18px;
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.modal h3.warn {
  color: var(--warn);
}

.modal-message {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.6;
}

.modal-list {
  margin: 0 0 14px;
  padding-left: 18px;
  max-height: 40vh;
  overflow: auto;
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn {
  flex: 1;
}
