/*
 * Screens-1 styles: today.js, entry.js (the shared form), exec.js, upload.js. Scoped under .s1.
 * Tokens from app.css only (light + dark follow automatically). RTL, mobile first (375px, one column),
 * 44px touch targets, no horizontal scroll. Served by portal_static (/screens/screens1.css).
 */

/* 44px targets everywhere in these screens, including Portal.ui.copyButton's small buttons */
.s1 .btn, .s1-dialog .btn { min-height: var(--touch); min-width: var(--touch); }
.s1 .btn--small, .s1-dialog .btn--small { min-height: var(--touch); padding: 8px 14px; }
.s1 .input, .s1-dialog .input { min-height: var(--touch); }
.s1 .chip { white-space: normal; }
.s1 .table-wrap { max-width: 100%; }
.s1 .row { min-width: 0; }
.s1 .row > * { min-width: 0; overflow-wrap: anywhere; }
.s1 .s1-danger { color: var(--red); border-color: currentColor; }
.s1 h3.s1-sub { font-size: 15px; margin: 12px 0 4px; }

/* ---------------------------------------------------------------- the form */
.s1-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.s1-head .screen-title { margin: 0; }
.s1-save { margin-inline-start: auto; }
.s1-save[data-state="error"], .s1-save[data-state="conflict"] { color: var(--red); font-weight: 600; }
.s1-save[data-state="local"] { color: var(--orange); font-weight: 600; }
.s1-form { display: block; }
.s1-sec {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin: 0 0 12px;
}
.s1-sec > * + * { margin-top: 10px; }
.s1-sec-title { font-size: 15px; font-weight: 700; color: var(--muted); margin: 0; }
.s1-field-err { font-size: 14px; padding: 6px 10px; }
.s1-grid2, .s1-grid3 { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) {
  .s1-grid2 { grid-template-columns: 1fr 1fr; }
  .s1-grid3 { grid-template-columns: 1.4fr 0.8fr 1.4fr; }
}
.s1-radios { border: 0; margin: 0; padding: 0; min-width: 0; }
.s1-radios legend { padding: 0; margin-bottom: 4px; }
.s1-inline { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.s1-inline legend { width: 100%; }
.s1-modes { display: flex; flex-wrap: wrap; gap: 0 16px; }
.s1-flags { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
@media (min-width: 640px) { .s1-flags { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.s1-soft { color: var(--orange); }

/* payee picker: dropdown on desktop, full-screen sheet on phones */
.s1-picker { position: relative; }
.s1-picker-bar { display: flex; gap: 8px; align-items: center; }
.s1-picker-bar .input { flex: 1 1 auto; min-width: 0; }
.s1-picker-close { display: none; }
.s1-options {
  list-style: none; margin: 4px 0 0; padding: 4px; max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
@media (min-width: 640px) {
  .s1-options { position: absolute; inset-inline: 0; top: 100%; z-index: 20; }
}
.s1-opt { padding: 10px 12px; min-height: var(--touch); border-radius: var(--radius-sm); cursor: pointer; }
.s1-opt + .s1-opt { border-top: 1px solid var(--border); }
.s1-opt[aria-selected="true"], .s1-opt:hover { background: var(--surface-2); }
.s1-opt--new { font-weight: 600; color: var(--accent); }
@media (max-width: 639px) {
  .s1-picker.is-open {
    position: fixed; inset: 0; z-index: 50; background: var(--surface); overflow-y: auto;
    padding: max(12px, env(safe-area-inset-top)) var(--gutter) calc(12px + env(safe-area-inset-bottom));
  }
  .s1-picker.is-open .s1-picker-close { display: inline-flex; }
  .s1-picker.is-open .s1-options { max-height: none; border: 0; box-shadow: none; padding: 0; }
}
.s1-picked > * + * { margin-top: 6px; }
.s1-payee-name { font-size: 17px; }
.s1-last-pays { margin: 0; padding-inline-start: 18px; color: var(--muted); }

/* account */
.s1-acct { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.s1-acct-num { font-weight: 600; }
.s1-acct-opt { align-items: flex-start; padding: 6px 0; }
.s1-acct-opt + .s1-acct-opt { border-top: 1px solid var(--border); }

/* invoices */
.s1-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.s1-inv { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; }
.s1-inv-manual { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 6px; }
@media (min-width: 640px) { .s1-inv-manual { grid-template-columns: 1fr 1fr; } }
.s1-inv-entry .input { flex: 1 1 160px; }
.s1-x { margin-inline-start: auto; min-width: var(--touch); min-height: var(--touch); }
.s1-chip-btn { font-variant-numeric: tabular-nums; }

/* amount + withholding */
.s1-amount-summary { border-top: 1px solid var(--border); padding-top: 8px; }
.s1-sum-line { cursor: pointer; font-weight: 600; min-height: var(--touch); display: flex; align-items: center; }
.s1-calc { direction: rtl; unicode-bidi: plaintext; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; margin: 6px 0; }
.s1-engine-tag { font-size: 14px; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--surface-2); margin: 6px 0; }
.s1-reasons { margin: 4px 0; padding-inline-start: 18px; }
.s1-override { margin-top: 8px; }
.s1-wht > * + * { margin-top: 6px; }

/* warnings + actions */
.s1-warnings { border-color: var(--red); }
.s1-actions { align-items: center; }
.s1-actions .btn--primary { flex: 1 1 160px; }
@media (min-width: 640px) { .s1-actions .btn--primary { flex: 0 0 auto; } }
.s1-attach { list-style: none; margin: 0; padding: 0; }
.s1-filebtn { display: inline-flex; }
.s1-paste { width: 100%; min-height: 160px; }
.s1-import { list-style: none; padding: 0; }

/* diffs (basket revisions, conflicts) */
.s1-diff td, .s1-diff th { overflow-wrap: anywhere; }
.s1-diff .s1-before { color: var(--muted); text-decoration: line-through; }
.s1-diff .s1-after { font-weight: 600; }
.s1-removed { text-decoration: line-through; color: var(--muted); }
.s1-conflict { margin-bottom: 12px; }

/* ---------------------------------------------------------------- today */
.s1-thead { margin-bottom: 8px; }
.s1-totals { font-variant-numeric: tabular-nums; }
.s1-tools { margin: 8px 0 12px; }
.s1-tcard > * + * { margin-top: 6px; }
.s1-tname { font-size: 16px; }
.s1-amt { font-weight: 700; font-size: 17px; }
.s1-st-cancel_requested, .s1-st-rejected { border-color: var(--red); }
.s1-st-held { border-style: dashed; }
.s1-st-paid { border-color: var(--green); }
.s1-inbox-list { list-style: none; margin: 0; padding: 0; }
.s1-inbox-item {
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; min-height: var(--touch);
  padding: 8px 10px; border-radius: var(--radius-sm); color: inherit; text-decoration: none; border: 1px solid var(--border);
}
.s1-inbox-item.is-new { border-color: var(--accent); }
.s1-diffbadge { font-size: 16px; }
.s1-revsel { width: auto; }
.s1-draft { padding: 4px 0; }
.s1-draft--failed { border-inline-start: 3px solid var(--danger, #b42318); padding-inline-start: 8px; }
.s1-note { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- exec */
.s1-exec-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.s1-switches { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .s1-switches { grid-template-columns: 240px 1fr; align-items: end; } }
.s1-xcard > * + * { margin-top: 8px; }
.s1-xcard.is-blocked { border-color: var(--red); background: var(--red-bg); }
.s1-bankname { font-size: 19px; display: block; }
.s1-big { font-size: 22px; font-weight: 700; }
.s1-gate { font-weight: 600; }
.s1-copygrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 640px) { .s1-copygrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.s1-copygrid .btn { width: 100%; }
.s1-xacts .btn { flex: 1 1 auto; }
.s1-report {
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 50vh; overflow-y: auto;
  background: var(--surface-2); padding: 10px; border-radius: var(--radius-sm); font-family: var(--font); font-size: 14px;
}
.s1-verify { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; }

/* ---------------------------------------------------------------- upload */
.s1-drop {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 18px 14px; text-align: center;
  background: var(--surface); cursor: pointer;
}
.s1-drop .row { justify-content: center; }
.s1-drop.is-over { border-color: var(--accent); background: var(--surface-2); }
.s1-drop:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.s1-drop-text { font-weight: 600; margin: 0 0 8px; }
.s1-upcard > * + * { margin-top: 8px; }
.s1-up-head { align-items: center; }
.s1-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.s1-fileicon { font-size: 40px; line-height: 1; }
.s1-fname { overflow-wrap: anywhere; }
.s1-up-state--error { color: var(--red); font-weight: 600; }
.s1-up-state--ok { color: var(--green); font-weight: 600; }
.s1-props { list-style: none; margin: 0; padding: 0; }
.s1-prop { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; }
.s1-dialog .s1-upload { margin-top: 8px; }

/* ---------------------------------------------------------------- WhatsApp buttons + dialogs (wa.js) */
.wa-buttons { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.wa-buttons .btn { min-height: var(--touch); min-width: var(--touch); }
.wa-reason { overflow-wrap: anywhere; }
.wa-dialog .dialog-body { max-width: 640px; }
.wa-dialog .btn, .wa-dialog .input { min-height: var(--touch); }
.wa-preview {
  white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; text-align: start;
  font: inherit; font-size: 14px; line-height: 1.5; margin: 8px 0; padding: 10px 12px;
  max-height: 45vh; overflow-y: auto; background: var(--surface-2, var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius);
}
.wa-note { resize: vertical; }
