/* #region zone:finance.style.overlays — ล็อกอิน กล่องฟอร์ม ยืนยัน toast และ Luna ลอยมุมขวาล่าง */
/* Login: the shared login-shell.css owns the layout; these are the Finance form controls inside it. */
.finance-login-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.finance-login-form label,
.finance-login-form .field-label {
  margin-top: var(--sp-2);
}
.finance-login-form input:not(.totp-box) {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: left;
}
.otp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.otp-head .field-label {
  margin-top: 0;
  font-size: var(--u-text-sm);
  font-weight: 500;
}
.otp-head .text-button {
  margin-right: -8px;
  font-size: var(--u-text-sm);
}
.totp {
  display: flex;
  gap: var(--sp-2);
  width: 100%;
}
.totp-box {
  width: 0;
  min-width: 0;
  flex: 1 1 0;
  height: 52px;
  padding: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--panel);
}
/* A 320px screen cannot hold six 44px boxes in a 24px-gutter dialog: two rows of three, same boxes. */
@media (max-width: 380px) {
  .totp {
    flex-wrap: wrap;
  }
  .totp-box {
    flex: 1 1 calc(33.333% - 8px);
  }
}
.totp-box:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.totp-box[aria-invalid='true'] {
  border: 2px solid var(--login-error);
}
.finance-login-form button[type='submit'] {
  min-height: 48px;
  margin-top: var(--sp-4);
  font-size: 14px;
}
.login-error {
  color: var(--login-error);
  font-size: var(--u-text-sm);
  line-height: 1.6;
  margin: var(--sp-1) 0 0;
}
.login-error a {
  margin-left: var(--sp-1);
  font-weight: 600;
  color: var(--login-error);
}
.login-notice {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-control);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: var(--u-text-sm);
}
.login-help {
  font-size: var(--u-text-sm);
  color: var(--muted);
}

/* Form dialog: 520px centred on desktop, full-screen sheet ≤ 480px; footer right-aligned, primary right. */
dialog {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--u-radius-dialog);
  background: var(--u-sheet);
  color: var(--text);
  box-shadow: var(--pop-shadow);
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
}
dialog::backdrop {
  background: var(--u-scrim);
}
/* The shell never scrolls (shared rule in desk-tokens.css): the form fills it, only .form-fields scrolls. */
#quick-form,
.trade-dialog form {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-height: 0;
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-2) var(--sp-6);
}
.dialog-head h2,
.confirm-dialog h2 {
  font-size: var(--t-section);
  font-weight: 650;
}
.form-fields {
  display: grid;
  align-content: start;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-6) var(--sp-4);
}
@media (hover: hover) and (pointer: fine) {
  /* the 6px gap + 8px scrollbar take 14px of the right padding, so the text edge stays at 24px */
  .form-fields {
    padding-inline-end: 10px;
  }
}
.field {
  display: grid;
  gap: var(--sp-1);
}
.field label {
  font-size: var(--t-label);
  font-weight: 600;
}
.field label small {
  color: var(--muted);
  font-weight: 400;
}
.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-input);
  background: var(--panel);
}
.field input {
  text-align: left;
}
.field input:focus-visible,
.field select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--acc-ring);
}
/* Thai file picker: the real input stays (keyboard, forms) but is visually hidden; the label is the button. */
.file-pick {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  position: relative;
}
.field .file-pick-input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
  clip-path: inset(50%);
}
.field .file-pick-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-button);
  background: var(--panel);
  cursor: pointer;
  white-space: nowrap;
}
.field .file-pick-button:hover {
  background: var(--hover);
}
.field .file-pick-input:focus-visible + .file-pick-button {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--acc-ring);
}
.field .file-pick-name {
  min-width: 0;
  flex: 1 1 8rem;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: var(--t-label);
}
.field [aria-invalid='true'].file-pick-input + .file-pick-button {
  border: 2px solid var(--error);
}
.field [aria-invalid='true'] {
  border: 2px solid var(--error);
}
.field-hint {
  color: var(--muted);
  font-size: var(--t-caption);
}
.field-error {
  color: var(--error);
  font-size: var(--t-caption);
  font-weight: 600;
}
.adorned {
  position: relative;
  display: block;
}
.adorned input {
  padding-left: var(--sp-8);
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.adornment {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 600;
}

.form-error {
  /* never flush against the footer divider: 12px above and below */
  margin: var(--sp-3) var(--sp-6);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-control);
  background: var(--error-soft);
  color: var(--error);
  font-size: var(--t-label);
  font-weight: 600;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--line);
}
.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
}
.confirm-dialog h2 {
  padding: var(--sp-6) var(--sp-6) var(--sp-2);
}
.confirm-dialog p {
  padding: 0 var(--sp-6) var(--sp-4);
  color: var(--muted);
}
/* the 2FA step-up boxes sit inside the same 24px gutter as the text */
.confirm-dialog .totp {
  box-sizing: border-box;
  padding: 0 var(--sp-6) var(--sp-4);
}
.csv-preview {
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--panel2);
  border-radius: var(--r-inner);
  overflow-x: auto;
}

/* Toast: passive notices only, top-centre. */
.toast {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  max-width: calc(100vw - 32px);
  padding: 10px var(--sp-4);
  border-radius: var(--r-control);
  background: var(--tip-bg);
  color: var(--tip-fg);
  box-shadow: var(--pop-shadow);
  font-size: var(--t-label);
}

