/* =========================================================
   星空好友商店记录 · 清爽表格样式
   ========================================================= */
:root {
  --bg: #f2f6ef;
  --surface: #ffffff;
  --soft: #f8faf6;
  --ink: #26362c;
  --muted: #718176;
  --line: #e4ebe0;
  --line-strong: #cfdacb;
  --brand: #4f9d6c;
  --brand-dark: #2f7a4e;
  --brand-soft: #e8f4ea;
  --blue: #5c86c4;
  --blue-soft: #eaf1fc;
  --rose: #d9787c;
  --rose-soft: #fdecec;
  --shadow: 0 10px 30px rgba(42, 75, 54, .08);
  --radius: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(circle at 4% 0%, rgba(176, 216, 172, .30), transparent 30%),
    radial-gradient(circle at 98% 4%, rgba(255, 224, 184, .24), transparent 28%),
    var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
input, select { min-width: 0; }
.app-shell { max-width: 1600px; margin: 0 auto; padding: 18px 22px 26px; }

/* ---------- 顶部 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 13px 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: #fff; background: linear-gradient(145deg, #74bd8d, #3d8a5b); box-shadow: 0 6px 16px rgba(61,138,91,.24); }
.brand-mark svg { width: 23px; height: 23px; }
.brand-text h1 { margin: 0; font-size: 18px; letter-spacing: .3px; }
.brand-text p { margin: 0; color: var(--muted); font-size: 11.5px; }
.top-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 33px; padding: 0 12px; border: 1px solid transparent; border-radius: 9px; font-size: 12px; font-weight: 600; white-space: nowrap; transition: .16s ease; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { color: #fff; background: var(--brand); box-shadow: 0 3px 10px rgba(79,157,108,.2); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-soft { color: var(--brand-dark); background: var(--brand-soft); }
.btn-soft:hover { background: #d9ecd9; }
.btn-ghost { color: var(--muted); background: #fff; border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line-strong); background: var(--soft); }
.btn-danger:hover { color: #b34d50; border-color: #f0c9c9; background: var(--rose-soft); }
input, select { height: 33px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: #93c7a2; box-shadow: 0 0 0 3px rgba(108,178,128,.14); }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0; padding: 11px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 6px 18px rgba(42,75,54,.05); }
.toolbar-spacer { flex: 1; }

/* ---------- 表格窗口 ---------- */
.sheet-window { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.grid-wrap { max-height: calc(100vh - 252px); overflow: auto; background: #fff; }
.grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: max-content; table-layout: fixed; }
.grid th, .grid td { height: 46px; padding: 7px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.grid .filler-col { background: #fff; }
.grid thead th { position: sticky; top: 0; z-index: 3; background: linear-gradient(180deg, #f7faf5, #f1f6ee); color: #495d4f; font-size: 12.5px; font-weight: 700; border-bottom: 2px solid #d6e3d2; }
.grid .friend-col { position: sticky; left: 0; z-index: 4; width: 118px; min-width: 118px; max-width: 118px; padding-left: 9px; padding-right: 9px; background: #fbfdfa; box-shadow: 2px 0 4px rgba(40,70,50,.045); }
.grid thead .friend-col { z-index: 6; }
.grid tbody tr:nth-child(even) td { background: #fcfdfb; }
.grid tbody tr:nth-child(even) .friend-col { background: #f8fbf7; }
.grid tbody tr:hover td { background: #f4faf3; }
.grid tbody tr:hover .friend-col { background: var(--brand-soft); }
.date-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.date-remove { width: 19px; height: 19px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #a8b6aa; font-size: 15px; line-height: 1; }
.date-remove:hover { color: #b34d50; background: var(--rose-soft); }
.friend-btn { display: flex; align-items: center; gap: 7px; width: 100%; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: left; font-size: 12.5px; font-weight: 600; }
.friend-btn:hover { color: var(--brand-dark); }
.friend-btn .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: 0 0 auto; display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; color: #fff; background: var(--brand); font-size: 11px; font-weight: 700; }
.avatar.guest { background: var(--blue); }
.cell { cursor: pointer; color: var(--ink); font-size: 12.5px; word-break: break-all; transition: background .12s ease; }
.cell:hover { background: #edf7ec !important; outline: 2px solid #9cccaa; outline-offset: -2px; }
.cell.dash { color: #b7c3b8; text-align: center; }
.cell-thumb { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; vertical-align: middle; margin-right: 4px; border: 1px solid var(--line); }
.cell-bought { color: var(--brand-dark); font-weight: 700; }
.cell-bought::before { content: "✓ "; color: var(--brand); }
.add-row td { background: #fbfdfb; }
.add-friend-btn { border: 0; background: transparent; color: var(--brand); font-size: 12.5px; font-weight: 600; padding: 0; }
.add-friend-btn:hover { text-decoration: underline; }

/* ---------- 底部页签 ---------- */
.sheet-tabs { display: flex; align-items: stretch; gap: 2px; padding: 6px 10px 0; border-top: 1px solid var(--line); background: #f6f9f4; }
.sheet-tabs button { min-width: 66px; height: 32px; padding: 0 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.sheet-tabs button:hover { background: #eef4ea; color: var(--ink); }
.sheet-tabs button.active { background: #fff; color: var(--brand-dark); border-color: var(--line); border-bottom: 3px solid var(--brand); }
.footer { margin-top: 10px; text-align: center; color: #9aa89d; font-size: 11.5px; }

/* ---------- 弹窗 ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; background: rgba(30,45,35,.40); backdrop-filter: blur(3px); }
.modal { width: min(540px,100%); max-height: 88vh; overflow: auto; padding: 19px; border: 1px solid var(--line); border-radius: 17px; background: #fff; box-shadow: 0 26px 70px rgba(20,35,25,.28); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.icon-close { width: 29px; height: 29px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: var(--muted); font-size: 18px; line-height: 1; }
.modal-body { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span, .field-head span { color: var(--muted); font-size: 12px; font-weight: 600; }
.field input, .field select { width: 100%; }
.field-row { display: grid; grid-template-columns: 120px minmax(0,1fr); gap: 10px; }
.input-with-btn { display: flex; gap: 6px; }
.input-with-btn input { flex: 1; }
.modal-codes { display: grid; gap: 6px; }
.modal-code { display: flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--soft); }
.modal-code-text { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--brand-dark); word-break: break-all; }
.modal-code-form { display: flex; gap: 7px; }
.modal-code-form input { flex: 1; }
.modal-code-form .btn { flex: 0 0 auto; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot-right { display: flex; gap: 7px; margin-left: auto; }

/* 单元格编辑 */
.cell-hint { margin: 0 0 4px; padding: 8px 10px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-dark); font-size: 11.5px; }
.cell-item { display: grid; grid-template-columns: minmax(0,1fr) 40px auto auto auto; gap: 7px; align-items: center; padding: 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.cell-item input { width: 100%; }
.thumb-wrap { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; cursor: pointer; overflow: hidden; }
.thumb-wrap img { width: 38px; height: 38px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; }
.thumb-none { width: 38px; height: 38px; border: 1px dashed var(--line-strong); border-radius: 8px; background: #fff; position: relative; }
.thumb-none::after { content: "图片"; position: absolute; inset: 0; display: grid; place-items: center; color: #a7b5a9; font-size: 10px; }
.mini-btn { min-height: 29px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.mini-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.mini-btn.upload { color: var(--brand-dark); border-color: #bcd9c2; background: var(--brand-soft); font-weight: 600; }
.mini-btn.buy.on { color: #fff; background: var(--brand); border-color: var(--brand); }
.mini-btn.del:hover { color: #b34d50; border-color: #f0c9c9; background: var(--rose-soft); }
#cellAddRow { margin-top: 10px; }
.empty-mini { padding: 16px; text-align: center; color: #9aa89d; border: 1px dashed var(--line-strong); border-radius: 9px; font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; padding: 9px 16px; border-radius: 999px; background: rgba(36,52,43,.94); color: #fff; font-size: 12.5px; opacity: 0; transform: translate(-50%,10px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 720px) {
  .app-shell { padding: 12px; }
  .grid-wrap { max-height: calc(100vh - 290px); }
  .field-row { grid-template-columns: 1fr; }
  .cell-item { grid-template-columns: minmax(0,1fr) 40px auto; }
  .cell-item .mini-btn.buy { grid-column: 1 / 2; }
}
