/* #region zone:monitor.page.settings — ศูนย์ตั้งค่า */
/* Settings center (console-settings-view.js) — page layout only; components come from design-system.css. */
.settings-center {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-5);
  align-items: start;
  min-width: 0;
}
.settings-nav {
  min-width: 0;
}
.settings-nav .tabs {
  border-bottom: 1px solid var(--border);
}
.settings-body {
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  min-width: 0;
  outline: none;
}
.settings-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-3) var(--s-4);
}
/* Sticky under the top bar: Save / Cancel stay reachable however far down a long list is scrolled. */
.settings-body > .settings-section-head {
  position: sticky;
  top: var(--topbar-h);
  z-index: 15;
  padding: var(--s-3) 0;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border-soft);
}
.settings-section-text {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  min-width: 0;
  flex: 1 1 280px;
}
.settings-section-actions {
  display: flex;
  gap: var(--s-2);
  margin-left: auto;
}
.settings-section-actions[hidden],
.settings-save-short {
  display: none;
}
.settings-section-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  color: var(--text-1);
}
.settings-section-hint {
  font-size: var(--fs-sm);
  color: var(--text-3);
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: var(--s-6);
  align-items: start;
}

/* Desktop ≥ 1100 px: the section list becomes a sticky left column. */
@media (min-width: 1100px) {
  .settings-center {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: var(--s-8);
  }
  .settings-nav {
    position: sticky;
    top: calc(var(--topbar-h) + var(--s-6));
  }
  .settings-nav .tabs {
    flex-direction: column;
    gap: var(--u-space-2);
    border-bottom: 0;
    overflow: visible;
  }
  .settings-nav .tab {
    justify-content: flex-start;
    width: 100%;
    height: 40px;
    padding: 0 var(--s-3);
    margin: 0;
    border: 0;
    border-radius: var(--r-md);
  }
  .settings-nav .tab:hover {
    background: var(--surface-hover);
  }
  .settings-nav .tab[aria-selected='true'] {
    background: var(--accent-soft);
    color: var(--accent-text);
  }
}

/* Registry rows (Luna และ AI) */
.setting-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--s-1);
  min-width: 0;
}
.setting-aside .select {
  min-width: 220px;
}
.setting-row > .field-error {
  grid-column: 1/-1;
}
.setting-meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.setting-row.is-dirty .row-text strong::after,
.price-field.is-dirty .field-label::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: var(--s-2);
  border-radius: 50%;
  background: var(--warning);
  vertical-align: middle;
}
.reset-link.btn {
  height: auto;
  min-height: var(--u-tap);
  font-size: var(--fs-xs);
}
/* Kit buttons own a real 44px target; an uncontained absolute pseudo target steals other clicks. */
.reset-link[hidden] {
  display: none;
}

/* Price form: 2 × 2 grid of normal-width fields */
.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: var(--s-5) var(--s-6);
  max-width: 760px;
}
.price-field .reset-link {
  align-self: flex-start;
}
.input-affix {
  display: flex;
  align-items: center;
  max-width: 240px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-3);
  transition: border-color var(--dur-fast) var(--ease);
}
.input-affix:focus-within {
  border-color: var(--focus);
  box-shadow: var(--focus-ring);
}
.input-affix .input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-align: right;
}
.input-affix .input:focus {
  box-shadow: none;
}
.input-suffix {
  padding: 0 var(--s-3) 0 var(--s-1);
  font: var(--fs-sm) var(--mono);
  color: var(--text-3);
}
.field.has-error .input-affix {
  border-color: var(--danger);
}

/* Read-only lists */
/* Feature toggles (ระบบและฟีเจอร์): the state pill + switch sit right of each row; the lottery job box spans the row. */
.switch-list {
  margin-top: var(--s-4);
}
.feature-aside {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-3);
}
/* Problem A (2026-09-29): the "ต้องเปิด X ก่อน" dependency line under a feature's hint, and the
 * stacked banners in the toggle-on confirm dialog when it offers to also turn a dependency on. */
.setting-requires {
  font-size: var(--fs-xs);
  color: var(--warning-fg);
}
.feature-dialog-intro {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.feature-job {
  grid-column: 1/-1;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--surface-2);
  min-width: 0;
}
.feature-job-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--text-2);
  min-width: 0;
}
.feature-job-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
}
.feature-job-actions .note {
  margin: 0;
  flex: 1 1 260px;
}
.alert-last {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}
.alert-last-title {
  font-weight: var(--fw-medium);
  color: var(--text-1);
}

/* Change password: the card owns the width (owner review 2026-09-26 — a fixed 420px form looked
   lost in a much wider card); the button stays right-aligned within that same field column. */
