:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --grid: #dfe4e8;
  --grid-strong: #b8c2cc;
  --text: #111827;
  --muted: #5d6875;
  --accent: #2563eb;
  --positive-bg: #ffc6cd;
  --positive-text: #a60000;
  --negative-bg: #c6efce;
  --negative-text: #006100;
  --blank-bg: #ffffff;
  --header-bg: #f8fafc;
  --date-bg: #fff7ed;
  --date-accent: #fb7185;
  --date-soft: #ffe4e6;
  --weekend-bg: #e0f2fe;
  --weekend-text: #0369a1;
  --input-focus-bg: rgba(224, 242, 254, 0.72);
  --input-focus-border: #38bdf8;
  --input-hover-bg: rgba(241, 245, 249, 0.72);
  --danger: #c62828;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

input {
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    color 0.16s ease;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(380px, 100%);
  display: grid;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--grid);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 45px rgba(17, 24, 39, 0.12);
}

.login-panel h1 {
  margin: 0 0 6px;
  font-size: 26px;
  line-height: 1.2;
}

.login-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.login-panel input {
  width: 100%;
  border: 1px solid var(--grid-strong);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
}

.login-panel input:hover,
.year-control input:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.login-panel input:focus,
.year-control input:focus {
  border-color: var(--input-focus-border);
  outline: 0;
  background: #f0f9ff;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.login-panel button,
.text-button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  min-height: 38px;
  padding: 0 16px;
  cursor: pointer;
}

.topbar .text-button {
  min-height: 30px;
  padding: 0 12px;
}

.subtle-button {
  border: 1px solid var(--grid-strong);
  background: #ffffff;
  color: var(--text);
}

.subtle-button:hover {
  border-color: #93c5fd;
  background: #f0f9ff;
  color: #075985;
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
}

.app-view {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.topbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--grid);
}

