/* Shared primitives. Loaded after screen styles; feature selectors may extend them. */

/* From style.css */

.text-link {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 560;
  padding: 8px 0;
}

.group {
  background: var(--surface);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: 0 1px 1px #1c344509;
}

.row {
  width: 100%;
  border: 0;
  background: var(--surface);
  min-height: 66px;
  padding: 11px 16px;
  display: flex;
  align-items: center;
  text-align: left;
  color: inherit;
  gap: 12px;
  position: relative;
}

.row:where(:not(:last-child))::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 61px;
  right: 0;
  height: 1px;
  background: var(--line);
}

.row-icon {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #edf2f7;
  color: #466585;
  font-size: 16px;
  font-weight: 700;
}

.row-icon svg {
  width: 19px;
  height: 19px;
}

.row-icon.black {
  background: #232b35;
  color: var(--on-dark);
}

.row-main {
  min-width: 0;
  flex: 1;
}

.row-title {
  font-size: 15.5px;
  font-weight: 590;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-detail {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-trailing {
  text-align: right;
  flex: none;
}

.row-amount {
  font-size: 15px;
  font-weight: 630;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.row-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.sheet {
  width: 100%;
  max-height: 92%;
  background: var(--bg);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 40px #0e203336;
}

.grabber {
  width: 37px;
  height: 5px;
  border-radius: 5px;
  background: #c9ced5;
  margin: 8px auto 0;
  flex: none;
}

.sheet-head {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex: none;
}

.sheet-head strong {
  font-size: 17px;
  font-weight: 650;
}

.sheet-head button {
  border: 0;
  background: none;
  color: var(--accent);
  min-width: 55px;
  height: 44px;
  font-size: 15px;
  font-weight: 560;
}

.sheet-head .done {
  font-weight: 650;
}

.sheet-body {
  overflow: auto;
  padding: var(--space-xs) var(--space-lg) var(--space-lg);
  scrollbar-width: none;
}

.sheet-body::-webkit-scrollbar {
  display: none;
}

.sheet-footer {
  padding: 10px var(--space-lg)
    max(var(--sheet-footer-space), var(--safe-bottom));
  background: var(--bg);
  flex: none;
}

.primary-button {
  width: 100%;
  height: 50px;
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: var(--radius-button-primary);
  font-size: 16px;
  font-weight: 640;
}

.primary-button:disabled {
  background: #b3c2d0;
}

.form-amount {
  border: 0;
  background: none;
  width: 100%;
  text-align: center;
  font-size: 39px;
  font-weight: 680;
  letter-spacing: -1px;
  outline: none;
  color: var(--ink);
  margin: 24px 0 28px;
  font-variant-numeric: tabular-nums;
}

.form-amount::placeholder {
  color: #b8c0c8;
}

.field-group {
  background: var(--surface);
  border-radius: 15px;
  overflow: hidden;
}

.field-row {
  width: 100%;
  min-height: 54px;
  border: 0;
  background: var(--surface);
  padding: 0 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  gap: 12px;
  font-size: 15px;
  color: var(--ink);
}

.field-row:not(:last-child) {
  border-bottom: 1px solid var(--line);
}

.field-row span:last-child {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-row svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: #b7bec5;
}

.field-input {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: right;
  outline: none;
  color: var(--ink);
}

.field-input::placeholder {
  color: #9aa2ab;
}

.sheet-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin: 10px 4px 0;
}

.checkmark {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.secondary-button {
  height: 45px;
  width: 100%;
  border: 1px solid #d9e3ec;
  background: var(--surface);
  color: var(--accent);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .group,
  .row,
  .field-group,
  .field-row {
    background: var(--surface);
    color: var(--ink);
  }

  .sheet,
  .sheet-footer {
    background: var(--bg);
  }

  .row:where(:not(:last-child))::after,
  .field-row:not(:last-child) {
    border-color: var(--line);
    background-color: var(--line);
  }

  .row-icon {
    background: #30404f;
  }

  .secondary-button {
    background: var(--surface);
    border-color: var(--line);
    color: #dbe4ec;
  }

  .form-amount,
  .field-input {
    color: var(--ink);
  }
}

.row-title,
.row-detail,
.row-amount,
.row-sub {
  display: block;
}

@media (prefers-color-scheme: dark) {
  .text-link {
    color: var(--accent);
  }

  .row-title,
  .row-amount {
    color: var(--ink);
  }

  .row-detail,
  .row-sub {
    color: var(--muted);
  }
}

@media (prefers-color-scheme: dark) {
  .field-row:not(:last-child) {
    background: var(--surface);
  }
}

/* From design.css */

.row-main strong {
  display: block;
  font-size: 15.5px;
  font-weight: 590;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-main small {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-row.field {
  cursor: default;
}

.field-row > input,
.field-row > select,
.field-row > textarea {
  font: inherit;
  color: var(--muted);
  text-align: right;
  border: 0;
  background: transparent;
  width: 60%;
  min-width: 0;
  padding: 10px 0;
  outline-offset: 0;
}

.field-row > select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b7bec5' stroke-width='2'%3E%3Cpath d='m9 5 7 7-7 7'/%3E%3C/svg%3E");
  background-position: right center;
  background-repeat: no-repeat;
  background-size: 16px;
}

.field-row input::-webkit-date-and-time-value {
  text-align: right;
}

.field-row > .date-input-shell {
  width: 65%;
  min-width: 0;
  overflow: hidden;
}

.form-amount {
  min-width: 0;
}

.text-link.full {
  min-height: 44px;
  display: block;
}

.primary-button .icon {
  width: 20px;
  height: 20px;
  vertical-align: middle;
  margin-right: 6px;
}

.secondary-button {
  margin-top: 10px;
}

dialog.sheet {
  position: fixed;
  padding: 0;
  margin: 0;
  border: 0;
  overflow: hidden;
  max-width: 100vw;
  max-height: 92dvh;
  color: inherit;
}

dialog.sheet[open] {
  display: flex;
}

dialog::backdrop {
  background: #19283a58;
}

.sheet-head h2 {
  font-size: 17px;
  font-weight: 650;
  margin: 0;
  text-align: center;
}

.sheet-head {
  touch-action: none;
}

.sheet-no-drag .sheet-head {
  touch-action: pan-y;
}

.sheet-head .sheet-close {
  padding: 0;
}

.sheet-grabber {
  touch-action: none;
  cursor: grab;
}

.sheet-body {
  min-height: 0;
}

.sheet-body:has(> form) {
  padding: 0;
  display: flex;
  overflow: hidden;
}

.sheet-body > form {
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.sheet-form-content {
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-xs) var(--space-lg) var(--space-lg);
  overscroll-behavior: contain;
}

.sheet-form-content > .field-group {
  margin-bottom: 10px;
}

.sheet-form-content details {
  margin: 12px 4px;
}

:where(.sheet-form-content) summary {
  padding: 10px 0;
  font-size: 14px;
  color: var(--accent);
  cursor: pointer;
}

.sheet-footer {
  margin-top: auto;
}

.sheet-body > .primary-button,
.sheet-body > .secondary-button {
  margin-top: 14px;
}

.sheet-body > .group + button {
  margin-top: 14px;
}

.check-label {
  display: flex;
  position: relative;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 8px 4px;
  font-size: 14px;
  cursor: pointer;
}

.check-label input {
  position: absolute;
  opacity: 0;
  width: 24px;
  height: 24px;
}

.check-label .checkmark {
  border: 1.5px solid #c7d0d8;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: transparent;
  flex: none;
}

.check-label .checkmark .icon {
  width: 15px;
  height: 15px;
}

.check-label input:checked + .checkmark {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.check-label input:focus-visible + .checkmark {
  outline: 3px solid #7caefb;
  outline-offset: 2px;
}

.row-icon,
.field-group:has(.debt-person-picker) {
  overflow: visible;
}

.field-label-text {
  flex-shrink: 0;
}

.inline-picker,
.calculator-panel {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  padding: 14px 20px 20px;
  overflow: hidden;
  border-radius: inherit;
}

/* Keep safe-area space inside the scroller, without a fixed opaque bottom strip. */
.inline-picker {
  padding-bottom: 0;
}
.inline-picker .picker-list {
  padding-bottom: max(var(--space-lg), var(--safe-bottom));
  scroll-padding-bottom: max(var(--space-lg), var(--safe-bottom));
}

.inline-picker .nav,
.calculator-panel .nav {
  flex-shrink: 0;
}

.inline-picker .searchbox {
  margin: 12px 0;
  flex-shrink: 0;
}

.calculator-panel {
  gap: 10px;
}

.calculator-panel .form-amount {
  width: 100%;
  margin: 6px 0;
  font-size: 30px;
}

.calculator-panel > .primary-button {
  flex-shrink: 0;
}

.field-row.category-quick-field {
  display: block;
  padding: 12px 14px;
}

.unsaved-prompt {
  position: absolute;
  inset: auto 0 0;
  z-index: 12;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  padding: 24px 20px;
  box-shadow: 0 -10px 40px #182a3d45;
}

.unsaved-prompt h3 {
  margin: 0;
  font-size: 18px;
}

.unsaved-prompt .primary-button {
  margin-top: 20px;
}

.sheet-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
  gap: 4px;
}

.sheet-head > :first-child {
  justify-self: start;
}

.sheet-head > :last-child {
  justify-self: end;
}

.sheet-head h2 {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-picker .nav,
.calculator-panel .nav {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 8px;
}

.inline-picker .nav-title,
.calculator-panel .nav-title {
  text-align: center;
}

dialog.sheet {
  overflow: visible;
}

.sheet-grabber {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 64px;
  height: 14px;
  margin: 0;
  background: transparent;
}

.sheet-grabber::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 37px;
  height: 4px;
  border-radius: 5px;
  background: #c9ced5;
}

.sheet-no-drag .sheet-grabber {
  display: none;
}

body.sheet-open {
  overflow: hidden;
}

.sheet-body {
  scrollbar-gutter: stable;
}

.sheet-keyboard-open .sheet-body:has(> form),
.sheet-keyboard-open .sheet-body > form,
.sheet-keyboard-open .sheet-form-content {
  flex: 0 1 auto;
}

.sheet-form-content {
  overflow-anchor: none;
  scroll-padding-block: 12px;
}

dialog.sheet.calculator-open {
  height: 640px;
}

.calculator-panel {
  overflow: hidden;
  overscroll-behavior: contain;
}

.calculator-panel .form-amount::placeholder {
  color: var(--muted);
  opacity: 0.45;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: #19283a58;
  z-index: 39;
}

dialog.sheet.sheet-custom {
  z-index: 40;
}

.sheet-footer {
  flex-shrink: 0;
}

.sheet-keyboard-open .sheet-footer {
  padding-bottom: 12px;
}

.sheet-keyboard-open .sheet-body > form > .sheet-footer {
  display: none;
}

@media (max-width: 750px) {
  body.sheet-open {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
  }
}

dialog.sheet:not([open]) {
  display: none;
}

@media (max-width: 750px) {
  body.sheet-open #app.phone {
    height: var(--sheet-page-height, 100dvh);
  }
}

.sheet-custom
  input:not(.form-amount):not([type="checkbox"]):not([type="radio"]),
.sheet-custom textarea,
.sheet-custom select {
  font-size: max(16px, 1em);
}

.row > .chevron {
  display: none;
}

body.sheet-open.sheet-document-layer {
  position: static;
  height: auto;
}

.sheet-document-layer dialog.sheet.sheet-custom,
.sheet-document-layer > .sheet-backdrop {
  position: absolute;
}

.sheet-coordinate-origin {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  visibility: hidden;
}

.field-row > select {
  text-align-last: right;
}

.row-title,
.row-main strong {
  font-size: var(--text-body);
}

.row-detail,
.row-sub,
.row-main small,
.sheet-hint {
  font-size: var(--text-caption);
  color: var(--muted);
  line-height: 1.45;
}

.text-link {
  color: var(--accent);
}

.row-detail,
.row-sub {
  white-space: normal;
  overflow-wrap: anywhere;
}

.row-trailing {
  max-width: 48%;
}

.field-row:has(.field-choice) {
  min-height: 68px;
  padding-block: var(--space-sm);
}

.row-icon.black {
  color: var(--on-dark);
}

.row-icon.blue {
  background: var(--tone-blue-bg);
  color: var(--tone-blue-ink);
}

.row-icon.green {
  background: var(--tone-green-bg);
  color: var(--tone-green-ink);
}

.row-icon.yellow {
  background: var(--tone-yellow-bg);
  color: var(--tone-yellow-ink);
}

.row-icon.purple {
  background: var(--tone-purple-bg);
  color: var(--tone-purple-ink);
}

.row-icon.red {
  background: var(--tone-red-bg);
  color: var(--tone-red-ink);
}

.primary-button {
  background: var(--accent);
  color: var(--on-accent);
}

.sheet-form-content .operation-advanced {
  margin: 16px 0 8px;
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
}

.sheet-keyboard-open .receipt-debt-people {
  max-height: 160px;
}
