:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #edf1f6;
  background: #101b2d;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

.menu-button {
  position: fixed;
  z-index: 2;
  top: 20px;
  left: 20px;
  display: flex;
  width: 48px;
  height: 48px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  border: 1px solid #52647c;
  border-radius: 10px;
  background: #1d2c42;
  cursor: pointer;
  transition: background-color 260ms ease, transform 260ms ease;
}

.menu-button:hover { background: #293c56; transform: translateY(-1px); }
.menu-button:active { transform: translateY(0); }
.menu-button:focus-visible { outline: 3px solid #becada; outline-offset: 3px; }
.menu-button span { width: 21px; height: 2px; border-radius: 2px; background: #edf1f6; }
.groups-menu { left: auto; right: 20px; }
.group-row { display: grid; grid-template-columns: minmax(0, 1fr) 80px 36px; gap: 8px; align-items: end; }
.group-delete { width: 36px; height: 48px; color: #ff9c9c; }
.group-row label { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.add-group { width: 100%; margin-top: 18px; font-size: 16px; }

.thresholds-panel {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(380px, calc(100vw - 28px));
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 28px 24px;
  overflow-y: auto;
  border: 0;
  border-right: 1px solid #43536a;
  border-radius: 0 16px 16px 0;
  background: #162338;
  color: #edf1f6;
  box-shadow: 18px 0 48px #0008;
  transform: translateX(-12px);
  opacity: 0;
  transition: transform 450ms ease, opacity 380ms ease, overlay 450ms allow-discrete, display 450ms allow-discrete;
}

.thresholds-panel[open] { transform: translateX(0); opacity: 1; }
@starting-style {
  .thresholds-panel[open] { transform: translateX(-12px); opacity: 0; }
}
.thresholds-panel::backdrop { background: #07101bcc; transition: background-color 450ms ease; }
.thresholds-panel:not([open])::backdrop { background: transparent; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-header h2 { margin: 0; font-size: 24px; font-weight: 600; }
.panel-close {
  width: 40px;
  height: 40px;
  border: 1px solid #52647c;
  border-radius: 9px;
  background: #1d2c42;
  color: #edf1f6;
  font: inherit;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 260ms ease, transform 260ms ease;
}
.panel-close:hover { background: #293c56; transform: rotate(4deg); }
.panel-close:focus-visible { outline: 3px solid #becada; outline-offset: 3px; }
.panel-actions { display: flex; justify-content: flex-end; margin-top: 28px; }
.panel-ok { min-width: 104px; }
.panel-description { margin: 16px 0 24px; color: #c7d0dc; line-height: 1.5; }
.threshold-rows { display: flex; flex-direction: column; gap: 14px; }
.threshold-row { display: flex; flex-direction: column; gap: 8px; }
.threshold-number { color: #e5ebf3; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.threshold-input {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  border: 1px solid #52647c;
  border-radius: 9px;
  background: #1d2c42;
  color: #f4f6f9;
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.threshold-input:focus { border-color: #9daec2; outline: 3px solid #8196b333; }
.threshold-input::placeholder { color: #8492a5; opacity: 1; }
.threshold-empty { margin: 0; color: #9eacbe; }

body {
  min-width: 320px;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  overflow: auto;
  background: radial-gradient(ellipse at 50% -25%, #203653 0, #142238 48%, #101b2d 82%);
}

.page {
  width: min(100% - 48px, 1120px);
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  padding: 88px 0 24px;
}

.entry-form {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(76px, .5fr) 96px;
  gap: 16px;
  align-items: start;
}

.field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.field input {
  display: block;
  width: 100%;
  min-width: 0;
  height: 88px;
  padding: 0 18px;
  border: 1px solid #52647c;
  border-radius: 12px;
  background: #1d2c42;
  color: #f4f6f9;
  font: inherit;
  font-size: 25px;
  text-align: center;
  box-shadow: inset 0 1px 2px #09111c66;
}

.field input::placeholder { color: #8492a5; opacity: 1; }
.field input:focus { border-color: #9daec2; outline: 3px solid #8196b333; }
.field label { color: #d4dce7; font-size: 19px; text-align: center; }
.field-error { width: 100%; margin: 0; color: #ff9c9c; font-size: 14px; line-height: 1.4; text-align: center; overflow-wrap: anywhere; }

.group-field label { width: 100%; overflow-wrap: anywhere; }
.entry-group-name { overflow-wrap: anywhere; }

.button {
  min-height: 48px;
  padding: 9px 24px;
  border: 1px solid #8190a3;
  border-radius: 10px;
  background: #dce2e9;
  color: #152033;
  font: inherit;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: .035em;
  cursor: pointer;
  transition: background-color 240ms ease, transform 240ms ease;
}

.button:hover { background: #f0f3f7; }
.button:active { transform: translateY(1px); }
.button:focus-visible { outline: 3px solid #becada; outline-offset: 3px; }

.add-button {
  justify-self: end;
  width: 100%;
  height: 88px;
  margin: 0;
  padding: 9px 12px;
  font-size: 20px;
}

.entries {
  flex: 1 1 0;
  min-height: 0;
  margin: 42px 20px 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #52647c #162338;
  border: 1px solid #43536a;
  border-radius: 10px;
  background: #162338cc;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 16px;
}

th, td {
  height: 34px;
  padding: 5px 10px;
  border: 1px solid #43536a;
  text-align: left;
  font-weight: 400;
}

th { position: sticky; top: 0; z-index: 1; background: #1b2a40; color: #edf1f6; text-align: center; font-weight: 550; }
td { color: #e2e7ee; }
tfoot th { text-align: right; }
tfoot td { font-variant-numeric: tabular-nums; }

.table-editor {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 1px 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.table-editor:focus { border-color: #8196b3; outline: 2px solid #8196b333; }
.entry-row--new {
  transform-origin: top center;
  animation: entry-arrive 420ms cubic-bezier(.2,.8,.2,1) both;
}
.entry-row--new:first-child > td { animation: entry-highlight 650ms ease-out both; }
@keyframes entry-arrive {
  0% { transform: translateY(10px) scale(.95); }
  55% { transform: translateY(0) scale(1.015); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes entry-highlight {
  0%, 25% { background-color: #355777; box-shadow: inset 0 1px 0 #a8d6ff88, inset 0 -1px 0 #a8d6ff55; }
  100% { background-color: transparent; box-shadow: inset 0 1px 0 transparent, inset 0 -1px 0 transparent; }
}
.table-editor[type="number"] { appearance: textfield; }
.table-editor[type="number"]::-webkit-inner-spin-button,
.table-editor[type="number"]::-webkit-outer-spin-button { appearance: none; margin: 0; }
.summary {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 24px;
  flex: 0 0 auto;
  margin: 20px 20px 0;
}

.summary-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-right: auto; }
.summary-actions { flex-direction: column; align-items: flex-start; gap: 10px; }
.overview-label { color: #e5ebf3; font-size: 20px; }
.overview-total-label { margin: 0; color: #c7d0dc; font-size: 17px; }
.overview-buttons { display: flex; gap: 10px; }
.export-button { min-height: 42px; padding: 7px 16px; font-size: 14px; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .entry-row--new { animation-delay: 0ms; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 760px) {
  .page { width: min(100% - 32px, 680px); padding: 80px 0 16px; }
  .entry-form { grid-template-columns: repeat(2, minmax(0, 1fr)) 60px; gap: 14px 8px; }
  .group-field { grid-column: 1; }
  .amount-field { grid-column: 1; }
  .division-field { grid-column: 2; }
  .field input { height: 62px; font-size: 21px; }
  .field label { font-size: 14px; }
  .field input { padding: 0 8px; }
  .add-button { grid-column: 3; grid-row: 2; height: 62px; font-size: 16px; padding: 9px 6px; }
  .entries { margin: 30px 0 0; }
  .summary { flex-direction: column; align-items: stretch; gap: 20px; margin: 20px 0 0; }
  .summary-actions { justify-content: flex-start; }
}

@media (max-height: 620px) {
  .page { padding-top: 80px; }
  .entries { margin-top: 24px; }
  .summary-actions { gap: 6px; }
  .overview-label { font-size: 18px; }
  .overview-total-label { font-size: 15px; }
}

@media (max-width: 760px) and (max-height: 620px) {
  .page { padding-top: 80px; }
  .entry-form { gap: 8px; }
  .field { gap: 6px; }
  .field input { height: 52px; }
  .add-button { height: 52px; }
  .entries { margin-top: 18px; }
  .summary { gap: 10px; }
  .export-button { min-height: 38px; }
}
 .review-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
 .drawer-controls { display: grid; gap: 12px; margin: 24px 0; }
 .drawer-controls .button { width: 100%; }
 .auto-import-control { display: flex; align-items: center; gap: 10px; }
 .photo-review { width: min(900px, 94vw); max-height: 90vh; overflow: auto; padding: 24px; border-radius: 12px; }
 .review-row { display: flex; flex-wrap: wrap; gap: 12px; border-bottom: 1px solid #ddd; padding: 12px 0; }
 .review-row label { display: flex; flex-direction: column; gap: 4px; }
 .review-row input[type=text] { width: 120px; padding: 8px; }
 .review-row p { width: 100%; margin: 0; }
 #review-warnings, #review-result { white-space: pre-wrap; }
 #inbox-list { display: grid; gap: 12px; margin-bottom: 16px; }