.brand {
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.page-switch-button {
  background: #0f766e;
}

.page-switch-button:hover {
  background: #0d9488;
}

.selection-mode-button {
  display: none;
}

.selection-mode-button.active {
  border-color: #2563eb;
  background: #2563eb;
  color: #ffffff;
}

.year-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.year-control input {
  width: 76px;
  height: 30px;
  border: 1px solid var(--grid-strong);
  border-radius: 6px;
  padding: 0 8px;
  background: #ffffff;
}

.icon-button {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--grid-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.save-status {
  min-width: 56px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.month-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  padding: 5px 8px;
  background: #e9eef3;
  border-bottom: 1px solid var(--grid);
}

.month-tabs button {
  min-width: 48px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.month-tabs button.active {
  background: var(--panel);
  border-color: var(--grid-strong);
  color: var(--text);
  font-weight: 800;
}

.stats-page {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.sheet-wrap {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  background: var(--panel);
}

.new-stats-page {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
  background: var(--panel);
}

.day-nav {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: #f8fafc;
  border-bottom: 1px solid var(--grid);
}

.day-nav .text-button {
  min-height: 30px;
  padding: 0 12px;
}

.column-filter-button {
  margin-left: auto;
}

.new-column-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 10px;
  z-index: 20;
  width: min(280px, calc(100vw - 20px));
  display: grid;
  gap: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.18);
}

.new-column-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #0f172a;
}

.mini-button {
  min-height: 26px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  padding: 0 9px;
  cursor: pointer;
}

.mini-button:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.new-column-list {
  max-height: 320px;
  display: grid;
  gap: 6px;
  overflow: auto;
}

.new-column-item {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #ffffff;
  padding: 0 8px;
  cursor: grab;
}

.new-column-item:active {
  cursor: grabbing;
}

.new-column-item.is-hidden-column {
  color: #94a3b8;
  background: #f8fafc;
}

.new-column-handle {
  color: #64748b;
  font-weight: 900;
  letter-spacing: 0;
}

.new-column-choice {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.new-column-choice input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.active-day-label {
  min-width: 178px;
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 15px;
  font-weight: 900;
}

.stats-table.new-stats-table {
  --new-name-width: 104px;
  --new-rate-width: 60px;
  --new-session-width: 52px;
  --new-data-width: 86px;
  --new-summary-width: 88px;
}

.stats-table.new-stats-table th,
.stats-table.new-stats-table td {
  width: var(--new-data-width);
  min-width: var(--new-data-width);
  height: 34px;
}

.stats-table.new-stats-table .row-header,
.stats-table.new-stats-table .corner {
  width: var(--new-name-width);
  min-width: var(--new-name-width);
}

.new-stats-table thead th {
  color: #0f172a;
}

.new-stats-table .new-draggable-column,
#statsTable .new-draggable-column,
.new-stats-table .new-person-cell {
  cursor: grab;
  user-select: none;
}

.new-stats-table .new-draggable-column:active,
#statsTable .new-draggable-column:active,
.new-stats-table .new-person-cell:active {
  cursor: grabbing;
}

.column-dragging {
  opacity: 0.55;
}

.column-drop-before {
  box-shadow:
    inset 3px 0 0 #2563eb,
    inset 0 -2px 0 #cbd5e1 !important;
}

.column-drop-after {
  box-shadow:
    inset -3px 0 0 #2563eb,
    inset 0 -2px 0 #cbd5e1 !important;
}

.new-column-item.column-drop-before {
  box-shadow: inset 0 3px 0 #2563eb !important;
}

.new-column-item.column-drop-after {
  box-shadow: inset 0 -3px 0 #2563eb !important;
}

.new-stats-table .new-person-cell.column-drop-before {
  box-shadow:
    inset 0 3px 0 #2563eb,
    inset -3px 0 0 rgba(251, 113, 133, 0.38) !important;
}

.new-stats-table .new-person-cell.column-drop-after {
  box-shadow:
    inset 0 -3px 0 #2563eb,
    inset -3px 0 0 rgba(251, 113, 133, 0.38) !important;
}

.new-stats-table thead tr:first-child th {
  top: 0;
  height: 36px;
  font-size: 15px;
  white-space: nowrap;
}

.new-stats-table .new-person-corner,
.new-stats-table .new-person-cell {
  left: 0;
  background: linear-gradient(180deg, var(--name-bg-top, #ecfeff), var(--name-bg-bottom, #ccfbf1)) !important;
  color: var(--name-text, #0f766e);
  box-shadow:
    inset -3px 0 0 var(--name-accent, rgba(13, 148, 136, 0.24)),
    inset 0 -2px 0 rgba(255, 255, 255, 0.7);
}

.new-stats-table .new-person-cell {
  padding: 0 5px;
}

.new-person-name-cell {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: center;
}

.new-person-name-input {
  grid-column: 2;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--name-text, #0f766e);
  text-align: center;
  font-size: 15px;
  font-weight: 900;
  padding: 0 20px 0 0;
}

.new-person-name-input:focus {
  background: rgba(255, 255, 255, 0.48);
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.24);
}

.new-delete-person {
  right: 2px;
}

.new-stats-table .new-water-rate-header,
.new-stats-table .new-water-rate-cell {
  width: var(--new-rate-width);
  min-width: var(--new-rate-width);
  background: #fff7ed;
  box-shadow: inset -1px 0 0 var(--grid);
}

.new-stats-table thead .new-water-rate-header {
  color: #c2410c;
}

.new-stats-table .new-session-header,
.new-stats-table .new-session-cell {
  width: var(--new-session-width);
  min-width: var(--new-session-width);
  background: #f1f5f9;
  color: #334155;
  font-size: 14px;
  font-weight: 900;
  box-shadow: inset -1px 0 0 var(--grid);
}

.new-stats-table thead .new-session-header {
  z-index: 4;
}

.water-rate-input {
  width: 48px;
  height: 26px;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  outline: 0;
  background: #ffffff;
  color: #c2410c;
  text-align: center;
  font-size: 15px;
  font-weight: 900;
}

.water-rate-input:focus {
  border-color: #fb923c;
  background: #fff7ed;
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.18);
}

.new-stats-table .new-field-header {
  background: #f8fafc;
  color: #0f172a;
}

.new-stats-table .new-computed-header,
.new-stats-table .new-computed-cell {
  background: #f8fafc;
}

.new-stats-table .new-computed-cell {
  font-size: 17px;
  font-weight: 900;
}

.new-stats-table .new-summary-header,
.new-stats-table .new-side-summary {
  width: var(--new-summary-width);
  min-width: var(--new-summary-width);
  background: #eef2ff;
  color: #3730a3;
}

.new-stats-table .new-person-block-row td,
.new-stats-table .new-person-block-row th {
  border-color: #d7dde5;
}

.new-stats-table .new-person-row-0 td:not(.new-water-rate-cell):not(.new-side-summary):not(.new-computed-cell) {
  background-color: #ffffff;
}

.new-stats-table .new-person-row-1 td:not(.new-water-rate-cell):not(.new-side-summary):not(.new-computed-cell) {
  background-color: #fbfdff;
}

.new-stats-table .new-day-row th,
.new-stats-table .new-day-row td {
  height: 32px;
  background: #f8fafc;
  font-size: 17px;
  font-weight: 900;
}

.new-stats-table .new-person-row-1 th,
.new-stats-table .new-person-row-1 td {
  border-bottom: 2px solid #b8c2cc;
}

.new-stats-table .new-day-label {
  color: #0f766e;
  background: #ecfeff;
}

.new-stats-table tfoot th,
.new-stats-table tfoot td {
  height: 36px;
  background: #fffbeb;
  color: #92400e;
  font-size: 16px;
  font-weight: 900;
}

.new-stats-table tfoot .new-grand-label {
  background: #fde68a;
  color: #b45309;
}

.new-stats-table tfoot .new-grand-session {
  z-index: 5;
  background: #fef3c7;
  color: #92400e;
}

.new-stats-table tfoot .new-grand-empty {
  background: #fff7ed;
}

.new-stats-table .cell-input {
  font-size: 17px;
  padding: 0 2px;
}

.new-stats-table .cell-input::placeholder {
  color: #94a3b8;
  font-weight: 700;
}

.new-stats-table .cell-input:placeholder-shown {
  background: rgba(219, 234, 254, 0.72);
  box-shadow: inset 0 0 0 1px #bfdbfe;
}

.new-stats-table .new-value-cell:hover .cell-input {
  background: rgba(239, 246, 255, 0.95);
  box-shadow: inset 0 0 0 1px #93c5fd;
}

.new-stats-table .new-rate-cell,
.new-stats-table .new-rate-cell .cell-input {
  color: #0f766e;
  font-size: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.38);
}

.modal-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid var(--grid);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.modal-close {
  width: 32px;
  height: 32px;
  font-size: 22px;
}

.modal-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.modal-panel input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--grid-strong);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
}

