/* Shared by the interactive ledger and the print-sized PNG. */
@import url("/assets/font.css");

:root {
  color-scheme: light;
  --ink: #191919;
  --muted: #535353;
  --rule: #7f7f7f;
  --soft-rule: #d8d8d8;
  --header: #e8e8e8;
  --red: #a51919;
  --red-bg: #fae8e8;
  --green: #0b6c26;
  --green-bg: #e3f4e5;
  font: 14px/1.5 "Ledger Noto", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #fff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p { margin: 0; }
h1, h2 { line-height: 1.3; }
button, input, select, a.button { font: inherit; }
button, input, select, a.button {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid #bdbdbd;
  border-radius: 4px;
  background: #fff;
  color: inherit;
}
button, a.button { cursor: pointer; white-space: nowrap; }
button:hover, a.button:hover { background: #f0f0f0; }
button:disabled { opacity: .5; cursor: default; }
a.button { display: inline-flex; align-items: center; text-decoration: none; }
:focus-visible { outline: 2px solid #1861a3; outline-offset: 2px; }
.primary { background: #202020; color: #fff; border-color: #202020; font-weight: 600; }
.primary:hover { background: #3c3c3c; }
.quiet { border-color: transparent; color: var(--muted); }
.danger { color: var(--red); border-color: #d7a7a7; }
.danger:hover { background: var(--red-bg); }
.positive-text { color: var(--green); }
.negative-text, .form-error, .error { color: var(--red); }
.form-error { margin: 8px 0; }

.sheet { width: min(1040px, calc(100% - 48px)); margin: 0 auto 40px; }
.app-sheet { margin-top: 18px; }
.export-sheet { margin: 16px auto; }
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 37px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--ink);
  font-weight: 700;
}
.masthead .quiet { font-weight: 400; }
.actions, .filters { display: flex; flex-wrap: wrap; gap: 7px; align-items: end; }
.actions { margin-top: 10px; }
.month-switch { display: inline-flex; gap: 3px; margin-right: auto; }
.month-switch button { padding: 0 9px 2px; font-size: 20px; line-height: 1; }
.filters { padding: 10px 0; border-bottom: 1px solid var(--soft-rule); }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 500; color: var(--muted); }
label :is(input, select) { font-size: 14px; font-weight: 400; color: var(--ink); min-width: 0; }
.search-field input { width: 155px; }
.status { margin-top: 10px; }
.ledger-heading {
  display: grid;
  grid-template-columns: 30% 34% 36%;
  align-items: center;
  padding: 15px 0 16px;
}
.ledger-heading h1 { padding: 0 8px; font-size: 32px; font-weight: 750; letter-spacing: -.025em; }
.headline-metric {
  border-left: 1px solid var(--rule);
  padding: 1px 0 2px 15px;
  font-size: 20px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.headline-metric strong { white-space: normal; font-variant-numeric: tabular-nums; }
.compact-label { display: none; }
.filter-scope, .empty-note { color: var(--muted); margin: 0 0 8px; font-size: 12px; }
.table-scroll { overflow-x: auto; padding: 0 0 1px; }
.ledger-table { width: 100%; min-width: 692px; border-collapse: collapse; table-layout: fixed; border: 1px solid var(--rule); }
.col-date { width: 13.6%; }
.col-living { width: 21.8%; }
.col-income { width: 21.2%; }
.col-work-expense { width: 22.6%; }
.col-total { width: 20.8%; }
.ledger-table :is(td, th) { border: 1px solid var(--rule); padding: 6px; }
.ledger-table th { text-align: center; }
.ledger-table thead th { padding: 9px 4px; background: var(--header); font-size: 18px; font-weight: 750; }
.ledger-table tbody th { font-size: 20px; }
.day-date time span, .summary-kind span { white-space: nowrap; }
.ledger-table tfoot th { font-size: 17px; }
.ledger-table th small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }
.detail-cell { position: relative; vertical-align: top; }
.ledger-table .detail-cell { padding: 6px 6px 55px; }
.line-entry {
  display: flex;
  width: 100%;
  min-height: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 5px;
  padding: 2px 4px;
  border: 0;
  border-radius: 2px;
  white-space: normal;
  text-align: left;
  font-size: 16px;
  line-height: 1.45;
}
.entry-name { min-width: 0; overflow-wrap: anywhere; }
.entry-value { flex: 0 0 auto; max-width: 65%; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.entry-value:first-child { max-width: 100%; }
.daily-subtotal { position: absolute; inset: auto 6px 7px; }
.amount-tag {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  column-gap: 3px;
  padding: 4px 3px;
  border-radius: 3px;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.38;
  text-align: center;
}
.amount-tag strong { min-width: 0; overflow-wrap: anywhere; }
.amount-tag.negative { background: var(--red-bg); color: var(--red); }
.amount-tag.positive { background: var(--green-bg); color: var(--green); }
.amount-tag.neutral { background: #f3f3f3; color: var(--muted); }
.total-cell { vertical-align: middle; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

dialog { width: min(630px, calc(100% - 26px)); max-height: calc(100% - 26px); padding: 0; border: 1px solid var(--rule); border-radius: 6px; color: var(--ink); }
dialog::backdrop { background: rgb(0 0 0 / .28); }
dialog form, .dialog-content { padding: 15px; }
.dialog-header, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.dialog-header { margin-bottom: 12px; }
.dialog-header h2 { font-size: 19px; }
.dialog-header .quiet { font-size: 20px; line-height: 1; }
.dialog-actions { justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }
#quick-form textarea {
  width: 100%;
  resize: vertical;
  padding: 8px 9px;
  border: 1px solid #bdbdbd;
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font: 400 16px/1.5 "Ledger Noto", "PingFang SC", "Microsoft YaHei", sans-serif;
}
#quick-hint { color: var(--muted); margin-top: 6px; font-size: 12px; }
#add-row { margin-right: auto; }
.entry-fields { display: grid; align-items: end; grid-template-columns: 1.12fr 1fr 1.4fr .82fr auto; gap: 7px; padding: 7px 0; border: 0; border-top: 1px solid var(--soft-rule); margin: 0; min-inline-size: 0; }
.entry-fields input, .entry-fields select { width: 100%; }
.entry-fields .remove-row { font-size: 17px; line-height: 1; }
#delete-dialog, #budget-dialog { width: min(380px, calc(100% - 26px)); }
#delete-details { overflow-wrap: anywhere; }
#image-dialog { width: min(810px, calc(100% - 26px)); }
#image-preview { width: 100%; height: auto; border: 1px solid var(--soft-rule); }
.login-page { min-height: 100svh; display: grid; place-items: center; }
.login-box { width: min(320px, calc(100% - 36px)); padding: 15px 0 32px; border-top: 2px solid var(--ink); }
.login-box h1 { font-size: 30px; margin-bottom: 17px; }
.login-box button { margin-top: 12px; width: 100%; }

@media (max-width: 760px) {
  .app-sheet { width: calc(100% - 24px); margin-top: 8px; }
  .app-sheet .ledger-heading { grid-template-columns: 1fr 1fr; gap: 7px 0; padding: 12px 0 10px; }
  .app-sheet h1 { grid-column: 1 / -1; padding: 0; font-size: 26px; }
  .headline-metric { padding-left: 9px; font-size: 13px; }
  .headline-metric:nth-child(2) { border-left: 0; padding-left: 0; }
  .app-sheet .ledger-table { min-width: 0; }
  .app-sheet .ledger-table thead th { font-size: 15px; }
  .app-sheet .ledger-table tbody th { font-size: 17px; }
  .app-sheet .ledger-table tfoot th small { font-size: 10px; }
  .app-sheet .ledger-table .detail-cell { padding: 6px; height: 1px; }
  .app-sheet .detail-body { display: flex; flex-direction: column; height: 100%; }
  .app-sheet .line-entry { font-size: 14px; }
  .app-sheet .daily-subtotal { position: static; margin-top: auto; padding-top: 4px; }
  .app-sheet .amount-tag { font-size: 13px; }
  .entry-fields { grid-template-columns: 1fr 1fr auto; }
  .entry-fields label:nth-child(3) { grid-column: 1; }
  .remove-row { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
  button, input, select, a.button { min-height: 38px; }
  .app-sheet .line-entry { min-height: 28px; }
}

@media (max-width: 520px) {
  .app-sheet .wide-label { display: none; }
  .app-sheet .compact-label { display: inline; }
  .app-sheet .col-date { width: 15%; }
  .app-sheet .col-living, .app-sheet .col-work-expense { width: 23%; }
  .app-sheet .col-income { width: 19%; }
  .app-sheet .col-total { width: 20%; }
  .app-sheet .ledger-table :is(td, th) { padding: 3px; }
  .app-sheet .ledger-table thead th { padding: 7px 2px; font-size: 11px; }
  .app-sheet .ledger-table tbody th { font-size: 12px; }
  .app-sheet .ledger-table tfoot th { font-size: 11px; }
  .app-sheet .ledger-table .detail-cell { padding: 3px; }
  .app-sheet .line-entry {
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 1px;
    min-height: 36px;
    padding: 4px 2px;
    font-size: 12px;
    line-height: 1.26;
  }
  .app-sheet .entry-value { max-width: 100%; text-align: right; }
  .app-sheet .amount-tag { display: grid; justify-content: stretch; gap: 1px; padding: 3px 2px; font-size: 11px; }
  .app-sheet .amount-tag .compact-label { font-size: 10px; }
}

@media (max-width: 470px) {
  .month-switch { flex: 1 0 100%; }
}

@media (max-width: 350px) {
  .actions > button { flex-grow: 1; padding-inline: 6px; font-size: 12px; }
  .headline-metric { display: grid; }
}
