/* 墨舍｜茶庄经营工作台 — 第一阶段原型样式 */

:root {
  --tea-brown: #382D26;
  --wood: #A77D58;
  --paper: #F6F1E8;
  --leaf: #68745B;
  --gold: #BD9563;
  --card: #FBF8F2;
  --paper-deep: #EFE6D8;
  --line: #E4D5C3;
  --line-strong: #D4C0A8;
  --muted: #7A6A5C;
  --ink: #382D26;
  --stamp: #C44536;
  --danger: #8B3A2F;
  --shadow: 0 1px 2px rgba(56, 45, 38, 0.05);
  --serif: "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", "Noto Sans CJK SC", "Source Han Sans SC", "PingFang SC", sans-serif;
  --masthead-logo: 192px;
  --page-pad: 36px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--paper-deep);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  min-height: 100%;
}
body {
  background-color: #E8DCCB;
  background-image:
    linear-gradient(180deg, rgba(246, 241, 232, 0.55), rgba(246, 241, 232, 0.55)),
    url("../assets/textures/wood.png");
  background-size: auto, 400px 800px;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app {
  min-height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  background-color: var(--paper);
  background-image: url("../assets/textures/paper.png");
  background-size: 512px 512px;
  box-shadow: 0 0 0 1px rgba(56, 45, 38, 0.06), 0 12px 40px rgba(56, 45, 38, 0.08);
  display: flex;
  flex-direction: column;
}

/* ——— 顶部店招：原标是主视觉，不是小图标 ——— */
.masthead {
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 22px 40px 18px;
  background: var(--paper);
  position: relative;
}
.masthead-brand {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 米白底承接白底原标，不加色底、不加滤镜 */
  background: transparent;
}
.masthead-logo {
  display: block;
  height: var(--masthead-logo);
  width: auto;
  max-width: var(--masthead-logo);
  object-fit: contain;
  object-position: center;
  /* 仅裁掉原图上下约 1px 灰边，不碰到书法、红印与竖排标语 */
  clip-path: inset(1px);
  image-rendering: auto;
}
.masthead-copy {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 6px;
  border-left: 1px solid var(--line-strong);
  padding-left: 40px;
}
.masthead-shop {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--tea-brown);
  line-height: 1.3;
  margin: 0;
}
.masthead-system {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--tea-brown);
  letter-spacing: 0.12em;
}
.masthead-date {
  margin: 10px 0 0;
  font-size: 15px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.masthead-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex: 0 0 auto;
  align-self: flex-start;
  padding-top: 8px;
}
.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  padding: 6px 10px;
  border: 1.5px solid var(--stamp);
  color: var(--stamp);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.12em;
  border-radius: 2px;
  transform: rotate(-8deg);
  background: rgba(255, 255, 255, 0.35);
  user-select: none;
}
.masthead-rule {
  height: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--gold);
  margin: 0 40px;
  opacity: 0.9;
}

/* ——— 导航：文字为主，无密集图标 ——— */
.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 4px;
  padding: 4px 32px 0;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.nav a {
  display: inline-flex;
  align-items: center;
  padding: 12px 16px 11px;
  text-decoration: none;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.06em;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.nav a:hover { color: var(--tea-brown); }
.nav a.is-active {
  color: var(--tea-brown);
  font-weight: 600;
  border-bottom-color: var(--wood);
}

main#view {
  flex: 1 1 auto;
  padding: 28px var(--page-pad) 48px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--tea-brown);
}
.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.kpi {
  padding: 18px 20px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.kpi-label {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.kpi-value {
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--tea-brown);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.kpi-value small {
  font-size: 15px;
  margin-left: 2px;
  font-weight: 500;
  letter-spacing: 0;
}
.kpi-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.kpi.is-debt .kpi-value { color: var(--danger); }
.kpi.is-in .kpi-value { color: var(--leaf); }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--tea-brown);
  text-decoration: none;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.quick-btn:hover { border-color: var(--wood); background: #F8F3EA; }
.quick-btn b { font-family: var(--serif); font-size: 17px; font-weight: 700; letter-spacing: 0.08em; }
.quick-btn span { font-size: 12px; color: var(--muted); }

.split {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 18px;
}
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.08em;
}
.section-title a, .section-title .link {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--wood);
  letter-spacing: 0;
  font-weight: 500;
  text-decoration: none;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}