.modal-panel input:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

.modal-panel input:focus {
  border-color: var(--input-focus-border);
  outline: 0;
  background: #f0f9ff;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

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

.stats-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.stats-table th,
.stats-table td {
  width: 94px;
  height: 33px;
  border: 1px solid var(--grid);
  padding: 0;
  text-align: center;
  vertical-align: middle;
  background: var(--blank-bg);
}

.stats-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 36px;
  background: var(--header-bg);
  font-size: 18px;
  font-weight: 900;
  box-shadow: inset 0 -2px 0 #cbd5e1;
}

.stats-table tfoot td,
.stats-table tfoot th {
  position: sticky;
  bottom: 0;
  z-index: 4;
  height: 34px;
  font-size: 22px;
  font-weight: 900;
  border-top: 2px solid var(--grid-strong);
}

.stats-table .row-header,
.stats-table .corner {
  position: sticky;
  left: 0;
  z-index: 5;
  width: 90px;
  min-width: 90px;
  background: var(--date-bg);
  color: #e00018;
  font-size: 19px;
  font-weight: 900;
  box-shadow: inset -3px 0 0 rgba(251, 113, 133, 0.38);
}

#statsTable {
  --stats-date-width: 78px;
  --stats-value-width: 92px;
  --stats-total-width: 112px;
  min-width: max-content;
}

