/* #region zone:monitor.ui.button — ปุ่ม */
:where(button) {
  cursor: pointer;
}
.btn-block {
  width: 100%;
}
.btn[aria-busy='true'] {
  cursor: progress;
}
.btn[aria-busy='true'] .btn-glyph {
  display: none;
}
.btn-spinner {
  width: var(--icon-sm);
  height: var(--icon-sm);
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* #endregion */
/* #region zone:monitor.ui.field — ฟิลด์ */
textarea.u-input {
  min-height: 96px;
  resize: vertical;
}
input[type='file'] {
  font-size: var(--fs-sm);
  color: var(--text-2);
  max-width: 100%;
}
input[type='file']::file-selector-button {
  height: var(--h-sm);
  margin-right: var(--s-3);
  padding: 0 var(--s-3);
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-1);
  font: inherit;
  font-weight: var(--fw-medium);
  cursor: pointer;
}
input[type='checkbox'],
input[type='radio'] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  margin: 0;
}
.guide-feature-item {
  min-height: var(--h-lg);
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-1);
  cursor: pointer;
  line-height: 1.5;
}
.guide-feature-item:hover {
  border-color: var(--border-strong);
}
.guide-feature-item:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.guide-feature-item:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.guide-card {
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.guide-card-header {
  font-weight: var(--fw-semibold);
  color: var(--accent);
  margin-bottom: var(--s-4);
}
.guide-card-row {
  padding: var(--s-3) 0;
  border-top: 1px solid var(--border-soft);
}
.guide-card-feature {
  font-weight: var(--fw-semibold);
  margin-bottom: var(--s-2);
}
.guide-card-command {
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.guide-card-footer {
  margin-top: var(--s-3);
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-width: 0;
}
.field-label,
label.field-label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-2);
}
.field-helper {
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.field-error {
  font-size: var(--fs-xs);
  color: var(--danger-fg);
}
.field-error:empty {
  display: none;
}
.field.has-error .input,
.field.has-error .select-trigger {
  border-color: var(--danger);
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-top: var(--s-4);
}
@media (max-width: 699px) {
  .form-actions {
    flex-direction: column-reverse;
  }
  .form-actions .btn {
    width: 100%;
  }
}

/* #endregion */
/* #region zone:monitor.ui.password — ช่องรหัสผ่านพร้อมปุ่มตา */
.password-field {
  position: relative;
  display: block;
  width: 100%;
}
.password-field > .input {
  padding-right: calc(var(--s-10) + var(--s-2));
}
.password-eye {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--s-10);
  height: 100%;
  min-height: var(--s-10);
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}
.password-eye:hover {
  color: var(--text-1);
}
.password-eye:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.password-eye[aria-pressed='true'] {
  color: var(--accent-text);
}
.password-eye-glyph {
  width: var(--icon-md);
  height: var(--icon-md);
}
/* #endregion */
/* #region zone:monitor.ui.totp — อินพุตรหัส 2FA 6 หลัก (กล่องแยก 6 ช่อง) */
.totp {
  display: flex;
  gap: var(--s-2);
  flex-wrap: nowrap;
  width: 100%;
  max-width: 336px;
}
.totp-box {
  width: 0;
  min-width: 0;
  flex: 1 1 0;
  height: var(--h-lg);
  padding: 0;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-1);
  font: 500 22px/1 var(--font);
  font-variant-numeric: tabular-nums;
  text-align: center;
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
.totp-box:hover:not(:disabled) {
  border-color: var(--text-faint);
}
.totp-box:focus-visible {
  outline: none;
  border-color: var(--focus);
  /* inset = 2px ring in total (border + 1px); stays inside the box so no overflow clipping, no size change */
  box-shadow: inset 0 0 0 1px var(--focus);
}
@media (prefers-reduced-motion: reduce) {
  .totp-box {
    transition: none;
  }
}
.totp-box:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.field.has-error .totp-box {
  border-color: var(--danger);
}
@media (max-width: 359px) {
  .totp {
    gap: var(--s-1);
  }
  .totp-box {
    width: var(--h-md);
    font-size: var(--fs-lg);
  }
}

