/* ฟอร์ม ตัวกรอง และการแจ้งเตือน */

/* ---------- ฟอร์ม ---------- */

.form-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  display: grid;
  gap: 1.1rem;
}
.form-card-flat { box-shadow: none; border: none; border-radius: 0; background: transparent; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.field { display: grid; gap: 0.3rem; }
/* ต้องชนะ display ของ .btn ที่ specificity สูงกว่า จึงต้องใช้ !important */
.is-hidden { display: none !important; }

label { font-size: var(--step-sm); color: var(--text-dim); font-weight: 500; }

input[type="text"], input[type="password"], input[type="date"], select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--bg-grain);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: var(--step-0);
}
input[inputmode="decimal"], input[type="date"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
input:hover, select:hover { border-color: #2f4257; }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.check { display: flex; align-items: center; gap: 0.5rem; color: var(--text); cursor: pointer; }
.check input { accent-color: var(--accent); width: 1rem; height: 1rem; }

.side-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  border: none;
  padding: 0;
  margin: 0;
}
.side-toggle legend { padding: 0 0 0.4rem; }
.side-option {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-grain);
  font-weight: 600;
  cursor: pointer;
}
.side-option input { position: absolute; opacity: 0; pointer-events: none; }
.side-buy:has(input:checked)  { border-color: var(--up);   background: var(--up-soft);   color: var(--up); }
.side-sell:has(input:checked) { border-color: var(--down); background: var(--down-soft); color: var(--down); }
.side-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.fee-box {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.calc { display: grid; gap: 0.35rem; margin: 0; }
.calc div { display: flex; justify-content: space-between; gap: var(--gap); }
.calc dt { color: var(--text-dim); font-size: var(--step-sm); }
.calc dd {
  margin: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.calc-total {
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
  font-weight: 600;
}
.calc-total dt { color: var(--text); }

.form-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.filters {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
}
.filters .field { min-width: 140px; }
.filter-actions { display: flex; gap: 0.5rem; }

.mark-form {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
}
.mark-form label { align-self: center; }
.mark-form .mark-input { width: 10rem; }

.mark-input {
  width: 6.5rem;
  padding: 0.3rem 0.5rem;
  text-align: right;
  background: var(--bg-grain);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--step-sm);
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 1rem 1.2rem;
  border: 1px solid rgba(255, 92, 108, 0.25);
  border-radius: var(--radius-lg);
  background: rgba(255, 92, 108, 0.05);
  flex-wrap: wrap;
}
.danger-zone p { margin: 0; font-size: var(--step-sm); }

.backup-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.3rem; }
.backup-list li { display: flex; justify-content: space-between; gap: var(--gap); font-size: var(--step-sm); }

/* ---------- แจ้งเตือน ---------- */

.flash {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: var(--step-sm);
}
.flash-ok    { background: var(--up-soft);   border-color: rgba(34,201,147,.35);  color: #8ff0cd; }
.flash-error { background: var(--down-soft); border-color: rgba(255,92,108,.35);  color: #ffb3ba; }
.flash-warn  { background: rgba(240,180,41,.10); border-color: rgba(240,180,41,.35); color: #f5d38a; }

/* ---------- หน้าเข้าสู่ระบบ ---------- */

.gate {
  width: min(380px, 100%);
  display: grid;
  gap: 0.6rem;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.gate-mark { font-size: 1.8rem; color: var(--up); line-height: 1; }
.gate form { display: grid; gap: 0.5rem; margin-top: 0.5rem; }
.gate p { margin: 0 0 0.5rem; font-size: var(--step-sm); }