#statsTable col.stats-date-col {
  width: var(--stats-date-width);
}

#statsTable col.stats-value-col {
  width: var(--stats-value-width);
}

#statsTable col.stats-day-total-col {
  width: var(--stats-total-width);
}

#statsTable th,
#statsTable td {
  width: var(--stats-value-width);
  min-width: var(--stats-value-width);
  max-width: var(--stats-value-width);
}

#statsTable .row-header,
#statsTable .corner {
  width: var(--stats-date-width);
  min-width: var(--stats-date-width);
  max-width: var(--stats-date-width);
}

#statsTable .day-total-header,
#statsTable .day-total,
#statsTable .grand-total {
  width: var(--stats-total-width);
  min-width: var(--stats-total-width);
  max-width: var(--stats-total-width);
}

#statsTable tbody tr.week-tone-0 {
  --week-row-bg: #f8fbff;
  --week-date-bg: #eff6ff;
  --week-edge: rgba(96, 165, 250, 0.32);
}

#statsTable tbody tr.week-tone-1 {
  --week-row-bg: #f7fdf9;
  --week-date-bg: #ecfdf5;
  --week-edge: rgba(52, 211, 153, 0.32);
}

#statsTable tbody tr.week-tone-2 {
  --week-row-bg: #fffaf0;
  --week-date-bg: #fff7ed;
  --week-edge: rgba(251, 146, 60, 0.3);
}

#statsTable tbody tr.week-tone-3 {
  --week-row-bg: #fbfaff;
  --week-date-bg: #f5f3ff;
  --week-edge: rgba(167, 139, 250, 0.3);
}

#statsTable tbody tr.week-tone-4 {
  --week-row-bg: #f6fdff;
  --week-date-bg: #ecfeff;
  --week-edge: rgba(34, 211, 238, 0.3);
}

#statsTable tbody tr.week-tone-5 {
  --week-row-bg: #fff8fb;
  --week-date-bg: #fff1f2;
  --week-edge: rgba(251, 113, 133, 0.28);
}

#statsTable tbody tr[class*="week-tone-"] td:not(.numeric-positive):not(.numeric-negative) {
  background: var(--week-row-bg);
}

#statsTable tbody tr[class*="week-tone-"] .row-header {
  background: var(--week-date-bg);
  box-shadow: inset -3px 0 0 var(--week-edge);
}

.day-header {
  position: relative;
  min-height: 32px;
  display: grid;
  place-content: center;
  gap: 2px;
  line-height: 1;
}

.row-clear-button {
  position: absolute;
  right: 2px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  border: 1px solid rgba(244, 63, 94, 0.28);
  border-radius: 50%;
  background: rgba(255, 241, 242, 0.92);
  color: #e11d48;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 0.16s ease,
    transform 0.16s ease,
    background-color 0.16s ease;
}

.row-clear-button:hover,
.row-clear-button:focus-visible {
  opacity: 1;
  background: #ffe4e6;
  transform: translateY(-50%) scale(1.06);
}

.row-clear-button:disabled {
  cursor: default;
  opacity: 0;
}

#statsTable tbody tr:hover .row-clear-button:not(:disabled),
.row-clear-button:focus-visible {
  opacity: 0.82;
}

.day-number {
  display: block;
  font-size: 18px;
  letter-spacing: 0;
}

.weekday {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 14px;
  margin: 0 auto;
  border-radius: 999px;
  background: var(--date-soft);
  color: #be123c;
  font-size: 10px;
  font-weight: 800;
}

.weekend-day .weekday {
  background: var(--weekend-bg);
  color: var(--weekend-text);
}

.invalid-day .weekday {
  visibility: hidden;
}

.stats-table thead .corner {
  z-index: 6;
}

.stats-table tfoot .row-header {
  z-index: 6;
}