table.data th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
table.data td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tr.is-clickable { cursor: pointer; }
table.data tr.is-clickable:hover td { background: rgba(167, 125, 88, 0.06); }
table.data .num, .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-feature-settings: "tnum";
}
table.data .muted, .muted { color: var(--muted); }
.cell-name { font-weight: 600; color: var(--tea-brown); }
.cell-id { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  letter-spacing: 0.04em;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}
.pill.ok { color: var(--leaf); border-color: #B7C0AE; background: rgba(104, 116, 91, 0.08); }
.pill.partial { color: #8A6230; border-color: #E0C39A; background: rgba(189, 149, 99, 0.12); }
.pill.wait { color: var(--danger); border-color: #D7B3AD; background: rgba(139, 58, 47, 0.06); }
.pill.warn { color: #8A6230; border-color: #E0C39A; background: rgba(189, 149, 99, 0.12); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--wood);
  background: var(--wood);
  color: #FBF8F2;
  font-size: 15px;
  letter-spacing: 0.06em;
  text-decoration: none;
}
.btn:hover { filter: brightness(0.97); }
.btn.secondary {
  background: transparent;
  color: var(--tea-brown);
  border-color: var(--line-strong);
}
.btn.secondary:hover { border-color: var(--wood); background: rgba(167, 125, 88, 0.06); }
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn.ghost:hover { color: var(--tea-brown); background: rgba(56, 45, 38, 0.04); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #FFFcf7;
}
.search input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  color: var(--ink);
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.form-grid .full { grid-column: 1 / -1; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label.field > span { letter-spacing: 0.06em; }
label.field input, label.field select, label.field textarea, .input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #FFFcf7;
  color: var(--ink);
  outline: none;
}
label.field textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; }
label.field input:focus, label.field select:focus, label.field textarea:focus, .input:focus {
  border-color: var(--wood);
}
.help { font-size: 12px; color: var(--muted); }

/* 客户详情 */
.profile {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.avatar-mark {
  width: 48px;
  height: 48px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 20px;
  color: var(--tea-brown);
  margin-bottom: 12px;
}
.dl { display: grid; grid-template-columns: 88px 1fr; gap: 6px 10px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.balance-box { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.balance-box .kpi-value { font-size: 26px; }

/* 快速记账 */
.item-table input { height: 36px; width: 100%; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: #FFFcf7; }
.item-table { width: 100%; border-collapse: collapse; }
.item-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 6px 6px; }
.item-table td { padding: 6px; vertical-align: middle; }
.sale-sum {
  margin-top: 8px;
  padding: 14px 16px;
  background: rgba(167, 125, 88, 0.07);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.sale-sum div span { display: block; font-size: 12px; color: var(--muted); }
.sale-sum div b { font-family: var(--serif); font-size: 20px; font-variant-numeric: tabular-nums; }
.suggest {
  position: relative;
}
.suggest-list {
  position: absolute;
  left: 0; right: 0; top: 100%;
  z-index: 8;
  background: #FFFcf7;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 240px;
  overflow: auto;
  box-shadow: 0 8px 20px rgba(56, 45, 38, 0.08);
}
.suggest-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  border-bottom: 1px solid var(--line);
}
.suggest-list button:hover { background: rgba(167, 125, 88, 0.08); }
.picked-customer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #FFFcf7;
}

/* 账单预览工作区 */
.bill-workspace {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 28px;
  align-items: start;
}
.bill-toolbar {
  position: sticky;
  top: 16px;
}
.bill-stage {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  background: #EFE6D8;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 20px;
}
.bill-stage-caption {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* 竖版清单：高级茶庄信纸，抬头为原标 */
.bill-sheet {
  width: 400px;
  background: #FBF7F0;
  color: var(--tea-brown);
  box-shadow: 0 8px 24px rgba(56, 45, 38, 0.1);
  padding: 18px;
}
.bill-frame {
  border: 1px solid var(--wood);
  outline: 1px solid rgba(189, 149, 99, 0.7);
  outline-offset: 3px;
  padding: 18px 18px 16px;
}
.bill-head { text-align: center; }
.bill-logo {
  display: block;
  width: auto;
  height: 158px;
  max-width: 158px;
  margin: 0 auto 2px;
  object-fit: contain;
  object-position: center;
  clip-path: inset(1px);
  background: transparent;
}
.bill-shop-name {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.28em;
  margin-top: 2px;
}
.bill-slogan {
  font-family: var(--serif);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.2em;
  margin: 2px 0 8px;
}
.bill-title {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.2em;
  margin: 8px 0 4px;
  padding-top: 8px;
  border-top: 1px solid var(--gold);
}
.bill-meta { margin: 8px 0 6px; font-size: 12px; }
.bill-meta div {
  display: flex;
  gap: 10px;
  padding: 2px 0;
}
.bill-meta span { color: var(--muted); width: 64px; flex: 0 0 64px; }
.bill-meta b { font-weight: 600; }
.bill-meta .is-muted b { color: var(--muted); font-weight: 400; }
.bill-page-hint {
  text-align: center;
  color: var(--wood);
  font-size: 11px;
  margin: 4px 0 6px;
}
.bill-item {
  padding: 8px 0 6px;
  border-top: 1px solid var(--line);
}
.bill-item-top { display: flex; gap: 10px; font-family: var(--serif); font-size: 13.5px; }
.bill-item-date { color: var(--muted); flex: 0 0 58px; }
.bill-item-bottom {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  padding-left: 68px;
}
.bill-item-amt { color: var(--tea-brown); font-variant-numeric: tabular-nums; }
.bill-item.is-adjust .bill-item-amt { color: var(--leaf); }
.bill-empty { color: var(--muted); font-size: 13px; padding: 12px 0; text-align: center; }
.bill-summary { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--gold); }
.bill-sum-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
}
.bill-sum-row.is-strong { font-weight: 700; font-size: 14px; margin-top: 2px; }
.bill-status {
  text-align: center;
  font-family: var(--serif);
  margin: 10px 0 6px;
  letter-spacing: 0.12em;
}
.bill-pays { font-size: 12px; color: var(--muted); margin: 6px 0 4px; }
.bill-pays-title { color: var(--muted); margin-bottom: 2px; }
.bill-thanks {
  text-align: center;
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.2em;
  margin: 18px 0 6px;
}
.bill-sign {
  text-align: center;
  font-family: var(--serif);
  letter-spacing: 0.24em;
  font-size: 14px;
}
.bill-foot {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.6;
}

/* 导入向导 */
.steps {
  display: flex;
  gap: 0;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
  overflow-x: auto;
}
.steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.steps li + li::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--line-strong);
  margin: 0 8px;
}
.steps li.is-done, .steps li.is-current { color: var(--tea-brown); }
.steps li.is-current b {
  background: var(--tea-brown);
  color: #F6F1E8;
}
.steps b {
  display: inline-flex;
  width: 22px; height: 22px;
  align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  font-size: 12px;
  font-weight: 600;
}
.dropzone {
  border: 1px dashed var(--wood);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  background: rgba(167, 125, 88, 0.05);
}
.notice {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: rgba(189, 149, 99, 0.1);
  font-size: 13px;
  color: var(--tea-brown);
  margin-bottom: 14px;
}
.notice.warn { border-color: #E0C39A; }
.raw-table { font-size: 13px; width: 100%; border-collapse: collapse; }
.raw-table th, .raw-table td { border: 1px solid var(--line); padding: 6px 8px; }
.raw-table th { background: rgba(167, 125, 88, 0.08); font-weight: 500; }

/* 设置 */
.settings-logo-preview {
  display: flex;
  align-items: center;
  gap: 24px;
}
.settings-logo-preview img {
  height: 200px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  clip-path: inset(1px);
}
.placeholder-box {
  padding: 16px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  background: rgba(56, 45, 38, 0.02);
}

/* 模态 */
.modal-root[hidden] { display: none !important; }
.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(56, 45, 38, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}
.modal {
  width: min(520px, 100%);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 22px 22px 18px;
  box-shadow: 0 16px 40px rgba(56, 45, 38, 0.16);
}
.modal h3 { margin: 0 0 12px; font-family: var(--serif); letter-spacing: 0.08em; }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--tea-brown);
  color: #F6F1E8;
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 30;
  font-size: 14px;
}

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.same-name-tip {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--wood);
  border: 1px solid var(--gold);
  padding: 0 6px;
  border-radius: 4px;
}

@media (max-width: 1100px) {
  :root { --masthead-logo: 156px; --page-pad: 24px; }
  .masthead { gap: 24px; padding: 16px 24px 14px; }
  .masthead-copy { padding-left: 24px; }
  .masthead-shop { font-size: 24px; }
  .kpi-grid, .quick-grid { grid-template-columns: 1fr 1fr; }
  .split, .profile, .bill-workspace { grid-template-columns: 1fr; }
  .bill-toolbar { position: static; }
  .sale-sum { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  :root { --masthead-logo: 132px; --page-pad: 16px; }
  .masthead { flex-wrap: wrap; gap: 12px 20px; padding: 12px 16px; }
  .masthead-copy { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 10px; width: 100%; }
  .masthead-aside { width: 100%; flex-direction: row; justify-content: space-between; align-items: center; padding-top: 0; }
  .masthead-shop { font-size: 22px; letter-spacing: 0.12em; }
  .form-grid { grid-template-columns: 1fr; }
  .nav { padding: 4px 8px 0; }
  .kpi-value { font-size: 26px; }
  /* 即使在平板，店招 Logo 仍须完整可见，不得缩成图标 */
  .masthead-logo { height: 132px; max-width: 132px; }
}
