/* ==========================================================================
   Base Reset, Shared Controls, Inputs, Modals & Utilities
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

code,
.mono {
  font-family: var(--font-mono);
}

:focus-visible {
  outline: 2px solid var(--action-blue-hover);
  outline-offset: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--action-blue);
  color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
  background: var(--action-blue-hover);
}

.btn-brand {
  background: var(--dbx-lava);
  color: var(--text-inverse);
}

.btn-brand:hover:not(:disabled) {
  background: var(--dbx-lava-hover);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--status-danger-bg);
  color: #F08A8A;
  border-color: var(--status-danger-border);
}

.btn-danger:hover:not(:disabled) {
  background: var(--status-danger);
  color: #FFFFFF;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon {
  padding: 5px;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-icon:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-icon.danger:hover:not(:disabled) {
  background: var(--status-danger-bg);
  color: #F08A8A;
  border-color: var(--status-danger-border);
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.field-error {
  font-size: 12.5px;
  color: #F08A8A;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--action-blue-hover);
}

.textarea {
  resize: vertical;
  min-height: 88px;
}

.input-with-action {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-action .input {
  padding-right: 36px;
}

.input-with-action .input-action-btn {
  position: absolute;
  right: 5px;
}

/* Simple Tags */
.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  background: var(--bg-surface-elevated);
  white-space: nowrap;
}

.tag-kv {
  color: var(--status-warning-text);
  border-color: var(--status-warning-border);
  background: var(--status-warning-bg);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 16, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* Toasts */
.toast-stack {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1200;
  max-width: 340px;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--action-blue);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.toast.warning {
  border-left-color: var(--status-warning-text);
}

.toast.error {
  border-left-color: var(--status-danger);
}

.toast-title {
  font-weight: 600;
}

.toast-message {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 2px;
}

.hidden {
  display: none !important;
}

/* Layout Utilities */
.stack-sm { display: flex; flex-direction: column; gap: 14px; }
.row-gap-xs { display: flex; align-items: center; gap: 6px; }
.row-gap-sm { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.text-sm-muted { font-size: 12px; color: var(--text-muted); }
.text-sm-sec { font-size: 12.5px; color: var(--text-secondary); }
.text-md-sec { margin: 0; color: var(--text-secondary); font-size: 13px; }
.text-ts { color: var(--text-secondary); font-size: 12px; }
.fw-600 { font-weight: 600; }
.th-right { text-align: right; }
.w-full { width: 100%; }
.min-w-0 { min-width: 0; }
.m-0 { margin: 0; }
.mt-2 { margin-top: 8px; }
.ml-2 { margin-left: 8px; }
.m-auto { margin: auto; }
.h1-page { margin: 0 0 6px; font-size: 19px; font-weight: 600; }
.h2-card { font-size: 15px; font-weight: 600; }
.h3-card { margin: 0; font-size: 14px; font-weight: 600; }
.pad-compact { padding: 28px 14px; }
.pad-table-empty { padding: 28px 16px; }
.popover-foot { padding: 8px 4px 2px; border-top: 1px solid var(--border-subtle); margin-top: 6px; }
.ws-opt-label { font-weight: 600; font-size: 13px; }
.ws-opt-host { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
