@import url("https://fonts.bunny.net/css?family=noto-sans-sc:400,500,600,700&display=swap");

:root {
  --bg: #eef5ee;
  --bg-2: #f5faf5;
  --ink: #2b2b2b;
  --muted: #6f7b6f;
  --line: #c8d8c8;
  --card: #fff;
  --accent: #1f4d2e;
  --accent-2: #159947;
  --danger: #c2410c;
  --pos: #159947;
  --head: #dcecdc;
  --radius: 14px;
  --shadow: 0 10px 28px rgba(40, 60, 40, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  font-family: var(--font);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(ellipse 90% 60% at 8% -8%, #dff0df 0%, transparent 50%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  width: min(1680px, 98vw);
  margin: 0 auto;
  padding: 12px 12px calc(28px + var(--safe-bottom));
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 10px;
}
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
}
.brand {
  margin: 2px 0 0;
  font-family: var(--font);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 400;
}

.nav-main {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 8px 0;
  background: linear-gradient(180deg, var(--bg) 60%, transparent);
}
.nav-main a {
  text-align: center;
  padding: 10px 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
}
.nav-main a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.flash {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 6px;
}
.flash li {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  background: #fff;
}
.flash li.ok { border-color: #a8d4b4; background: #f0faf2; color: #1b5e2f; }
.flash li.error { border-color: #f0c4b0; background: #fff5f0; color: var(--danger); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #355035;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}
.filters select, .filters input[type="date"], .filters input[type="number"],
.filters input[type="month"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  background: #fff;
}

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: #f4faf4; text-decoration: none; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: #163d24; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #e8c4b4; }
.btn.sm { padding: 5px 10px; font-size: 0.8rem; }

.file-drop {
  border: 2px dashed #b5ccb5;
  border-radius: 14px;
  padding: 22px 16px;
  text-align: center;
  background: #f7fbf7;
  margin-bottom: 12px;
}
.file-drop strong { display: block; margin-bottom: 6px; }
.file-drop .hint { color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.file-drop input[type="file"] { margin-top: 10px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
.kpi {
  background: #f5faf5;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.kpi span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.kpi strong {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent);
}
.kpi.neg strong { color: var(--danger); }
.kpi.pos strong { color: var(--pos); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap.day-wrap {
  overflow-x: visible;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
  border-bottom: 1px solid var(--line);
  padding: 8px 8px;
  text-align: left;
  vertical-align: middle;
}
table.data th {
  background: var(--head);
  color: #355035;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
table.data td.num, table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
table.data tr:hover td { background: #f7fbf7; }
table.data .neg { color: var(--danger); font-weight: 600; }
table.data .pos { color: var(--pos); font-weight: 600; }
table.data .cat-cell { color: var(--muted); font-size: 0.8rem; }

.chart-box {
  position: relative;
  height: 280px;
  max-width: 100%;
}
.chart-grid {
  display: grid;
  gap: 14px;
}
@media (min-width: 860px) {
  .chart-grid.two { grid-template-columns: 1fr 1fr; }
}

.rank-grid {
  display: grid;
  gap: 14px;
}
@media (min-width: 860px) {
  .rank-grid { grid-template-columns: 1fr 1fr; }
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.hint { color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--muted);
}

.date-preview {
  margin-top: 10px;
  font-size: 0.85rem;
}
.date-preview table { min-width: 0; width: 100%; }
.date-preview input[type="date"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  font: inherit;
}

.inline-form { display: inline; }

input.price-edit {
  width: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 6px;
  font: inherit;
  text-align: right;
  font-variant-numeric: tabular-nums;
  background: #fff;
  color: var(--ink);
}
input.price-edit:hover { border-color: #9bbb9b; background: #f7fbf7; }
input.price-edit:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(31, 77, 46, 0.12);
}
input.price-edit.saving { opacity: 0.6; }
input.price-edit.saved {
  border-color: var(--pos);
  background: #eefaf1;
}
input.price-edit.price-empty {
  border-color: #e0a060;
  background: #fff4e8;
  color: #9a4d00;
}
input.price-edit.price-empty::placeholder {
  color: #c47a2a;
  opacity: 1;
}
table.data tr.row-missing-cost td {
  background: #fff6eb;
}
table.data tr.row-missing-cost:hover td {
  background: #ffefd9;
}
table.data tr.row-missing-cost .col-action {
  background: #fff6eb;
}
table.data tr.row-missing-cost:hover .col-action {
  background: #ffefd9;
}
.missing-legend {
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #fff4e8;
  border: 1px solid #e0a060;
  color: #9a4d00;
}
.collab-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f3f8f3;
  border: 1px solid #d5e5d5;
}
.collab-label {
  font-weight: 600;
  color: #355035;
  font-size: 0.9rem;
}
input.collab-name {
  width: 180px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid #b7cbb7;
  border-radius: 8px;
  background: #fff;
  font-size: 0.9rem;
}
input.collab-name:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 77, 46, 0.12);
}
input.note-edit {
  width: 100%;
  max-width: 100%;
  padding: 4px 6px;
  border: 1px solid #d0dcd0;
  border-radius: 6px;
  background: #fff;
  font-size: 0.75rem;
  box-sizing: border-box;
}
input.note-edit:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}
table.data.day-table th:nth-child(1),
table.data.day-table td:nth-child(1) { width: 6%; }
table.data.day-table th:nth-child(2),
table.data.day-table td:nth-child(2) { width: 11%; white-space: normal; }
table.data.day-table th:nth-child(3),
table.data.day-table td:nth-child(3) { width: 6%; white-space: normal; }
table.data.day-table th:nth-child(4),
table.data.day-table td:nth-child(4) { width: 5%; }
table.data.day-table th:nth-child(5),
table.data.day-table td:nth-child(5) { width: 6%; }
table.data.day-table th:nth-child(6),
table.data.day-table td:nth-child(6) { width: 7%; }
table.data.day-table th:nth-child(7),
table.data.day-table td:nth-child(7) { width: 6%; }
table.data.day-table th:nth-child(8),
table.data.day-table td:nth-child(8) { width: 7%; }
table.data.day-table th:nth-child(9),
table.data.day-table td:nth-child(9) { width: 7%; }
table.data.day-table th:nth-child(10),
table.data.day-table td:nth-child(10) { width: 6%; }
table.data.day-table th:nth-child(11),
table.data.day-table td:nth-child(11) { width: 6%; }
table.data.day-table th:nth-child(12),
table.data.day-table td:nth-child(12) { width: 7%; white-space: normal; }
table.data.day-table th:nth-child(13),
table.data.day-table td:nth-child(13) { width: 10%; white-space: normal; overflow: visible; }
table.data.day-table th:nth-child(14),
table.data.day-table td:nth-child(14) { width: 10%; }
.cell-price-by {
  font-size: 0.75rem;
  color: #4a5d4a;
}
table.data .btn-row-sync {
  white-space: nowrap;
  padding: 5px 8px;
  font-size: 0.75rem;
  display: inline-block;
  width: auto;
  min-width: 0;
}
table.data.day-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  font-size: 0.8rem;
}
table.data.day-table th,
table.data.day-table td {
  padding: 6px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table.data.day-table .price-edit {
  width: 100%;
  max-width: 88px;
  padding: 4px 2px;
  font-size: 0.8rem;
}
table.data .col-action {
  white-space: nowrap;
  text-align: center;
  overflow: visible;
  position: static;
  box-shadow: none;
  background: transparent;
  min-width: 0;
  width: auto;
}
table.data thead .col-action {
  background: var(--head);
  z-index: 1;
}
table.data tr:hover .col-action {
  background: #f7fbf7;
}
table.data thead tr:hover .col-action {
  background: var(--head);
}
table.data.day-table .col-action {
  white-space: nowrap;
  overflow: visible;
}
.btn.saved-flash {
  background: var(--pos) !important;
  border-color: var(--pos) !important;
  color: #fff !important;
}
.share-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 40, 20, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.share-modal[hidden] { display: none !important; }
.share-dialog {
  width: min(640px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 16px;
}
.share-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.share-dialog-head strong {
  font-size: 1.05rem;
  color: var(--accent);
}
.share-preview-wrap {
  background: #eef5ee;
  border-radius: 12px;
  padding: 10px;
  margin: 10px 0 14px;
  text-align: center;
  max-height: 58vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.share-preview-wrap img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(40, 60, 40, 0.12);
  display: block;
  margin: 0 auto;
}
.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hist-box {
  background: #f5faf5;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 4px 0 8px;
}
.hist-title {
  font-weight: 700;
  color: #355035;
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.hist-table { min-width: 0 !important; }
.hist-table th, .hist-table td { font-size: 0.82rem; }
tr.history-panel td { background: #fafdfa; border-bottom: none; }