.header-cell {
  position: relative;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: center;
  height: calc(100% - 6px);
  margin: 3px;
  border: 1px solid var(--name-border, #cbd5e1);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--name-bg-top, #ffffff), var(--name-bg-bottom, #f8fafc));
  box-shadow:
    inset 0 2px 0 var(--name-shine, rgba(255, 255, 255, 0.85)),
    inset 0 -3px 0 var(--name-accent, rgba(37, 99, 235, 0.16));
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    filter 0.16s ease,
    transform 0.16s ease;
}

.name-drag-handle {
  width: 14px;
  min-width: 14px;
  height: 100%;
  align-self: stretch;
  border-radius: 5px 0 0 5px;
  color: var(--name-text, #64748b);
  cursor: grab;
  opacity: 0.42;
  background:
    radial-gradient(circle, currentColor 1.2px, transparent 1.6px) center 7px / 6px 6px repeat-y;
}

.name-drag-handle:active {
  cursor: grabbing;
}

.header-cell:hover .name-drag-handle,
.new-person-name-cell:hover .name-drag-handle {
  opacity: 0.8;
}

.header-cell:hover {
  filter: saturate(1.08);
  box-shadow:
    inset 0 2px 0 var(--name-shine, rgba(255, 255, 255, 0.9)),
    inset 0 -3px 0 var(--name-accent, rgba(37, 99, 235, 0.2)),
    0 0 0 2px rgba(148, 163, 184, 0.18);
}

.header-cell:focus-within {
  border-color: var(--input-focus-border);
  filter: saturate(1.12);
  transform: translateY(-1px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.96),
    inset 0 -3px 0 var(--name-accent, rgba(37, 99, 235, 0.22)),
    0 0 0 3px rgba(56, 189, 248, 0.24),
    0 6px 16px rgba(15, 23, 42, 0.08);
}

.name-tone-0 {
  --name-bg-top: #eff6ff;
  --name-bg-bottom: #dbeafe;
  --name-border: #93c5fd;
  --name-text: #1d4ed8;
  --name-accent: rgba(37, 99, 235, 0.22);
}

.name-tone-1 {
  --name-bg-top: #fdf2f8;
  --name-bg-bottom: #fce7f3;
  --name-border: #f9a8d4;
  --name-text: #be185d;
  --name-accent: rgba(219, 39, 119, 0.22);
}

.name-tone-2 {
  --name-bg-top: #ecfdf5;
  --name-bg-bottom: #d1fae5;
  --name-border: #86efac;
  --name-text: #047857;
  --name-accent: rgba(5, 150, 105, 0.2);
}

.name-tone-3 {
  --name-bg-top: #fff7ed;
  --name-bg-bottom: #ffedd5;
  --name-border: #fdba74;
  --name-text: #c2410c;
  --name-accent: rgba(234, 88, 12, 0.22);
}

.name-tone-4 {
  --name-bg-top: #f5f3ff;
  --name-bg-bottom: #ede9fe;
  --name-border: #c4b5fd;
  --name-text: #6d28d9;
  --name-accent: rgba(124, 58, 237, 0.2);
}

.name-tone-5 {
  --name-bg-top: #ecfeff;
  --name-bg-bottom: #cffafe;
  --name-border: #67e8f9;
  --name-text: #0e7490;
  --name-accent: rgba(8, 145, 178, 0.2);
}

.name-tone-6 {
  --name-bg-top: #fefce8;
  --name-bg-bottom: #fef3c7;
  --name-border: #facc15;
  --name-text: #a16207;
  --name-accent: rgba(202, 138, 4, 0.22);
}

.name-tone-7 {
  --name-bg-top: #f0fdfa;
  --name-bg-bottom: #ccfbf1;
  --name-border: #5eead4;
  --name-text: #0f766e;
  --name-accent: rgba(13, 148, 136, 0.2);
}

.name-tone-8 {
  --name-bg-top: #fff1f2;
  --name-bg-bottom: #ffe4e6;
  --name-border: #fda4af;
  --name-text: #be123c;
  --name-accent: rgba(225, 29, 72, 0.2);
}

.name-tone-9 {
  --name-bg-top: #eef2ff;
  --name-bg-bottom: #e0e7ff;
  --name-border: #a5b4fc;
  --name-text: #4338ca;
  --name-accent: rgba(79, 70, 229, 0.2);
}

.name-tone-10 {
  --name-bg-top: #f7fee7;
  --name-bg-bottom: #ecfccb;
  --name-border: #bef264;
  --name-text: #4d7c0f;
  --name-accent: rgba(101, 163, 13, 0.2);
}

.name-tone-11 {
  --name-bg-top: #faf5ff;
  --name-bg-bottom: #f3e8ff;
  --name-border: #d8b4fe;
  --name-text: #7e22ce;
  --name-accent: rgba(147, 51, 234, 0.2);
}

.header-name {
  grid-column: 2;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  text-align: center;
  color: var(--name-text, var(--text));
  font-size: 17px;
  font-weight: 900;
  min-width: 0;
  padding: 0 23px 0 0;
  border-radius: 6px;
}

.header-name:focus {
  color: var(--name-text, #0f172a);
  background: rgba(255, 255, 255, 0.34);
}

.delete-column {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: #fee2e2;
  color: #991b1b;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.16;
  transition: opacity 0.16s ease, background-color 0.16s ease;
}

.header-cell:focus-within .delete-column,
.header-cell:hover .delete-column {
  opacity: 0.9;
}

.delete-column:hover {
  background: #fecaca;
}

.cell-input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  text-align: center;
  color: inherit;
  font-size: 22px;
  font-weight: 800;
  padding: 0 4px;
  border-radius: 5px;
  caret-color: #0284c7;
}

#statsTable tbody td.data-cell {
  position: relative;
  cursor: cell;
}

body.nine-selection-mode #statsTable tbody td.data-cell {
  touch-action: none;
}