.auth-password-panel {
  grid-column: 1 / -1;
}
.auth-password-body {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.auth-password-body > .btn {
  align-self: flex-start;
}
.auth-password {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.auth-password .auth-pair {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.auth-password .field:has(.auth-otp, .u-otp) {
  max-width: none;
}
.auth-password .form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0;
}

/* #region zone:monitor.page.settings.password-fields — ช่องเปลี่ยนรหัสผ่านใช้รูปทรงเดียวกัน */
html:root .auth-password .field {
  margin-top: 0;
}
html:root .auth-password :is(input.u-input, input.u-otp) {
  width: 100%;
  height: var(--u-tap);
  min-height: var(--u-tap);
  border: 1px solid var(--u-line-strong);
  border-radius: var(--u-radius-inner);
  padding: var(--u-space-2) var(--u-space-4);
  font: 400 var(--u-body)/1.4 var(--u-font);
}
html:root .auth-password :is(.u-otp-paste, .form-actions .u-btn) {
  height: var(--u-tap);
  min-height: var(--u-tap);
  padding-block: 0;
}
.auth-password .auth-hint {
  margin: 0;
}
.auth-password .auth-hint:is([hidden], :empty) {
  display: none;
}
/* #endregion */

/* Pending edits: desktop header actions; phones reserve room for the bottom save bar. */
@media (max-width: 759px) {
  .settings-center {
    gap: var(--u-space-3);
    scroll-margin-top: calc(var(--topbar-h) + var(--u-space-4));
  }
  .settings-nav {
    position: sticky;
    top: var(--topbar-h);
    z-index: 16;
    background: var(--surface-0);
    padding-block: var(--u-space-2);
  }
  .settings-body {
    gap: var(--u-space-4);
  }
  .settings-body > .settings-section-head {
    position: static;
    padding: 0;
    border: 0;
  }
  .settings-section-actions:not([hidden]) {
    position: fixed;
    z-index: 18;
    inset-inline: var(--gutter);
    bottom: max(var(--u-space-2), env(safe-area-inset-bottom, 0px));
    width: auto;
    margin: 0;
    padding: var(--u-space-2);
    gap: var(--u-space-2);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--u-radius-card);
    box-shadow: var(--shadow-overlay);
    flex-direction: row-reverse;
  }
  .settings-section-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: var(--u-tap);
  }
  .settings-section-actions .btn-label {
    display: none;
  }
  .settings-save-short {
    display: inline;
  }
  .settings-center:has(.settings-section-actions:not([hidden])) {
    padding-bottom: calc(var(--u-tap) + var(--u-space-6) + env(safe-area-inset-bottom, 0px));
  }
  html:has(.settings-section-actions:not([hidden])) {
    scroll-padding-bottom: calc(var(--u-tap) + var(--u-space-6) + env(safe-area-inset-bottom, 0px));
  }
}
@media (max-width: 699px) {
  /* Sticky on a phone: keep it short — hint hidden, Cancel + Save side by side. */
  .settings-section-hint {
    display: none;
  }
  .settings-section-actions {
    width: 100%;
    flex-direction: row-reverse;
  }
  .settings-section-actions .btn {
    flex: 1 1 auto;
    min-width: 0;
  }
  .setting-aside {
    align-items: stretch;
  }
  .setting-aside .select {
    min-width: 0;
  }
  .input-affix {
    max-width: none;
  }
  .auth-password-panel {
    max-width: none;
  }
  .feature-aside {
    justify-content: space-between;
  }
  .feature-job-actions .btn {
    width: 100%;
  }
}
@container content (max-width:640px) {
  .setting-aside {
    align-items: flex-start;
  }
}
.usage-live-mount:empty {
  display: none;
}

/* #endregion */
/* #region zone:monitor.page.settings.desktop — หน้าตั้งค่าแอป Windows (สถานะเวอร์ชัน SHA-256 ขั้นตอนติดตั้ง) */
.desktop-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}
.desktop-status,
.desktop-suggest {
  margin-bottom: var(--s-3);
}
.sha-value {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-1);
  min-width: 0;
  max-width: 100%;
}
.sha-text {
  min-width: 0;
  max-width: 34ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: var(--fs-sm) var(--mono);
  font-variant-numeric: tabular-nums;
}
.install-steps {
  margin: 0;
  padding-left: 1.5em;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  font-size: var(--fs-sm);
  line-height: 1.65;
  color: var(--text-2);
}
.install-steps li {
  padding-left: var(--s-1);
}
.install-steps li::marker {
  color: var(--text-3);
  font: var(--fw-semibold) var(--fs-sm) var(--mono);
}
@media (max-width: 699px) {
  .sha-text {
    max-width: 16ch;
  }
  .desktop-download-button {
    width: 100%;
  }
}
/* #endregion */
/* #region zone:monitor.weather-history.style — ตารางประวัติที่ปรับตามหน้าจอ */
.weather-history-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: var(--s-3);
  align-items: end;
  margin: var(--s-4) 0;
}
.weather-history-form label {
  display: grid;
  gap: var(--s-2);
  min-width: 0;
}
.weather-history-form input,
.weather-history-form select {
  min-width: 0;
  width: 100%;
  padding: 10px var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-3);
  color: var(--text-1);
}
.weather-history-form input::placeholder {
  color: var(--text-3);
}
.weather-history-form button {
  padding: 11px var(--s-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-3);
  color: var(--text-1);
  cursor: pointer;
}
.weather-history-form button:hover {
  background: var(--surface-hover);
}
.weather-history-result {
  overflow: auto;
  max-height: 320px;
}
.weather-history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.weather-history-table th,
.weather-history-table td {
  padding: 10px var(--s-3);
  border-bottom: 1px solid var(--border, #84939a);
  vertical-align: top;
}
@media (max-width: 820px) {
  .weather-history-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 600px) {
  .weather-history-form {
    grid-template-columns: minmax(0, 1fr);
  }
}
/* AI management card: budget fields in a column, then the live numbers; every gap is a spacing token. */
.ai-gateway-fields {
  display: grid;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.ai-gateway-live > * + * {
  margin-top: var(--s-5);
}
.ai-gateway-live td:first-child {
  white-space: nowrap;
}
/* #endregion */