/* #endregion */
/* #region zone:monitor.ui.select — dropdown ชั้นลอย และเมนู */
.select {
  position: relative;
  display: inline-flex;
  min-width: 0;
  max-width: 100%;
}
.select-block {
  display: flex;
  width: 100%;
}
.select-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  inset: auto auto 0 0;
}
.select-trigger {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  min-width: 140px;
  height: var(--h-md);

  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
.select-sm .select-trigger {
  height: var(--h-sm);
  font-size: var(--fs-sm);
  min-width: 120px;
}
.select-trigger:hover:not(:disabled) {
  border-color: var(--text-faint);
}
.select-trigger:focus-visible,
.select-trigger[aria-expanded='true'] {
  outline: none;
  border-color: var(--focus);
  box-shadow: var(--focus-ring);
}
.select-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.select-glyph {
  width: var(--icon-sm);
  height: var(--icon-sm);
  color: var(--text-3);
}
.select-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.select-value.is-placeholder {
  color: var(--text-faint);
}
.select-chevron {
  width: 16px;
  height: 16px;
  flex: none;
  background: currentColor;
  color: var(--text-3);
  -webkit-mask: url('/monitor/icons/chevron-down.svg') center/16px 16px no-repeat;
  mask: url('/monitor/icons/chevron-down.svg') center/16px 16px no-repeat;
  transition: transform var(--dur) var(--ease);
}
.select-trigger[aria-expanded='true'] .select-chevron {
  transform: rotate(180deg);
}

/* floating layers: popovers (selects, menus) and phone bottom sheets. Mounted in the top layer. */
.layer {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-1);
  overflow: visible;
  font-family: var(--font);
}
.layer-popover {
  position: fixed;
  inset: 0 auto auto 0;
  width: 0;
  height: 0;
}
.popover {
  position: fixed;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  max-width: min(420px, calc(100vw - 16px));
  overflow: hidden;

  animation: pop-in var(--dur) var(--ease);
}
.popover.is-above {
  animation-name: pop-in-above;
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes pop-in-above {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.layer-sheet {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  background: var(--scrim);
  display: flex;
  align-items: flex-end;
  animation: fade-in var(--dur) var(--ease);
}
.sheet {
  width: 100%;
  max-height: 78dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface-raised);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-top: 1px solid var(--border-strong);
  box-shadow: var(--shadow-overlay);
  padding: 0 0 calc(var(--s-2) + env(safe-area-inset-bottom));
  animation: sheet-in 220ms var(--ease);
}
.sheet-handle {
  width: 40px;
  height: 5px;
  border-radius: var(--r-full);
  background: var(--border-strong);
  margin: var(--s-2) auto var(--s-1);
  touch-action: none;
  cursor: grab;
}
.sheet-title {
  padding: var(--s-2) var(--s-5) var(--s-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-2);
}
@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
  to {
    transform: none;
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.select-search {
  margin: var(--s-2);
  width: auto;
  flex: none;
}
.listbox {
  display: grid;
  gap: var(--u-space-2);
  align-content: start;
  overflow-y: auto;
  padding: var(--s-1);
  overscroll-behavior: contain;
  flex: 1;
}
.listbox-group {
  padding: var(--s-2) var(--s-3) var(--s-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-3);
}
.listbox-empty {
  padding: var(--s-3);
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.option {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 36px;
  padding: var(--s-1) var(--s-3) var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: var(--fs-md);
}
.sheet .option {
  min-height: 44px;
}
.option.is-active {
  background: var(--surface-hover);
}
.option[aria-selected='true'] {
  color: var(--accent-text);
  font-weight: var(--fw-medium);
}
.option[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
}
.option-check {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--accent-text);
}
.option-check .icon {
  width: 18px;
  height: 18px;
}
.option-body {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  min-width: 0;
  flex: 1;
}
.option-glyph {
  width: var(--icon-sm);
  height: var(--icon-sm);
  align-self: center;
}
.option-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.option-hint {
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}

/* menus */
.menu-popover {
  min-width: 220px;
}
.menu {
  display: flex;
  flex-direction: column;
  gap: var(--u-space-2);
  padding: var(--s-1);
}

.sheet .menu-item {
  min-height: 44px;
}
.menu-item:hover:not(:disabled),
.menu-item:focus-visible {
  background: var(--surface-hover);
  outline: none;
}
.menu-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.menu-glyph {
  width: var(--icon-sm);
  height: var(--icon-sm);
  color: var(--text-3);
}
.menu-label {
  flex: 1;
}
.menu-hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.menu-item.is-danger {
  color: var(--danger-fg);
}
.menu-item.is-danger .menu-glyph {
  color: var(--danger-fg);
}
.menu-divider {
  height: 1px;
  background: var(--border);
  margin: var(--s-1) var(--s-2);
}

/* #endregion */
