/* ═══════════════ SETTINGS v2.0 ═══════════════ */

.settings-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-content: start;
  align-items: start;
}

.settings-group {
  background: var(--surface); border-radius: var(--radius);
  padding: 1.35rem; border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  resize: horizontal;
  overflow: auto;
  min-width: 300px;
  max-width: calc(100% - 1.25rem);
  flex-shrink: 0;
  box-sizing: border-box;
  width: 380px;
}
.settings-group h3 { font-size: 0.875rem; font-weight: 700; margin-bottom: 1rem; color: var(--text); letter-spacing: -0.2px; }
.settings-save-bar { width: 100% !important; resize: none !important; flex-basis: 100%; }

.setting-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 0; border-bottom: 1px solid var(--border-light); gap: 1rem;
}
.setting-item:last-child { border-bottom: none; padding-bottom: 0; }
.setting-item.column { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
.setting-item label { font-size: 0.85rem; font-weight: 500; color: var(--text); }

.setting-input {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.875rem; background: var(--bg); color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.setting-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,107,53,0.08); }
.setting-select {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.875rem; background: var(--bg); color: var(--text);
}

.permissions-table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.permissions-table { min-width: 400px; }
.permissions-table td { text-align: center; }
.permissions-table td:first-child { text-align: left; font-weight: 500; font-size: 0.825rem; }
.permissions-table td:last-child  { text-align: center; width: 40px; }
.perm-check { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }
.perm-check-owner { opacity: 0.45; cursor: not-allowed; accent-color: var(--text-muted); }

.settings-group-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; gap: 0.5rem; flex-wrap: wrap;
}
.settings-group-header h3 { margin-bottom: 0; }
.settings-group-actions { display: flex; gap: 0.4rem; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.775rem; }

/* Role context menu */
#role-ctx-menu {
  display: none; position: fixed; z-index: 99999;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  min-width: 175px; padding: 0.2rem 0; overflow: hidden;
}
.role-ctx-title {
  padding: 0.4rem 0.85rem; font-size: 0.75rem;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.role-ctx-btn {
  display: block; width: 100%; text-align: left;
  padding: 0.5rem 0.85rem; background: none; border: none;
  cursor: pointer; font-size: 0.825rem; color: var(--text);
  transition: background var(--transition);
}
.role-ctx-btn:hover { background: var(--border-light); }
.role-ctx-delete { color: var(--danger, #e74c3c); }

/* Roles chip list */
.roles-chips-label {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: 0.5px; margin-bottom: 0.5rem;
}
.roles-chips-wrap {
  display: flex; flex-wrap: wrap; gap: 0.45rem;
}
.role-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.65rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 500;
  background: var(--primary); color: #fff;
  cursor: default; user-select: none;
}
.role-chip-builtin {
  /* all chips share the same dark style */
}
.role-chip-del {
  background: none; border: none; color: rgba(255,255,255,0.9);
  cursor: pointer; font-size: 1rem; line-height: 1; font-weight: 700;
  padding: 0 0 0 0.15rem; margin-left: 0.1rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.role-chip.chip-ready {
  background: #1a1a1a;
  box-shadow: 0 0 0 2px #e74c3c55;
}
.role-chip.chip-ready .role-chip-del {
  opacity: 1;
  pointer-events: auto;
  color: #ff6b6b;
}
.role-chip-del:hover { color: #fff; }

/* UI Theme Picker */
.ui-theme-grid {
  display: flex; gap: 0.65rem; flex-wrap: wrap; margin-top: 0.35rem;
}
.ui-theme-card {
  background: none; border: 2px solid var(--border);
  border-radius: var(--radius-sm); padding: 0; cursor: pointer;
  transition: all var(--transition); overflow: hidden;
  display: flex; flex-direction: column; align-items: center; width: 76px;
}
.ui-theme-card:hover  { border-color: var(--primary); transform: translateY(-1px); }
.ui-theme-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.ui-theme-preview {
  width: 100%; height: 50px; display: flex; overflow: hidden;
  border-radius: calc(var(--radius-sm) - 2px) calc(var(--radius-sm) - 2px) 0 0;
  background: #ffffff;
}
.utp-sidebar { width: 20px; flex-shrink: 0; }
.utp-content { flex: 1; display: flex; flex-direction: column; padding: 5px 4px; gap: 3px; }
.utp-bar { height: 7px; border-radius: 4px; width: 55%; margin-bottom: 2px; }
.utp-lines { display: flex; flex-direction: column; gap: 2px; }
.utp-lines::before,
.utp-lines::after  { content: ''; display: block; height: 4px; border-radius: 3px; background: rgba(0,0,0,0.10); }
.utp-lines::before { width: 90%; }
.utp-lines::after  { width: 65%; }
.ui-theme-card > span {
  font-size: 0.70rem; font-weight: 600; color: var(--text-muted);
  padding: 4px 0 3px; text-align: center; width: 100%;
}
.ui-theme-card.active > span { color: var(--primary); }

/* ── Save bar ── */
.settings-save-bar {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0.9rem 1.1rem;
}
.btn-save-settings { min-width: 180px; justify-content: center; }

/* ── Stock threshold inline ── */
.threshold-inline {
  display: flex; align-items: center; gap: 0.5rem;
}
.threshold-inline-input {
  width: 80px !important; text-align: center; font-size: 1.05rem !important;
  font-weight: 700 !important; padding: 0.35rem 0.5rem !important;
}
.threshold-inline-label { font-size: 0.855rem; color: var(--text-muted); white-space: nowrap; }
.threshold-hint { font-size: 0.775rem; color: var(--text-muted); margin-top: 0.5rem; line-height: 1.45; padding: 0 0.1rem; }