#statsTable .cell-input[readonly] {
  cursor: cell;
  caret-color: transparent;
  user-select: none;
}

#statsTable .cell-input.is-editing {
  cursor: text;
  caret-color: #0284c7;
  user-select: text;
  background: rgba(240, 249, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.32);
}

.cell-selecting #statsTable,
.cell-selecting #statsTable * {
  user-select: none;
}

#statsTable tbody td.cell-selected {
  position: relative;
  z-index: 2;
  outline: 2px solid #2563eb;
  outline-offset: -2px;
  box-shadow:
    inset 0 0 0 999px rgba(219, 234, 254, 0.48),
    0 0 0 1px rgba(37, 99, 235, 0.26);
}

#statsTable tbody td.cell-selected-anchor {
  outline-color: #0f766e;
  box-shadow:
    inset 0 0 0 999px rgba(204, 251, 241, 0.5),
    0 0 0 1px rgba(15, 118, 110, 0.3);
}

#statsTable tbody td.cell-selected .cell-input {
  background: transparent;
}

.cell-selection-badge {
  position: fixed;
  z-index: 10000;
  max-width: min(280px, calc(100vw - 16px));
  padding: 7px 10px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  color: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.2);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}

.stats-table tbody td {
  transition:
    background-color 0.16s ease,
    box-shadow 0.16s ease,
    outline-color 0.16s ease;
}

.stats-table tbody td:hover .cell-input {
  background: var(--input-hover-bg);
}

.stats-table tbody td:focus-within {
  position: relative;
  z-index: 3;
  outline: 2px solid var(--input-focus-border);
  outline-offset: -2px;
  box-shadow:
    inset 0 0 0 999px var(--input-focus-bg),
    0 0 0 3px rgba(56, 189, 248, 0.16);
}

.cell-input:focus {
  background: rgba(240, 249, 255, 0.66);
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.28);
}

.numeric-positive:focus-within {
  outline-color: #fb7185 !important;
  box-shadow:
    inset 0 0 0 999px rgba(255, 228, 230, 0.62),
    0 0 0 3px rgba(251, 113, 133, 0.16) !important;
}