/* Undo after a delete: a page row under the header (not a toast, which is passive and 4 s), kept for 60 s. */
.undo-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: 8px var(--gutter);
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: var(--t-label);
}
.undo-strip[hidden] {
  display: none;
}
.undo-action {
  min-height: 44px;
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-button);
  background: var(--panel);
  color: var(--accent-text);
  font-weight: 650;
}
.undo-action:hover {
  background: var(--hover);
}
#delete-dialog .dialog-actions {
  flex-wrap: wrap;
}

/* Luna: the round avatar launcher shared with Monitor/Account (52px, 20px/24px offsets + safe area).
   One clean brand ring (assistant/luna-thinking.css paints it and its "busy" halo); no second well ring. */
.luna-launcher {
  position: fixed;
  z-index: var(--z-luna-launcher);
  right: calc(24px + env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  min-width: 52px;
  padding: 0;
  border-radius: 50%;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.luna-launcher .luna-portrait {
  width: 47px;
  height: 47px;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.luna-launcher:hover .luna-portrait {
  transform: scale(1.04);
}
.luna-launcher:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.luna-launcher[aria-expanded='true'] {
  display: none;
}
.luna-portrait {
  display: block;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--header-well-bg);
}
.luna-avatar {
  display: block;
  width: 100%;
  height: 100%;
}
.luna-panel {
  position: fixed;
  z-index: var(--z-luna);
  right: calc(24px + env(safe-area-inset-right));
  bottom: calc(90px + env(safe-area-inset-bottom));
  width: 400px;
  max-width: calc(100vw - 32px);
  height: min(640px, calc(100dvh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--pop-shadow);
  overflow: hidden;
}
.luna-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.luna-head > div {
  display: grid;
  flex: 1;
  min-width: 0;
}
.luna-head small {
  color: var(--muted);
  font-size: var(--t-caption);
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--panel2);
  white-space: pre-wrap;
}
.bubble.user {
  align-self: flex-end;
  background: var(--acc-soft);
}
.bubble.error {
  background: var(--error-soft);
  color: var(--error);
}
.chat-suggestions {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 var(--sp-3) var(--sp-2);
  scrollbar-width: none;
}
.chat-suggestions::-webkit-scrollbar {
  display: none;
}
.chat-suggestions button {
  min-height: 32px;
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: var(--u-radius-pill);
  color: var(--accent-text);
  background: var(--acc-soft);
}
.chat-form {
  display: grid;
  gap: 6px;
  padding: var(--sp-3);
  border-top: 1px solid var(--line);
}
.chat-composer {
  position: relative;
  display: grid;
  width: 100%;
}
/* Height is set by assistant/luna-composer.js: one line (or the whole placeholder) up to five lines. The
   right padding keeps typed text clear of the Send button inside the box. */
.chat-form textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  resize: none;
  overflow-y: hidden;
  padding: 10px 76px 10px var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-input);
  background: var(--panel);
  line-height: 1.55;
  text-align: left;
}
.chat-form textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--acc-ring);
}
.chat-form textarea.is-max {
  overflow-y: auto;
}
.chat-form .primary {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-height: 32px;
  padding: 5px var(--sp-3);
}
.chat-form > .field-hint {
  padding: 0 2px;
  line-height: 1.45;
}
.chat-pii {
  padding: var(--sp-2) 10px;
  border: 1px solid var(--amber);
  border-radius: var(--r-control);
  background: var(--amber-soft);
  color: var(--text);
  font-size: var(--t-caption);
}
.chat-pii strong {
  display: block;
  color: var(--amber);
}
.chat-pii p {
  margin-top: 3px;
  overflow-wrap: anywhere;
}
.chat-pii p span {
  color: var(--muted);
}
.luna-audit {
  align-self: flex-start;
  max-width: 94%;
  font-size: var(--t-caption);
  color: var(--muted);
}
.luna-audit summary {
  cursor: pointer;
  color: var(--accent-text);
  font-weight: 600;
}
.luna-audit ul {
  margin: 6px 0 0;
  padding-left: 18px;
}
.bubble.error .chat-retry {
  display: flex;
  margin-top: var(--sp-2);
  min-height: 32px;
  border-color: var(--error);
  color: var(--error);
  background: var(--panel);
}

@media (max-width: 600px) {
  .toast {
    top: auto;
    bottom: calc(72px + 12px + env(safe-area-inset-bottom));
  }
  .luna-launcher {
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(14px + env(safe-area-inset-bottom));
    transition:
      transform 0.2s ease,
      opacity 0.2s ease;
  }
  .luna-launcher.is-tucked:not(:focus-visible) {
    transform: translateX(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
  }
  /* Phones get a 44px Send button; one line of text plus 16px above and below keeps 6px around it. */
  .chat-form textarea {
    padding-top: var(--sp-4);
    padding-bottom: var(--sp-4);
  }
  .chat-form .primary {
    min-height: 44px;
  }
  .luna-panel {
    inset: auto 0 0 0;
    width: 100%;
    max-width: none;
    height: min(85dvh, 640px);
    border-radius: var(--r-card) var(--r-card) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}
@media (max-width: 480px) {
  dialog:not(.confirm-dialog) {
    width: 100vw;
    max-width: 100vw;
    height: fit-content;
    max-height: 100dvh;
    margin: auto 0 0;
    border-radius: var(--u-radius-dialog);
    border: 0;
  }
  .form-fields {
    flex: 0 1 auto;
  }
  .dialog-actions {
    padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
  }
  .dialog-actions button {
    flex: 1;
  }
}
/* #endregion */