.numeric-negative:focus-within {
  outline-color: #22c55e !important;
  box-shadow:
    inset 0 0 0 999px rgba(220, 252, 231, 0.64),
    0 0 0 3px rgba(34, 197, 94, 0.16) !important;
}

.numeric-positive {
  background: var(--positive-bg) !important;
  color: var(--positive-text);
}

.numeric-negative {
  background: var(--negative-bg) !important;
  color: var(--negative-text);
}

.numeric-zero {
  color: #000;
}

.summary-cell {
  font-size: 22px;
  font-weight: 900;
}

.month-label {
  color: #b00000;
  background: var(--positive-bg) !important;
}

.text-value {
  color: #8b0000;
  font-size: 19px;
  font-weight: 900;
}

@media (max-width: 760px) {
  .app-view {
    grid-template-rows: auto 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
    justify-content: flex-start;
  }

  .selection-mode-button {
    display: inline-flex;
  }

  .sheet-wrap {
    touch-action: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .sheet-wrap::-webkit-scrollbar {
    width: 0;
    height: 0;
  }

  .day-nav {
    flex-wrap: wrap;
    gap: 6px;
  }

  .active-day-label {
    order: -1;
    width: 100%;
    min-width: 0;
  }

  #statsTable {
    --stats-date-width: 74px;
    --stats-value-width: 88px;
    --stats-total-width: 104px;
  }

  .stats-table.new-stats-table {
    --new-name-width: 82px;
    --new-rate-width: 46px;
    --new-session-width: 42px;
    --new-data-width: 68px;
    --new-summary-width: 72px;
  }

  .stats-table.new-stats-table th,
  .stats-table.new-stats-table td {
    width: var(--new-data-width);
    min-width: var(--new-data-width);
    height: 32px;
  }

  .stats-table.new-stats-table .row-header,
  .stats-table.new-stats-table .corner {
    width: var(--new-name-width);
    min-width: var(--new-name-width);
  }

  .new-stats-table .new-person-name-input {
    font-size: 13px;
  }

  .water-rate-input {
    width: 38px;
    height: 24px;
    font-size: 13px;
  }

  .new-stats-table thead tr:first-child th {
    height: 32px;
    font-size: 13px;
  }

  .stats-table.new-stats-table .new-session-header,
  .stats-table.new-stats-table .new-session-cell {
    width: var(--new-session-width);
    min-width: var(--new-session-width);
    max-width: var(--new-session-width);
    font-size: 13px;
  }

  .stats-table.new-stats-table .new-water-rate-header,
  .stats-table.new-stats-table .new-water-rate-cell {
    width: var(--new-rate-width);
    min-width: var(--new-rate-width);
    max-width: var(--new-rate-width);
  }

  .stats-table.new-stats-table .new-summary-header,
  .stats-table.new-stats-table .new-side-summary {
    width: var(--new-summary-width);
    min-width: var(--new-summary-width);
    max-width: var(--new-summary-width);
  }

  .new-stats-table .new-day-row th,
  .new-stats-table .new-day-row td {
    height: 30px;
    font-size: 15px;
  }

  .new-stats-table .cell-input {
    font-size: 15px;
  }

  .new-stats-table .new-computed-cell {
    font-size: 15px;
  }

  .new-stats-table .new-rate-cell,
  .new-stats-table .new-rate-cell .cell-input {
    font-size: 14px;
  }

  .new-stats-table tfoot th,
  .new-stats-table tfoot td {
    height: 32px;
    font-size: 14px;
  }

  .stats-table th,
  .stats-table td {
    width: 104px;
    height: 40px;
  }

  .stats-table .row-header,
  .stats-table .corner {
    width: 92px;
    min-width: 92px;
    font-size: 19px;
  }

  .day-header {
    min-height: 39px;
  }

  .day-number {
    font-size: 19px;
  }

  .weekday {
    min-width: 36px;
    height: 16px;
    font-size: 12px;
  }

  .stats-table thead th,
  .header-name {
    font-size: 19px;
  }

  .cell-input,
  .summary-cell,
  .stats-table tfoot td,
  .stats-table tfoot th {
    font-size: 22px;
  }
}
